Camera in nokia 5300

Go down

Camera in nokia 5300

Post  sukesh on Tue Oct 30, 2007 6:38 am

Hi.
I hv a problem. In nokia 5300, camera is opening but picture is not being captured.

Any idea??

Sukesh

sukesh

Posts : 8
Join date : 2007-09-10

View user profile

Back to top Go down

Camera in nokia 5300

Post  Adeesh on Tue Oct 30, 2007 6:45 am

HI,
There might be the problem with the encoding which you are specifying while capturing the image.. One thing you can try is to call the method as getSnapShot(null);

Try the following code to capture the image:

import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
import javax.microedition.media.*;
import javax.microedition.media.control.*;
import java.io.*;
import javax.microedition.lcdui.game.*;


/**
* A simple example of the MMAPI (JSR 135) support for taking snapshots
*
* Take a snapshot by clicking the "Click!" button.
*
*/
public class Camera extends MIDlet implements CommandListener, PlayerListener{


private Display myDisplay;
private Form myForm;
private ImageCanvas myImageCanvas;

private Player myPlayer;
private VideoControl vc;
private Image myImage;
private byte[] byteImage;

public Camera() {
myDisplay = Display.getDisplay(this);
myForm=new Form ("Camera Test");
myForm.addCommand(new Command("Exit", Command.EXIT,0));
myForm.addCommand(new Command("Click!", Command.SCREEN,1));
myForm.addCommand(new Command("Show Snapshot", Command.SCREEN,1));
myForm.setCommandListener(this);

myImageCanvas= new ImageCanvas ("The Snapshot");
myImageCanvas.addCommand(new Command("Exit", Command.EXIT,0));
myImageCanvas.addCommand(new Command("Back", Command.SCREEN,1));
myImageCanvas.setCommandListener(this);

initPlayer();
}


protected void startApp() throws MIDletStateChangeException {
myDisplay.setCurrent(myForm);
}

protected void pauseApp() {}

protected void destroyApp(boolean unconditional) {
try {
myPlayer.stop();
myPlayer.close();
}
catch( Exception e ) {
log("Exception: " + e.toString());
}
}

/**
* Inits and starts the Player for Video capuring (even though it's)
* actually only still images that get captured, not live video.
*/
private void initPlayer(){
try{
myPlayer = Manager.createPlayer("capture://video");
myPlayer.addPlayerListener(this);
myPlayer.realize();

// Grab the video control and set it to the current display.
vc = (VideoControl)myPlayer.getControl("VideoControl");
if (vc != null) {
myForm.append((Item)vc.initDisplayMode(vc.USE_GUI_PRIMITIVE, null));
// sets the size of the viewfinder. This has no impact on the snapshot's size!
vc.setDisplaySize(120,160);
}
myPlayer.start();

}catch(Exception e){
log("Exception: " + e.toString());
}

}

public void commandAction(Command c, Displayable s){
if(c.getCommandType()==Command.EXIT){
notifyDestroyed();
}else if (c.getLabel().equals("Click!")){
takeSnapshot();
}else if (c.getLabel().equals("Show Snapshot")){
myDisplay.setCurrent(myImageCanvas);
}else if (c.getLabel().equals("Back")){
myDisplay.setCurrent(myForm);
}
}

/**
* Take the snapshot and show it on a Canvas.
* Note that it's not possible to pass any
* parameters other than "null" to getSnapshot()
**/
private void takeSnapshot(){
try {
byteImage = vc.getSnapshot(null);
myImage = Image.createImage(byteImage, 0, byteImage.length);

myDisplay.setCurrent(myImageCanvas);

}catch( Exception e ) {
log("Exception: " + e.toString());
}
}

/**
* PlayerListener Interface method, logs all player event.
*/
public void playerUpdate(Player player, String event, Object eventData){
log(" ** playerUpdate: " + event + " **");

}

public void log(String msg){
System.out.println(msg);
}


/**
* Very simple Canvas class that just shows the snapshot.
*/
public class ImageCanvas extends Canvas{

public ImageCanvas(String title){
super();
setTitle(title);
}

public void paint(Graphics g){
g.setColor(0xFFFFFF);
g.fillRect(0,0, getWidth(), getHeight());
g.drawImage(myImage, 0, 0, Graphics.TOP | Graphics.LEFT) ;
}
}


}

