ofxCvColorImage can convert ofImage?

I want to take a special frame in ofVideoPlayer to generated a ofimage.

  
unsigned char *  pixelColor =  VideoPlayer>getPixels();  
ofTexture texColor = loadData(pixelColor,VideoPlayer>getWidth(),VideoPlayer->getHeight(),GL_RGB);  
ofPixels  tmp;  
texColor.readToPixels(tmp);  
ofImage.setFromPixels(tmp);  

if ofxCVColorImage can convertd to ofimage,I think the process is easier.

  
ofxCvColorImage cvImg;  
cvImg.setFromPixels(VideoPlayer>getPixels());  
  
ofImage myImg = cvImg; Error........  

You can grab a texture from an ofxCvImage using getTextureReference() and then draw that:

  
  
ofTexture tex = cvImage.getTextureReference();  
tex.draw();  
  

or you can grab the pixels from the ofxCvImage and add those to an ofImage

  
  
ofImage img;  
img.setFromPixels(cvImage.getPixelsRef());  
  

Hope that helps a little bit.

thanks…
as this does, it’s simplier.

also if you just want to go from ofVideoPlayer -> ofImage you can do:

  
  
ofImage img;  
img.setFromPixels(video.getPixelsRef);  
  

Oh my god !

thank you very much ! arturo !

I love OF !!

[quote=“arturo, post:4, topic:8318”]
also if you just want to go from ofVideoPlayer -> ofImage you can do:[/quote]

Based on ofxCvImage documentation (base class for ofxCvColorImage):
http://www.openframeworks.cc/documentation/ofxOpenCv/ofxCvImage.html#getTextureReference

If I understand correctly, I should be able to do this (verified bUseTexture = true):

  
myCvColorImage.getTextureReference().bind();  

However, it does’nt work for me and so I must do this in order to reference myCvColorImage texture:

  
ofImage img;  
img.setFromPixels(myCvColorImage.getPixelsRef());  
  
img.getTextureReference().bind();  

In regards to myCvColorImage.getTextureReference().bind();:
Do I need to reload the myCvColorImage or something ?

yes that should work, which problem are you having?

Thanx for the quick reply, sorry for my delayed reponse…

I was getting a garbled-garbage image ; incomplete pixel image, noise, etc. (sorry I forgot to mention this!)

I resolved the problem by updating the CvColorImage texture since I was manipulating it and then drawing it via openGL :

  
  
myCvColorImage *= otherCvColorImage;  
myCvColorImage.updateTexture();