Reputation: 1120
When trying to load an Image and copy a part of it or smooth, everything ok, but when I'm capturing video and try to copy a part of the frame, it becomes reverse and rotated on 180 degrees, does anybody knows why?
IplImage *scaled=cvCreateImage(sz,IPL_DEPTH_8U,3);
capture = cvCaptureFromFile( "C:\\New York.avi" );
IplImage *frame = cvQueryFrame( capture );
cvResize(frame,scaled,CV_INTER_LINEAR);
cvShowImage("123",scaled);
cvReleaseImage(&scaled);
Upvotes: 1
Views: 1160
Reputation: 93410
You need to match the depth and number of channels of the destination image to make the resize operation work. Right now, you are assuming these values.
capture = cvCaptureFromFile("C:\\New York.avi");
IplImage* frame = cvQueryFrame(capture);
IplImage* scaled = cvCreateImage(sz, frame->depth, frame->nChannels);
cvResize(frame, scaled, CV_INTER_LINEAR);
cvShowImage("123", scaled);
cvWaitKey(0); // wait for a key press, and then
cvReleaseImage(&scaled);
I hope you are using a recent version of OpenCV.
EDIT:
On a comment below you stated that you are using OpenCV b5a. I just found a message from 2006 that mentions this version, which means you are using a jurassic release of OpenCV and that's probably the root of the problem.
There's a page that shows how to use OpenCV with C++ Builder, but if you are having problems with that, I suggest you move to another compiler.
What you are observing is most likely a bug of this ancient release of OpenCV.
Upvotes: 2