Re: NSImage to IplImage (was: Adding an image to a project)
Re: NSImage to IplImage (was: Adding an image to a project)
- Subject: Re: NSImage to IplImage (was: Adding an image to a project)
- From: D'Angelo Emmanuel <email@hidden>
- Date: Thu, 15 Jul 2010 19:15:19 +0200
- Acceptlanguage: fr-FR, fr-CH
- Thread-topic: NSImage to IplImage (was: Adding an image to a project)
Hi Vincenzo,
Besides getting an NSImage from the correct path in your app bundle, you'll have to get the pixel data.
An NSImage is an object that hides the raw pixel data from you, because of a display resolution independance purpose.
To access the pixel data, you have the choice between :
1. either getting an NSBimtmapImageRep
2. or creating a CGImage
from your NSImage.
These 2 structures then have methods to copy their pixel data into a char or float array (check the documentation of NSBitmapImageRep and Quartz Drawing, you may have to allocate inbetween a color space object).
It's fairly straightforward if you follow the documentation step by step.
An additional issue that you may have is that OpenCV expects BGR images instead of the usual RGB ordering. It seems a bit strange, but I didn't find any workaround (the cvCvtColor function does not modify the channel ordering property of teh IplImages).
Emmanuel_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden