-4

I am a Blackberry Developer i create a blackberry camera application. But i take picture when i click is it possible to take picture without any user interaction.It's Necessary for my Application. please suggest me and send me the code and i am going through this process.

   public void doTakePicture(){
    try
    {

        System.out.println("Inside doTakePicture");
      Invoke.invokeApplication(Invoke.APP_TYPE_CAMERA,new CameraArguments());
      player = javax.microedition.media.Manager.createPlayer("capture://video");
      player.realize();
      player.start();
      videoControl = (VideoControl) player.getControl("VideoControl");

      if(videoControl!=null)
      {
          Field videoField = (Field) videoControl.initDisplayMode (VideoControl.USE_GUI_PRIMITIVE, "net.rim.device.api.ui.Field");
          videoControl.setDisplayFullScreen(true);
          videoControl.setVisible(true);
          System.out.println("videoControl=="+videoControl);
          if(videoField != null)
          {
              add(videoField);
          }

      } 


    }



catch(Exception ex)
 {
    System.out.println(ex);

 }
}

public boolean invokeAction(int action) { System.out.println("Action=="+action); boolean handled = super.invokeAction(action);

System.out.println("handled=="+handled);
System.out.println("Inside Invoke Camera");

if(handled==false)
{
    System.out.println("Inside First If Blog"); 
    if(action == ACTION_INVOKE)
    {   
        System.out.println("Inside Second If Blog");
        try
        {    
            System.out.println("If Blog of invoke Action");


            System.out.println("videoControl11=="+videoControl);
            byte[] snapshot = videoControl.getSnapshot(null);
            System.out.println("snapshot=="+snapshot);
        }
        catch(Exception e)
        {
            Dialog.alert(e.toString());
        }
    }
}           
return handled;                

}

using this code I want to try take picture automatic when camera is invoke but not taking picture automatic and i am getting a null value here byte[] snapshot = videoControl.getSnapshot(null); please help me where i am making mistake.
Thanks in Advance

  • 3
    Why do you want to do this? It sounds like a pretty sketchy requirement. – Michael Petrotta Apr 14 '12 at 05:23
  • 3
    With respect to your edit, "It's Necessary for my Application" is not sufficient, and reinforces my perception that you're doing this for unethical/immoral purposes. Please prove me wrong. – Michael Petrotta Apr 14 '12 at 05:45
  • 3
    Not sure it's the job of SO users to pass moral judgement on posters. There are plenty of legitimate uses for automatic photo taking. Time lapse photography is one that springs to mind. – donturner Apr 14 '12 at 21:16

1 Answers1

4

You will need to instantiate the camera from within your application, rather than invoking the default camera application. Once you've done this you can take a photo programmatically by calling VideoControl.getSnapshot. Example:

Player player = Manager.createPlayer("capture://video");
player.realize();
player.start();
VideoControl videoControl = (VideoControl) player.getControl("VideoControl");

//this will take a photo
byte[] snapshot = videoControl.getSnapshot("encoding=jpeg&width=640&height=480&quality=superfine");
donturner
  • 17,867
  • 8
  • 59
  • 81