C ++ opencv project porting to Android (Mat-"IplImage *)

Source: Internet
Author: User

C ++ opencv project porting to Android (Mat-"IplImage *)

Recently, many problems have been encountered when porting the pedestrian detection C ++ project on the PC to the Android platform. Therefore, some important points have been recorded.
1. You 'd better refer to the mix-processing in the Opencv sample.
2. Data Structure Problems: Especially converting Mat data obtained from java into IplImage *. This will cause many problems. The approximate method on the internet is:

// The first conversion method: error IplImage * imgIpl1 = cvCreateImage (cvSize (w, h), 8, 3); Mat temp = preMat. clone (); imgIpl1-> imageData = (char *) temp. data; // The Second Conversion Method IplImage imgIpl2 = preMat. operator _ IplImage (); // IplImage imgIpl3 = (IplImage) (preMat); // IplImage * imgIpl4 = & IplImage (preMat ); // The Fifth conversion method is Mat imgtemp; imgtemp = mGr. clone (); imgshow = cvCreateImage (cvSize (mGr. cols, mGr. rows), 8, 3); imgshow. imageData = (char *) imgtemp. data;

However, it is not easy for me, and I don't know why. So I continued to explore and encountered this problem: taking address of temporary [-fpermissive]
Finally, the solution was found:

Mat& mGr  = *(Mat*)addrGray;IplImage temp = (IplImage)mGr;IplImage *imgshow =&temp;

The specific reason is: The operation obtains the address of the Temporary Variable. After the return result, the temporary variable "disappears" and you cannot use it any more.

Okay, the problem is solved. The Code has finally been transplanted!

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.