nariakiiwatani / ofxNDI

NewTek NDI SDK Wrapper for openFrameworks.
https://ndi.tv/
MIT License
103 stars 19 forks source link

ofxNDIVideoGrabber Image to ofxCvColorImage #15

Closed freshmania-at closed 4 years ago

freshmania-at commented 4 years ago

Hello,

I'm trying to use the received NDI image and use it with OpenCV.

It seems like the pixel format is different (I get a lot of lines in the image) and I can't figure out what to do.

looks like this: https://forum.openframeworks.cc/uploads/default/original/2X/f/f0159bd88b523ab3f3ff3d0e8eebc7400808e513.png Do you have a hint, how to convert the ofxNDIVideoGrabber image to an ofxCvColorImage?

Thanks for your help!

nariakiiwatani commented 4 years ago

Yes,

ofxCvColorImage data seems to be like rgbrgbrgb... of unsigned char. https://openframeworks.cc/documentation/ofxOpenCv/ofxCvColorImage/ so you may get good result by doing pixels.setImageType(OF_IMAGE_COLOR); before converting to ofxCvImage.

But I recommend not to use it unless the image is small and frequency is low enough because it's slow.

If I were you, I would use OpenCV functionality to convert.

I'm not OpenCV expert but as far as I know you can convert image data using cv::Mat::convertTo or something like that.

You can check the format of receiving image in getOfPixelFormatFromFourCCType https://github.com/nariakiiwatani/ofxNDI/blob/master/src/ofxNDIFrame.cpp#L122

Hope it helps!

freshmania-at commented 4 years ago

Oh yes, thanks a lot! This -> pixels.setImageType(OF_IMAGE_COLOR); works for now.

can be closed.