I am using OpenCV via Matlab to detect faces in a video and then do some processing using Matlab. At the moment I do face detection on the IplImage-structured frames (queried by cvQueryFrame) of the video. I save each of the queried frames as a jpg and then use the face coordinates to get the ROI for the required processing. See the portion of code outlining this below.
% After reading in frame from video..
for i=1:size
img = calllib('highgui210','cvQueryFrame',cvCapture);
calllib('cxcore210','cvFlip',img,img,1);
calllib('highgui210', 'cvSaveImage', 'ThisFrame.jpg', img, ptr);
% Rest of the processing comes here..
This being the case, I feel that there should be an easier and less-crude way to convert an ‘IplImage’ image to a matrix or array in Matlab. Is this a possibility? If yes,how is this done?
Some pointers in this direction would be much appreciated!
Try mexing the following code:
You’ll end up with a function (mex) IplImage2mxArray, use it in Matlab:
Due to internal opencv representations the channels of img might be permuted (BGR instread of RGB). Also note that img might contain four channels – an additional alpha channel.
-Shai