Ask Your Question

Imwrite() on iOS - Does it work?

asked 2017-02-24 06:06:07 -0500

ginister gravatar image

Hi everyone, I'm running this code on iOS

  imwrite("currentimg.jpg", capturedFrameOutImg);

And not getting any errors, however if I go into the photos app I don't see my Mat there. The Mat is a 3 channel image in the program but it doesn't seem to be saving. Is this functionality working on iOS or is this method not implemented? And if it is, where might I find my file?


edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2017-02-27 13:17:37 -0500

ginister gravatar image

The answer is yes! I found similar code on SO to this which did the job just fine:

 NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *directory = [paths objectAtIndex:0];
NSString *filePath = [directory stringByAppendingPathComponent:[NSString stringWithFormat:@"hand%f.jpg", CFAbsoluteTimeGetCurrent()]];
const char* filePathC = [filePath cStringUsingEncoding:NSMacOSRomanStringEncoding];

const cv::String thisPath = (const cv::String)filePathC;

//Save image
imwrite(thisPath, capturedFrame);
edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2017-02-24 06:06:07 -0500

Seen: 1,034 times

Last updated: Feb 27 '17