You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 29, 2022. It is now read-only.
my app consumes 80 MB above memory after perspective correction. After logging,i found image size was approximately doubled (original size:1936X2592 and perspective corected size:2566X3494). This consumed memory was not relased completely ,only release upto 50MB and internally release somtimes only. So memory usage was summed up for each image's perspective correction and app crashes in device with 512MB ram.Reason was below operation. I don't understand reason to use these operations.
Finally i figure out this was causing memory problem and app crashes..I changes size of perspectively corrected image to original image size. And memory reduces by half. and also app don't crashes.Changes I made
(void)correctPerspective{
// Define the destination image
cv::Mat original = [OpenCV cvMatFromUIImage:self.pickedImg];
The two main compiler switches that you would often use are when you build your application with a third party library that is not ARC compliant and vice versa, are
-fno-objc-arc
-fobjc-arc
-f is the switch and no-objc-arc and objc-arc are the options that you are turning on. As evident from the names, the first one turns off ARC and the second turns on.
For example, if your application is ARC enabled but a third party library is not, you use the first switch -fno-objc-arc to exclude the third party library. Conversely, if your application is not yet ARC enabled (gasp!) but the third party library you are integrating is, you use the second switch -fobjc-arc You add these flags to the project from the Build phases tab as shown below.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
my app consumes 80 MB above memory after perspective correction. After logging,i found image size was approximately doubled (original size:1936X2592 and perspective corected size:2566X3494). This consumed memory was not relased completely ,only release upto 50MB and internally release somtimes only. So memory usage was summed up for each image's perspective correction and app crashes in device with 512MB ram.Reason was below operation. I don't understand reason to use these operations.
Finally i figure out this was causing memory problem and app crashes..I changes size of perspectively corrected image to original image size. And memory reduces by half. and also app don't crashes.Changes I made
(void)correctPerspective{
// Define the destination image
cv::Mat original = [OpenCV cvMatFromUIImage:self.pickedImg];
CGFloat scaleFactor =[self.imgDoc contentScale];
vector anchorPts;
cv::Point2f src[4], dst[4];
src[0].x = anchorPts[0].x;
src[0].y = anchorPts[0].y;
src[1].x = anchorPts[1].x;
src[1].y = anchorPts[1].y;
src[2].x = anchorPts[2].x;
src[2].y = anchorPts[2].y;
src[3].x = anchorPts[3].x;
src[3].y = anchorPts[3].y;
dst[0].x = 0;
dst[0].y = 0;
dst[1].x = original.cols - 1;
dst[1].y = 0;
dst[2].x = original.cols - 1;
dst[2].y = original.rows - 1;
dst[3].x = 0;
dst[3].y = original.rows - 1;
cv::Mat undistorted= cv::Mat( cvSize(original.cols,original.rows), CV_8UC1);
cv::warpPerspective(original, undistorted, cv::getPerspectiveTransform(src, dst), undistorted.size());
original.release();
finalImg=[OpenCV UIImageFromCVMat:undistorted];
undistorted.release();
}
The text was updated successfully, but these errors were encountered: