OpenCV (ofxCvImage) | How to load an external file?

Noob question but I couldnt find an answer by looking at the source files…
How can I load an external file (say a jpg image) into a ofxCvColorImage ?

ofxCvColorImage img;  
img = cvLoadImage([file name])   

doesnt work… I guess it’s because img doesnt directly return an IplImage pointer.
I guess I should make img.cvImage public but I would have to edit the library :slight_smile:

I could be way off here because I am new to this, but you could probably do it this way:

ofxCvColorImage ofImage;
IplImage* image;

image = cvLoadImage();
ofImage = image;

But like I said I am new to this so…

I am still hoping someone will answer my question related to oF / OpenCV here

this should work

ofxCvColorImage img;
ofImage fileImage;


hope it helps


yep. this should work indeed but I was looking for a more “elegant” solution… I just started using opencv with openframework and it’s a bit weird :roll:

hi all

i can use images with alpha in ofxCvImage?? and conserve the alpha in all the process??

i want to take a image with alpha, and get with ROI parts of the images, and make alot of litlle parts of images all with alpha, maybe por take and image and make a puzzle, or jigsaw puzzle, but with alpha and with open cv… i need to handle alpha with open cv, any idea??

sorry, no alpha in ofxOpenCv yet. it’s on the todo list though.

Hi, i’ve added a ofxCvColorImageAlpha class to ofxOpenCv addon



wow thx n3m3da It will try it and will comment on you :slight_smile:

thanxs n3m3da this is great!

found this class extremely useful - here is a port to 007 if anyone needs it

It’s quite old topic but here is a working class with of 0.9.3