I’ve written a slideshow application that reads a file [imread()] (any type supported by OpenCV), then formats it to fit a user window [resize()], and then displays the file [imshow()]. I’d like to make this same image available over NDI, using the NDI SDK. The sample code with the SDK opens a .png file, decodes the file, and then sends it over the network.
I’m having trouble understanding the data formats. I tried taking my Mat object and using the opencv pngImage to convert the data, but the NDI code returns an error that it’s not a valid PNG file. Any help would be appreciated.
BOOL ndiShow(Mat m)
{
Mat pngImage(m.rows, m.cols, CV_8UC4, (cv::Vec4b*)m.data);
std::vector<unsigned char> image_data;
unsigned long xres = 0, yres = 0;
// I'm not sure that the data pointer or size is correct here
if (decodePNG(image_data, xres, yres, &pngImage.data[0], pngImage.total(), true)) {
return FALSE;
}
// We are going to create a frame
NDIlib_video_frame_v2_t NDI_video_frame;
NDI_video_frame.xres = pngImage.cols;
NDI_video_frame.yres = pngImage.rows;
NDI_video_frame.FourCC = NDIlib_FourCC_type_RGBA;
NDI_video_frame.p_data = pngImage.data;// &image_data[0];
NDI_video_frame.line_stride_in_bytes = pngImage.cols * 4;
// We now submit the frame. Note that this call will be clocked so that we end up submitting at exactly 29.97fps.
NDIlib_send_send_video_v2(g_pNDI_send, &NDI_video_frame);
return TRUE;
}