cv.GetMat(myIplImage)
Since OpenCV seems to be moving away from IplImages, it would make sense for cv_bridge to do the same. Perhaps that should be ticketed.
Originally posted by Dan Lazewatsky with karma: 9115 on 2012-02-13
This answer was ACCEPTED on the original site
Post score: 2
Original comments
Comment by Pi Robot on 2012-02-13:
Many thanks @diaz! Do you happen to know what type of Mat is returned by GetMat? For example, if I use 'frame = cv.GetMat(self.bridge.imgmsg_to_cv(ros_image, "bgr8"))', what Mat type is frame? e.g. 8UC3, 32FC3? etc. I ask because I'm still having size and/or type compatibility problems when trying to copy or perform other operations with the 'frame' matrix and other image matrices in my code.
Comment by Dan Lazewatsky on 2012-02-13:
I'm not sure what the correspondence is between IplImage encodings and the regular Mat encodings, but it should be semantically equivalent. bgr8 would likely give you 8UC3 or something similar. When creating new Mats of the same type, you can be encoding-agnostic by using mat.type and mat.channels.
Comment by Pi Robot on 2012-02-13:
Thanks again @diaz. Yes, it looks like its type 8UC3 or 16 in integer format.
Comment by Dan Lazewatsky on 2012-02-13:
Could you post code that requires converting to a numpy array? Most OpenCV functions work on array-like objects, and Mats certainly are. I just tried cv.CvtColor using a Mat as the source and destination, and it works fine.
Comment by Pi Robot on 2012-02-13:
OK, I jumped the gun. It looks like it is only the functions in cv2 that require a numpy array. In the lk_track.py demo the convert function used is cv2.cvtColor and this requires a numpy array whereas the old cv.CvtColor does not. Similarly, the new cv2.goodFeaturesToTrack requires numpy arrays.