convert mat to iplimage
hi to all!
i have a simple question...can i convert a Mat imege into a Iplimage* ???
i need to insert the Mat image into a video,and the cvWriteFrema need a IplImage...
thanks :)
cv::Mat mat_img;
IplImage ipl_img = mat_img.operator IplImage();
I have always had to do it myself in C:
void iplimage_from_cvmat(CvMat* input, IplImage * output) { int x,y; for( x=0; x < output->width; x++ ){ for( y=0; y < output->height; y++) { // note: CvMat is indexed (row, column) but IplImage is indexed (x,y) // so the indexes must be interchanged! cvSetReal2D( output, x, y, CV_MAT_ELEM(*input, uchar, y, x) ); } } }
@elmiguelao: Can you provide the java equivalent of this code?
Asked: 2012-10-08 09:57:00 -0600
Seen: 12,639 times
Last updated: Oct 08 '12
Why don't you use VideoWriter::write?
I try to use VideoWriter::write... I create
VideoWriter writer2("video_rect_out2.avi", CV_FOURCC('M','J','P','G'), fps, cvSize(img_template.cols, img_template.rows), true);
and after i use
writer2 << img_template;
but at the end the video result is empty...