[英]How to convert NSData into image (Mat) of OpenCV
The app receives bytes which are the image data (PNG format) . 该应用程序接收的字节是图像数据(PNG格式) 。 How to convert
NSData
bytes or (const void *) buffer into cv::Mat? 如何将
NSData
字节或(const void *)缓冲区转换为cv :: Mat? I know I have to use something like 我知道我必须使用类似
NSData -> some array -> imdecode -> cv::Mat
How to do this in proper way? 如何以适当的方式做到这一点?
May be it will help for the other generations. 可能会对其他世代有所帮助。 The solution:
解决方案:
NSData *data = ....//some byte array data
cv::Mat matC = cv::imdecode(Mat(1, (int)[data length], CV_8UC1, (void*)data.bytes), CV_LOAD_IMAGE_UNCHANGED);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.