How to change Cordova camera plugin options - android

I am using cordova camera plugin. It works fine. But i have two problems. One of them; after i capture photo 2 buttons appear. Their names are "Save" and "Discard". I want to rename them with "confirm" and "Cancel". How can i do this? an other question; after Saving photo, my photo is turning. How can i block this?

Save/Discard - you can't do this in the Cordova Camera API presented to you.
You'd need to write your own plugin which uses a SurfaceView (more
detail here).
This is a known Android issue - it ignores the correctOrientation parameter - I believe however that it uploads the photo in the correct orientation. It just is not shown correctly.

after i add correctOrientation in my code, it shown phooto correctly.
navigator.camera.getPicture(photoCaptured,photoCapturedFail,
{
quality: 50,
destinationType: Camera.DestinationType.DATA_URL,
correctOrientation: true
});

Related

Cordova-Plugin-Camera-Preview - is there a way to listen for a tapPhoto event?

I want to run some code on a photo capture, but there isn't an obvious way to to this. I set tapPhoto to true so that the plugin captures pictures when the user taps the screen, and it seems to be working since it triggers the camera sound. My issue is that there does not seem to be a way to run code once the capture happens, so that I can close the camera, retrieve the image data, etc. This is my code:
angular.module('myApp').factory('photoService', function(...){
var cameraOptions = {
camera: CameraPreview.CAMERA_DIRECTION.BACK,
tapPhoto: true
}
CameraPreview.startCamera(cameraOptions);
//onCapture isn't a real part of the plugin, but this is just the code I want to run each
//time the user taps the phone screen
CameraPreview.onCapture = function(imgData){
showPhoto(imgData);
CameraPreview.stopCamera();
}
});
I saw online that takePicture() is basically what I want, but it looks like we have to call it once for it to work subsequent times (https://github.com/cordova-plugin-camera-preview/cordova-plugin-camera-preview/issues/364) and I don't want to do that because my app essentially opens the camera, allows the user to take a single photo, and then closes the camera, so having to take double the number of pictures than necessary is not ideal. Is there another way to achieve the functionality I want?

ionic 2: camera and photo gallery together

I am using Ionic 2 for an app and I have a question regarding the ionic-native plugin - Camera. There any way to use the Camera only or photo gallery only inside of an Ionic 2 Application. using the option sourcetype CAMERA or PHOTOALBUM.
Is there a way where I can use both at the same time. Like in Whatsapp, when you want to send an image tou can take a picture at the same time or use a picture from photo gallery.
Any ideas?
I think the best option is to show an action sheet (or something like that) in which the user can select an action (Camera or Album). Then create separate methods for both functionalities and call the desired method (this isn't a full implementation):
function getPictureFromCamera() {
Camera.getPicture({
...
sourceType: 'CAMERA'
}).then(...);
...
}
function getPictureFromAlbum() {
Camera.getPicture({
...
sourceType: 'PHOTOLIBRARY'
}).then(...);
...
}

Taking Screenshots Using Qt C++ on Android

thanks for checking my question out!
I'm currently working on a project using Qt C++, which is designed to be multi-platform. I'm a bit of a newcoming to it, so I've been asked to set up the ability to take screenshots from within the menu structure, and I'm having issues with the Android version of the companion app.
As a quick overview, it's a bit of software that send the content of a host PC's screen to our app, and I've been able to take screenshots on the Windows version just fine, using QScreen and QPixmap, like so:
overlaywindow.cpp
{
QPixmap screenSnapData = screenGrab->currentBackground();
}
screenGrabber.cpp
{
QScreen *screen = QGuiApplication::primaryScreen();
return screen->grabWindow( QApplication::desktop()->winId() );
}
Unfortunately, Android seems to reject QScreen, and with most suggestions from past Google searches suggesting the now-deprecated QPixmap::grab(), I've gotten a little stuck.
What luck I have had is within the code for the menu itself, and QWidget, but that isn't without issue, of course!
QFile doubleCheckFile("/storage/emulated/0/Pictures/Testing/checking.png");
doubleCheckFile.open(QIODevice::ReadWrite);
QPixmap checkingPixmap = QWidget::grab();
checkingPixmap.save(&doubleCheckFile);
doubleCheckFile.close();
This code does take a screenshot, but only of the button strip currently implemented, and not for the whole screen. I've also taken a 'screenshot' of just a white box with the screen's dimensions by using:
QDesktopWidget dw;
QWidget *screen=dw.screen();
QPixmap checkingPixmap = screen->grab();
Would anyone know of whether there was an alternative to using QScreen to take a screenshot in Android, or whether there's a specific way to get it working as compared to Windows? Or would QWidget be the right track? Any help's greatly appreciated!
as i can read in Qt doc : In your screenGrabber.cpp :
QScreen *screen = QGuiApplication::primaryScreen();
return screen->grabWindow( QApplication::desktop()->winId() );
replace with :
QScreen *screen = QGuiApplication::primaryScreen();
return screen->grabWindow( 0 ); // as 0 is the id of main screen
If you want to take a screenshot of your own widget, you can use the method QWidget::render (Qt Doc):
QPixmap pixmap(widget->size());
widget->render(&pixmap);
If you want to take a screenshot of another app/widget than your app, you should use the Android API...

Unity3D Webcam Autofocus Callback?

I want to take a picture from camera using Unity. Taking picture itself is not a big deal but I want more accurate one using autofocus callback method like in Android (onAutoFocus(boolean success, Camera camera)) So I can take a picture if callback returns success true. Is there any way to do it in Unity or I need some plugin for that? If there is one can somebody reference to it? Thanks a lot!
There is a plugin called Camera Capture Kit available on the assetstore that seems to be able to do what you want. We used the code to make theese features available on both Android as well as iPhone.
https://www.assetstore.unity3d.com/en/#!/content/56673
Camera Capture Kit comes with a plug-n-play camera app which enables Auto-focus - you can set the autofocus mode by calling .
CameraCapture.UnitySetFocusMode( webCamTextureReferance, FocusModes.Autofocus );
That will represent AVCaptureFocusModeAutoFocus and you should be able to trigger a callback for the focus event yourself by adding a piece of code like this in the function initCapture in the file Assets/Tastybits/Native/iOS/CameraCapture.mm :
[camDevice addObserver:self forKeyPath:#"adjustingFocus" options:flags context:nil];
Now, Camera Capture Kit doesn't give you a callback when focus is being done on iOS so you will have to add it yourself and calling back to unity yourself using SendMessage.
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
if( [keyPath isEqualToString:#"adjustingFocus"] ){
BOOL adjustingFocus = [ [change objectForKey:NSKeyValueChangeNewKey] isEqualToNumber:[NSNumber numberWithInt:1] ];
NSLog(#"Is adjusting focus? %#", adjustingFocus ? #"YES" : #"NO" );
if(adjustingFocus)
UnitySendMessage( "FocusController", "FocusChanged", "1" );
else
UnitySendMessage( "FocusController", "FocusChanged", "0" );
}}

image won't show in tableView

I'm creating a tableView in appcelerator (Android) and I want to add an image to it. This is just a test because I also had some problems with it in my project and I wanted to try it out first somewhere else so I wouldn't ruin my whole project.
I first added the standard png's to see if he would show those, and he did. But when I add a png that I've created, he refuses to show it in the tableView. Does someone know why he refuses to show the image? (I created that png in photoshop by changing one of the standard png's and adding my image to it.)
var win = Titanium.UI.createWindow({
title:'tableViewRow',
backgroundColor:'#fff'
});
var regData = [
{leftImage:'KS_nav_ui.png', title:'gft', left:20, color:'black'},
{rightImage:'KS_nav_views.png', title:'grofvuil', left:20, color:'black'},
{leftImage:'glas.png', title:'glas', left:20, color:'black'}
];
var tbl = Titanium.UI.createTableView({
data:regData
});
win.add(tbl);
win.open();
Here's an image of the result I get in my android emulator (android api: Google APIs Android 2.2 and screen:HVGA)
If you are using AppC 1.8, you may just need a forward slash in your path '/'. (or backward if Windows)
I've solved it. What I did is I ran the application in an android amulator. I closed the app and went back to the homescreen (where you can save some apps). I pressed on menu and went to the settings. Than I went to applications. I opened 'manage applications' and remove the application. I closed the emulator and ran it again and the images were shown.
I don't know why you have to do it, but it worked for me. I hope I can save someone the frustration by posting the answer (I know I had them :D)

Categories

Resources