Adeesh

Posts : 10
Join date : 2007-09-11

View user profile

Back to top Go down

Re: Camera in nokia 5300

Post  sukesh on Tue Oct 30, 2007 6:56 am

Thanks.
But I am doing the same...but not able to capture the picture.


Sukesh

sukesh

Posts : 8
Join date : 2007-09-10

View user profile

Back to top Go down

Re: Camera in nokia 5300

Post  guantana on Tue Oct 30, 2007 10:31 pm

Did u try to capture the exception or you are getting blank byte[].
avatar
guantana

Posts : 22
Join date : 2007-09-09
Location : New Delhi, India

View user profile http://guantana.blogspot.com

Back to top Go down

Re: Camera in nokia 5300

Post  sukesh on Tue Oct 30, 2007 11:29 pm

Hi Adeesh,

I have tried the method you sent, but it is not working. What kind of encoding you were talking about...I didn't get it actually?

By the way, Have you any idea of opening camera and capturing the picture on motorola and samsung handsets??


Regards
Sukesh

sukesh

Posts : 8
Join date : 2007-09-10

View user profile

Back to top Go down

Re: Camera in nokia 5300

Post  Adeesh on Tue Oct 30, 2007 11:56 pm

Hi,
Can you post the code which you are trying to capture the image? Is there any exception thrown while capturing the image?

Tell me the encodings returned by the following method.
String encodings = System.getProperty("video.snapshot.encodings");


Capturing of image on Motorola and Samsung is same as of capturing image on Nokia and SE phones.

Thanks
Adeesh Jain

Adeesh

Posts : 10
Join date : 2007-09-11

View user profile

Back to top Go down

Re: Camera in nokia 5300

Post  sukesh on Wed Oct 31, 2007 12:23 am

For motorola and samsung i have heard that some problem of permissions appears....

On the emulator, I am getting.... "encoding=jpeg"

Code is:
takesnapshot method:
try {
byte[] barImage = videoControl.getSnapshot(null);
imageSnapShot = Image.createImage(barImage, 0, barImage.length);

//showCameraPicture(barImage,".png");
stopCamera();
} catch (MediaException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}

In canvas just painting the image....


One more thing i noticed that network access is very slow in 5300 as compared to 60 series phones although other processings are faster. Everytime it tries to connect to server....it responds very late...

sukesh

Posts : 8
Join date : 2007-09-10

View user profile

Back to top Go down

Re: Camera in nokia 5300

Post  guantana on Wed Oct 31, 2007 12:52 am

Hi sukesh,

Regarding slow network connection: There could be many reason for this.
1.) Network latency may be higher because of Your carrier. Try with other carriers.
2.) Check the time taken by server.

If it is genuinely slow then you can not do anything.

Guantana
avatar
guantana

Posts : 22
Join date : 2007-09-09
Location : New Delhi, India

View user profile http://guantana.blogspot.com

Back to top Go down

Re: Camera in nokia 5300

Post  sukesh on Wed Oct 31, 2007 1:02 am

Hi
Regarding slow network...the same carrier is used by other phones...there it is responding fine.

I tried on samsung but as I click to open the camera...blank screen is returned. Camera is not opening at all. Pic capturing is further issue.

And no solution for nokia 5300 pic capturing??


Regards
Sukesh

sukesh

Posts : 8
Join date : 2007-09-10

View user profile

Back to top Go down

Re: Camera in nokia 5300

Post  anuj_geek on Wed Jul 02, 2008 5:44 am

Hi,

Nokia 5300 is a Series 40 3rd Edition device and all device from these series doesn't have support for getSnapShot() Method. so instead of creating player by this way :-

myPlayer = Manager.createPlayer("capture://video");

you can try,

myPlayer = Manager.createPlayer("capture://image");

and do let me know weather this works for you or not.

Regards,
Anuj

anuj_geek

Posts : 1
Join date : 2008-07-02

View user profile

Back to top Go down

Re: Camera in nokia 5300

Post  Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum