Ask Your Question

asquared's profile - activity

2018-08-14 11:46:28 -0600 received badge  Notable Question (source)
2016-10-14 01:07:19 -0600 received badge  Popular Question (source)
2013-01-30 16:11:24 -0600 received badge  Student (source)
2012-12-09 21:34:43 -0600 commented answer imencode & imdecode in iOS

I checked the libraries, but no luck. libjpeg is already included.

2012-12-02 15:24:45 -0600 asked a question imencode & imdecode in iOS

Hi All,

I am trying to use OpenCV-2.4.3 in my iOS program. However, I have some issues with encoding and decoding the cv::Mat data structures. Here is the code below:

- (void) processImage:(cv::Mat&)image {
     /** processImage is a callback function, which is called for every frame captured by the camera. */
      vector<int> param;
      vector<uchar> buff;
      param.push_back(CV_IMWRITE_JPEG_QUALITY); 
      param.push_back(40); /* jpeg quality */
      cv::Mat image_copy(cv::Size(WIDTH,HEIGHT), CV_8UC3, cv::Scalar(0));
      cv::Mat outputFrame(cv::Size(WIDTH,HEIGHT), CV_16UC3, cv::Scalar(0));

     cv::cvtColor(image, image_copy, CV_BGRA2BGR);
     cv::imencode(".jpg", image_copy, buff, param);

     NSLog(@"Size using jpg compression %d, ", (int) buff.size());

     cv::imdecode(cv::Mat(buff), CV_LOAD_IMAGE_COLOR, &outputFrame);

     /** Testing the encode and the decode functions. */
}

However, the code looks good to me, but I get the following error:

OpenCV Error: Unspecified error (could not find encoder for the specified extension) in imencode, file /Users/alexandershishkov/opencv2.4.3rc/opencv/modules/highgui/src/loadsave.cpp, line 415
libc++abi.dylib: terminate called throwing an exception

Now, I am not sure what to do? I am kinda stuck on the same error for a long time. I have recompiled the OpenCV library for the iOS, however I don't see the mistake I am doing.

Comments/Code?

Thanks