Using toOf from ofxCv

Hi ,

trying to use ofxCv::toOf() to convert a cv::Mat to an ofImage I get the following error on a Rapsberry pi :

Utilities.h: In function ‘void ofxCv::toOf(cv::Mat, ofImage_&) [with T = unsigned char]’:
src/testApp.cpp:46:27: instantiated from here
…/…/…/addons/ofxCv/libs/ofxCv/include/ofxCv/Utilities.h:290:3: error: no matching function for call to ‘toOf(cv::Mat&, unsigned char*)’
…/…/…/addons/ofxCv/libs/ofxCv/include/ofxCv/Utilities.h:290:3: note: candidates are:
…/…/…/addons/ofxCv/libs/ofxCv/include/ofxCv/Utilities.h:269:10: note: ofVec2f ofxCv::toOf(cv::Point2f)
…/…/…/addons/ofxCv/libs/ofxCv/include/ofxCv/Utilities.h:269:10: note: candidate expects 1 argument, 2 provided
…/…/…/addons/ofxCv/libs/ofxCv/include/ofxCv/Utilities.h:270:10: note: ofVec3f ofxCv::toOf(cv::Point3f)
…/…/…/addons/ofxCv/libs/ofxCv/include/ofxCv/Utilities.h:270:10: note: candidate expects 1 argument, 2 provided
…/…/…/addons/ofxCv/libs/ofxCv/include/ofxCv/Utilities.h:271:14: note: ofRectangle ofxCv::toOf(cv::Rect)
…/…/…/addons/ofxCv/libs/ofxCv/include/ofxCv/Utilities.h:271:14: note: candidate expects 1 argument, 2 provided
…/…/…/addons/ofxCv/libs/ofxCv/include/ofxCv/Utilities.h:272:13: note: ofPolyline ofxCv::toOf(cv::RotatedRect)
…/…/…/addons/ofxCv/libs/ofxCv/include/ofxCv/Utilities.h:272:13: note: candidate expects 1 argument, 2 provided
…/…/…/addons/ofxCv/libs/ofxCv/include/ofxCv/Utilities.h:273:39: note: template ofPolyline ofxCv::toOf(const std::vector<cv::Point_<Tp> >&)
…/…/…/addons/ofxCv/libs/ofxCv/include/ofxCv/Utilities.h:284:7: note: template void ofxCv::toOf(cv::Mat, ofPixels
&)
…/…/…/addons/ofxCv/libs/ofxCv/include/ofxCv/Utilities.h:288:7: note: template void ofxCv::toOf(cv::Mat, ofImage_&)

could someone point me in the right direction ?

THanks.

E

can you post the code that you are passing? seems that is failing to compile because you are passing unsigned char* instead of ofImage or ofPixes but it’s hard to tell without seeing the code that is producing the error

well actually nothing “fancy”

I have a ofImage and a ofxCv::Mat in ofApp.h

then in update() I do :

toOf(my_Mat, My_Img);

passing ofImage.getPixelsRef() doesn’t throw any error but when I try to draw the image I get a black screen . (and I called update() on the ofImage)

thanks

I found I had this same error,

I think the problem is that in the ofxCv code, calling the overloaded version of toOf that takes a mat and an ofImage actually just calls the PixelsRef version internally.

The problem is it uses the function ofImage.getPixels() instead of ofImage.getPixelsRef()

I changed this line of code from

toOf(mat, img.getPixels()); to ttoOf(mat, img.getPixelsRef()); inside the ofxCv addon (line 290 in ofxCv Utilities.h) and That solved the problem for me.

if you can report a bug in ofxCv repo? ping @kylemcdonald

this was a bug, it was fixed last week with this commit https://github.com/kylemcdonald/ofxCv/commit/005c0a7ae35e45fc505546599e06ff3b9724ac11

i had accidentally merged some changes from the “develop” branch into master.