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.