farmes of video stream

Forum for J2ME mobile games related topics including programming doubts, books and other resources for J2ME game development

Mosquito program

Postby sou » Mon Apr 28, 2008 7:27 am

Hi All...
I want to Know the idea which is done in code in mosquito program ...I mean the idea to make the video stream of camera behind and everything including the mosquito in front???
actually I need any idea to make video stream of camera behind and want any object in front it..!!!
thanks
sou
 
Posts: 8
Joined: Thu Apr 10, 2008 3:07 pm

Re: Mosquito program

Postby DevelopmentTeam » Mon Apr 28, 2008 10:49 am

sou wrote:Hi All...
I want to Know the idea which is done in code in mosquito program ...I mean the idea to make the video stream of camera behind and everything including the mosquito in front???
actually I need any idea to make video stream of camera behind and want any object in front it..!!!
thanks


From your post, I can understand that mosquito program is some app that shows the camera output in the screen and displays a mosquito in front of the screen which seems like the mosquito is really flying in front of the camera.
User avatar
DevelopmentTeam
Site Admin
 
Posts: 661
Joined: Tue Aug 15, 2006 8:39 am
Location: India

Re: Mosquito program

Postby sou » Mon Apr 28, 2008 4:12 pm

yes I meant that... I want to know how that done by java code...or if any one can give me the source code of this application??!!
sou
 
Posts: 8
Joined: Thu Apr 10, 2008 3:07 pm

farmes of video stream

Postby sou » Thu May 01, 2008 3:03 am

Hi All
Can I access the frames of camera video stream one by one and draw over them ???....i know we can do that by C programing language but i want to Know if Ican do that by j2me???
I here that there is class called Background ....can any one tell me about this class???
:roll:
thanks
Last edited by sou on Thu May 01, 2008 8:26 pm, edited 1 time in total.
sou
 
Posts: 8
Joined: Thu Apr 10, 2008 3:07 pm

Re: farmes of video stream

Postby DevelopmentTeam » Thu May 01, 2008 5:07 am

Code: Select all
p = Manager.createPlayer("capture://video");
p.realize();
rc = (RecordControl) p.getControl("RecordControl");
videoControl = (VideoControl) (p.getControl("VideoControl"));
videoControl.initDisplayMode(VideoControl.USE_DIRECT_VIDEO, this);
videoControl.setVisible(true);

int x = (getWidth() - videoControl.getDisplayWidth()) >> 1;
int y = (getHeight() - videoControl.getDisplayHeight()) >> 1;
videoControl.setDisplayLocation(x, y);

rc.setRecordStream(baos);
p.prefetch();

rc.startRecord();
p.start();


You can use this code to show the video on the canvas and then you can draw over it using the paint function
User avatar
DevelopmentTeam
Site Admin
 
Posts: 661
Joined: Tue Aug 15, 2006 8:39 am
Location: India

Re: farmes of video stream

Postby sou » Thu May 01, 2008 8:17 am

I wrote this code in Canvas constructor and create the object from canvas class in snapper class
it throw NullPointerException...
I dont know what is the problem .....can you help me ??

sorry for bother ...thanks alot for your help :D



=====================================================================
public class CameraCanvas
extends Canvas {
private SnapperMIDlet mSnapperMIDlet;
private Player p;
public VideoControl videoControl ;
public RecordControl rc;
private OutputStream baos;

public CameraCanvas()
{
try {

p = Manager.createPlayer("capture://video");
p.realize();
rc = (RecordControl) p.getControl("RecordControl");
videoControl = (VideoControl) (p.getControl("VideoControl"));
videoControl.initDisplayMode(VideoControl.USE_DIRECT_VIDEO, this);
videoControl.setVisible(true);

int x = (getWidth() - videoControl.getDisplayWidth()) >> 1;
int y = (getHeight() - videoControl.getDisplayHeight()) >> 1;
videoControl.setDisplayLocation(x, y);

rc.setRecordStream(baos);
p.prefetch();

rc.startRecord();
p.start();

} catch (IOException ex) {
ex.printStackTrace();
} catch (MediaException ex) {
ex.printStackTrace();
}
sou
 
Posts: 8
Joined: Thu Apr 10, 2008 3:07 pm

Re: farmes of video stream

Postby DevelopmentTeam » Sat May 03, 2008 2:06 pm

You have not initialized the variable 'baos'
User avatar
DevelopmentTeam
Site Admin
 
Posts: 661
Joined: Tue Aug 15, 2006 8:39 am
Location: India

Re: farmes of video stream

Postby sou » Sun May 04, 2008 9:21 am

sorry....I dont know how to initialize the outputstream variable in my case????
sou
 
Posts: 8
Joined: Thu Apr 10, 2008 3:07 pm

Re: farmes of video stream

Postby DevelopmentTeam » Tue May 06, 2008 6:36 am

Code: Select all
public class CameraCanvas
extends Canvas {
private SnapperMIDlet mSnapperMIDlet;
private Player p;
public VideoControl videoControl ;
public RecordControl rc;
ByteArrayOutputStream baos = new ByteArrayOutputStream();

public CameraCanvas()
{
try {

p = Manager.createPlayer("capture://video");
p.realize();
rc = (RecordControl) p.getControl("RecordControl");
videoControl = (VideoControl) (p.getControl("VideoControl"));
videoControl.initDisplayMode(VideoControl.USE_DIRECT_VIDEO, this);
videoControl.setVisible(true);

int x = (getWidth() - videoControl.getDisplayWidth()) >> 1;
int y = (getHeight() - videoControl.getDisplayHeight()) >> 1;
videoControl.setDisplayLocation(x, y);

rc.setRecordStream(baos);
p.prefetch();

rc.startRecord();
p.start();

} catch (IOException ex) {
ex.printStackTrace();
} catch (MediaException ex) {
ex.printStackTrace();
}


You can use this code
User avatar
DevelopmentTeam
Site Admin
 
Posts: 661
Joined: Tue Aug 15, 2006 8:39 am
Location: India

Re: farmes of video stream

Postby sou » Sat May 10, 2008 3:00 pm

I tried it but it still not working..the video strem still over the frame..the difference is dimensions of canvas has minimized
?But Really ...thank you for your help :)
Last edited by sou on Sun May 11, 2008 9:45 am, edited 1 time in total.
sou
 
Posts: 8
Joined: Thu Apr 10, 2008 3:07 pm

Re: farmes of video stream

Postby DevelopmentTeam » Sun May 11, 2008 5:26 am

you r welcome. keep posting your doubts... :)
User avatar
DevelopmentTeam
Site Admin
 
Posts: 661
Joined: Tue Aug 15, 2006 8:39 am
Location: India


Return to J2ME Games

Who is online

Users browsing this forum: No registered users and 3 guests

cron