0

I'm doing a bit of feasability R&D on a project I've been thinking about, the problem is that I'm unfamiliar with the limitations of the Camera API or the OS itself.

I want to write a cordova app which when opened (and authorized), will take a picture every nth second and upload it to a FTP site. Consider it something like a CCTV function, where my site will continuously render the latest image to the user.

Some pseudo code:

while (true) {
       var img = api.takePicture(args);
       uploadImage(img);
       thread.sleep(1000);
}

So my question is, can I access the camera and instruct it to take a picture without user intervention (again, after camera access is authorized)? Examples or direction for any API call to accomplish it would be really appreciated. I saw this article, and the answer looks promising, but the OP has android and I'd to know if it behaves the same on iOS.

On a side note, how do I test my cordova application on my iPhone without buying an app store license? I only want to run it on my own device.

Community
  • 1
  • 1
Daniel Minnaar
  • 5,865
  • 5
  • 31
  • 52

1 Answers1

0

Solved using CameraPictureBackground plugin:

function success(imgurl) {   console.log("Imgurl = " + imgurl);   //here I added my function to upload the saved pictures   //on my internet server using file-tranfer plugin }

function onFail(message) {
    alert('Failed because: ' + message); }

function CaptureBCK() {
    var options = {
    name: "Image", //image suffix
    dirName: "CameraPictureBackground", //foldername
    orientation: "portrait", //or landscape
    type: "back" //or front
    };
window.plugins.CameraPictureBackground.takePicture(success, onFail, options); }


<button onclick="CaptureBCK();">Capture Photo</button> <br>

You will find your pictures under CameraPictureBackground directory in your device acrhive. I used also file-transfer plugin in order to directly upload the pictures on my server over the internet.

Chetann
  • 297
  • 5
  • 7