[AC-745] Camera preview is different to taken image on Android with overlay
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Resolved |
Resolution | Duplicate |
Resolution Date | 2015-09-29T01:28:04.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Titanium SDK & CLI |
Labels | Android, Camera, Overlay, TCSupportTriage |
Reporter | Osian Evans |
Assignee | Shak Hossain |
Created | 2014-12-10T09:47:53.000+0000 |
Updated | 2016-03-08T07:37:00.000+0000 |
Description
When using an overlay with Ti.Media.showCamera() on Android, the resulting preview shows a zoomed in version of the final picture that is taken.
On taking the photo, the actual photo is displayed for a moment within the preview view, and it is visibly different.
function ModuleConstructor(_params) {
var self = Ti.UI.createWindow();
var cameraOverlay = Titanium.UI.createView({});
var cameraOverlayButton = Titanium.UI.createImageView({
bottom: 10,
image: '/images/camera_btn.png',
});
cameraOverlay.add(cameraOverlayButton);
cameraOverlayButton.addEventListener('click', function(e){
Ti.Media.takePicture();
});
self.addEventListener("postlayout", postlayoutHandler);
function postlayoutHandler(e) {
self.removeEventListener("postlayout", postlayoutHandler);
Titanium.Media.showCamera({
overlay: cameraOverlay,
showControls: false,
success: function(e) {
Ti.API.info('# SUCCESS : '+e.success);
...code etc...
},
cancel: function(e) {
Ti.API.info('# CANCEL : '+e.error);
...code etc...
},
error: function(e) {
Ti.API.info('# ERROR : '+ e.code +' : '+ e.error);
...code etc...
},
mediaTypes:Ti.Media.MEDIA_TYPE_PHOTO,
});
}
return self;
};
module.exports = ModuleConstructor;
Attachments
File | Date | Size |
---|---|---|
motog2_640.mov | 2015-07-06T08:21:30.000+0000 | 1083517 |
nexus4_640.mov | 2015-07-06T08:21:35.000+0000 | 1720601 |
Were you able to reproduce the issue? Do you need additional information from me?
I would really appreciate a response as to whether this is a bug, and if there is a workaround, or a pending fix. I realise that a fix may not be done in time for my current project, but at the moment the project is on hold until I can find a definitive answer to the issue. Thanks!
Could someone give some indication of what the process / timescale for this issue will be? Thanks!
Is it possible to get the preview image width/height? If you read this page: http://androblip.huiges.nl/2010/07/25/camera-preview-size-picture-size-and-scaling/ _"It seems that on the G1 the standard previewsize you get is 320 x 480, while the picture size is something like 1536 x 2048. A quick thinker sees that the preview is 2:3, while the picture is ofcourse 3:4"_ old phone but with my moto g2 I still have a difference between the size of the preview image and the actual photo. And when you have a overlay image and want to adjust the image its difficult when the image size differs.
I can't compile the whole sdk but something like this:
in https://github.com/appcelerator/titanium_mobile/blob/17dc8754653daaff170ea0c18f74218168a5633e/android/modules/media/src/java/ti/modules/titanium/media/TiCameraActivity.java should probably work
[~oshevans] we can not replicate this issue, can you please send us more information in order to help us to reproduce the issue? Thanks
I can create a video and attach it later. E.g. Nexus 4 and Moto G2 produce different result
Attached the screen recordings. Make sure to watch them with Quicktime! VLC wasn't showing all frames! Moto G2: with overlay has a bigger image once the image was taken. Without the overlay the image size is the same as the preview size Nexus 4: with and without overlay the images look the same after taking the photo (although the preview image looks a bit stretched when you turn the camera (will upload a video of that in the evening)
any update here, do you need more information? Would like to see the preview-size added to the camera module
Marking this resolved. Will request to process the pull request.
[~michael] Does previewRect property should be applied on the final preview image ?
@ssombhatla you mean inside the pull request? I've added it so it can be used like the croppedrect. When you just look at the preview (live camera) it looks fine but once the image is taken it will use a different image size (device depending) and I you are using overlays or need to positioning the camera image it will be different. E.g. I present an overlay with a box the user has to be inside. When taking the image the result will be different and you can't adjust the overlay because you don't know what the preview size was. With this pull request you should be able to adjust the overlay (according to: http://androblip.huiges.nl/2010/07/25/camera-preview-size-picture-size-and-scaling/)
[~michael] Looks like this is an undocumented issue in Android Camera API and happens on specific devices. The anomaly in preview and final picture is because of horizontal field of view being greater in the final picture which is a result of preview and final picture having different aspect ratio. This results in extending both horizontal sides which are not visible in preview. Hence applying a cropped rect from (0,0) will not show the correct image as expected.