As stated in documentation:
IplImage.imageData (from OpenCV library):
A pointer to the aligned image data
Image.tostring() (from Python PIL):
Returns a string containing pixel data, using the standard “raw”
encoder.
What is the difference between the results of Image.tostring() and IplImage.imageData ? What should I do if I want to get exactly the same data as returned by IplImage.imageData in Python ?
EDIT:
Just to clarify, I need to use PIL to load images as I have a python service to receive data from internet and there’s no straightforward way in OpenCV to load an image from memory instead of disk.
While Opencv image, pixel data is ordered as BGR, in PIL it is RGB.
You can convert a PIL image data to opencv as below.
For more information here.
http://opencv.willowgarage.com/documentation/python/cookbook.html