android - How to check front Cam ID? also getting captured image is mirror image from front camera. -
i trying use default camera intent both image , video capture. when turn front camera , capture image or video preview (captured image or video ) inverted . want put prescale in frontcamera. didn't know find camera id in default camera.!!
note : not custom camera.!!
problem : captured image front camera getting image mirror image. if there problem ? didnt ! thx
even stored captured image in sdcard mirror image! how prescale or other idea correct it??
help!
photo.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { captureimage(); } });
catureimage method
private void captureimage() { context context = this; packagemanager packagemanager = context.getpackagemanager(); if (packagemanager.hassystemfeature(packagemanager.feature_camera) == false && packagemanager .hassystemfeature(packagemanager.feature_camera_any) == false) { toast.maketext(camerarolling2.this, "camera not available'", toast.length_short).show(); return; } intent takepictureintent = new intent(mediastore.action_image_capture); if (takepictureintent .resolveactivity(camerarolling2.this.getpackagemanager()) != null) { file photofile = null; try { photofile = createimagefile(); } catch (ioexception ex) { // error occurred while creating file toast.maketext(camerarolling2.this, "error connecting camera", toast.length_short).show(); ex.printstacktrace(); } // continue if file created if (photofile != null) { takepictureintent.putextra(mediastore.extra_output, uri.fromfile(photofile)); startactivityforresult(takepictureintent, capture_image_activity_request_code); showimg.setimagebitmap(null); } } } @suppresslint("simpledateformat") private file createimagefile() throws ioexception { // create image file name string timestamp = new simpledateformat("yyyymmdd_hhmmss") .format(new date()); string imagefilename = "jpeg_" + timestamp + "_"; file storagedir = environment .getexternalstoragepublicdirectory(environment.directory_pictures); file image = file.createtempfile(imagefilename, ".jpg", storagedir); mcurrentphotopath = image.getabsolutepath(); log.v("createimagefile", "" + mcurrentphotopath); return image; }
and activity result
@override public void onactivityresult(int requestcode, int resultcode, intent data) { if (requestcode == capture_image_activity_request_code && resultcode == activity.result_ok) { file imgfile = new file(mcurrentphotopath); if (imgfile.exists()) { bitmapfactory.options bitmap_options = new bitmapfactory.options(); bitmap_options.insamplesize = 4; bitmap_options.outheight = 200; bitmap_options.outwidth = 200; bitmap mybitmap = bitmapfactory.decodefile( imgfile.getabsolutepath(), bitmap_options); showimg.setimagebitmap(mybitmap); if (showimg.getdrawable() == null) { log.e("imageview", "null image"); imageflag = false; } else { log.e("imageview", "image view updated"); imageflag = true; } } } if (resultcode == activity.result_canceled) { toast.maketext(camerarolling2.this, "camera option canceled", toast.length_short).show(); imageflag = false; }
i trying use default camera intent both image , video capture
there no single "default camera intent" in android. there thousands of android device models. these ship hundreds of different "default camera intent" apps. users can install other "default camera intent" apps play store or other places. 1 of apps user chooses use take picture (action_image_capture
) or record video (action_video_capture
).
when turn front camera , capture image or video preview (captured image or video ) inverted
i going guess "inverted", mean "rotated".
there hundreds of different possible camera apps. many save image or video metadata tells viewer app rotate image (e.g., jpeg photos might have orientation exif header). not, electing rotate content themselves.
also, images or videos camera (front-facing, rear-facing, external) rotated.
hence, should not assuming rotation tied particular camera user used. instead, examine actual content , react accordingly. this sample project demonstrates rotating jpeg image, using couple of different techniques.
so want put prescale in frontcamera.
you cannot control this.
but didn't know find camera id in default camera.!!
you cannot control this.
Comments
Post a Comment