Im using tesseract OCR and it only reads 300 dpi images, when i take photos using UIImage picker controller camera the images are in 72 dpi how can i take images in 300 dpi like the stock app in iOS?
I'm using Tesseract on an iPad with iOS7 and the following code successfully presents the UIImagePickerController and I get an image back that I can readily OCR with Tesseract:
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
iosPicker = [[UIImagePickerController alloc] init];
iosPicker.sourceType = UIImagePickerControllerSourceTypeCamera;
iosPicker.mediaTypes = [[NSArray alloc] initWithObjects: (NSString *) kUTTypeImage, nil];
iosPicker.allowsEditing = NO;
iosPicker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;
iosPicker.cameraDevice = UIImagePickerControllerCameraDeviceRear;
iosPicker.modalPresentationStyle = UIModalPresentationFullScreen;
iosPicker.delegate = self;
[self presentViewController:iosPicker animated:YES completion:^{}];
}
Side note: iosPicker is an instance variable defined in the interface for the view controller.
Related
Thumbnails do not display in the UIImagePickerController when running on iPhone 11 or real device with iOS 14.
UIImagePickerController * picker = [[UIImagePickerController alloc] init];
picker.delegate=self;
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
[self presentViewController:picker animated:YES completion:nil];
Result:
Photos and Albums showing as Blank but when I tap on-screen image will be selected.
For me, it was caused by using
UIScrollView.appearance(whenContainedInInstancesOf: [UINavigationController.self]).backgroundColor = .backgroundPrimaryNew
I don't know why is that, but after I've removed this line it began working again and thumbnails are showing.
Try this
Instead of presenting add UIImagePickerController as subView
UIImagePickerController * picker = [[UIImagePickerController alloc] init];
picker.delegate=self;
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
[self.view addSubview:self.picker.view];
[self addChildViewController:self.picker];
[self.picker didMoveToParentViewController:self];
I am using UIImagepickerController to capture video in my app.
Sometimes it behaves strangely - that image capturing is coming. Mostly it comes when a new user is registered and try to capture a video or a new ipa file is installed and tested. Eventhough it appears randomly.
When I prompt UIImagepickerController it display take photo button (White button) instead of video record button (Red button)
Here is my code -
UIImagePickerController *imagePicker=[[UIImagePickerController alloc]init];
imagePicker.delegate=self;
if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
imagePicker.allowsEditing = YES;
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.mediaTypes = [[NSArray alloc] initWithObjects: (NSString *) kUTTypeMovie, nil];
}
[self presentViewController:imagePicker animated:YES completion:NULL];
Just try replacing your code with this.
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
// picker.mediaTypes = [NSArray arrayWithObject:(NSString *)kUTTypeMoviekUTTypeImage];
picker.mediaTypes = [NSArray arrayWithObjects:(NSString *)kUTTypeMovie,nil];
//picker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModeVideo;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentViewController:picker animated:YES completion:NULL];
I want to crop a photo that is taken in the app and then save. I am using the GKImagePicker so that I can do this but if I use the code below even though I push the take photo button in my app it shows me the photo library which I pick to crop. I do not want to do this and just want to crop my photo which I have taken in the app.
- (IBAction)takePhoto:(UIButton *)sender {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
self.imagePicker = [[GKImagePicker alloc] init];
self.imagePicker.cropSize = CGSizeMake(320, 320);
self.imagePicker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentModalViewController:self.imagePicker.imagePickerController animated:YES];
[self presentViewController:picker animated:YES completion:NULL];
}
Remove the last line in your code:
[self presentViewController:picker animated:YES completion:NULL];// remove
and give it a try ;)
You can also check this.
I am getting the following error running my app on a device (I'm not getting it running in the simulator):
CGImageCreateWithImageProvider`: invalid image size: 180 x 180.
- (IBAction)choosePic:(id)sender {
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
self.imageOne = [[UIImagePickerController alloc] init];
self.imageOne.sourceType = UIImagePickerControllerSourceTypeCamera;
self.imageOne.delegate = self;
}
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {
self.imageOne = [[UIImagePickerController alloc] init];
self.imageOne.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
self.imageOne.delegate = self;
}
[self presentViewController:self.imageOne animated:YES completion:nil];
}
As per the answer
this error can be of lower iOS version devices. As some iOS versions don't support resizing images. And also may be the problem of JPG image. Try with PNG image.
I am trying to build an app that would let user pick and upload a video from the library on iPad. I need the max video length to be 30 sec.
I am using the following code:
UIImagePickerController *mediaPicker = [[UIImagePickerController alloc] init];
mediaPicker.mediaTypes = [NSArray arrayWithObjects:(NSString *)kUTTypeMovie,(NSString *)kUTTypeImage,nil];
mediaPicker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
mediaPicker.videoQuality = UIImagePickerControllerQualityTypeIFrame960x540;
mediaPicker.videoMaximumDuration = 30.0f;
mediaPicker.delegate = self;
if (self.imagePickerPopOverController.popoverVisible) {
[self.imagePickerPopOverController dismissPopoverAnimated:YES];
}
self.imagePickerPopOverController = [[UIPopoverController alloc] initWithContentViewController:mediaPicker];
[self.imagePickerPopOverController presentPopoverFromBarButtonItem:self.navigationItem.rightBarButtonItem
permittedArrowDirections:UIPopoverArrowDirectionUp
animated:NO];
After the video has been picked, I expect the UIImagePickerController to show a trimmer to trim the video length to 30 sec (if its longer), but it does not.
Set this before you present the controller.
imagePickerController.allowsEditing = YES;