This site is no longer active and is available for archival purposes only. Registration and login is disabled.

How to use the camera as the input?


How to use the camera as the input?

Postby Gar » Mar 19, 2008 @ 4:16am

I am the new one to study edgelib. I do not know how to use the camera as the input.

I am using Windows desktop workstation and one camera. I am going to create a small game using the camera. Any example code? Thank you.
good good study, day day up!
open heart every day ^!^
Gar
pm Member
 
Posts: 14
Joined: Mar 13, 2008 @ 2:03am


Postby Gar » Mar 19, 2008 @ 8:42pm

good good study, day day up!
open heart every day ^!^
Gar
pm Member
 
Posts: 14
Joined: Mar 13, 2008 @ 2:03am


Postby Kzinti » Mar 20, 2008 @ 1:55am

Kzinti
pm Member
 
Posts: 3238
Joined: Jan 13, 2002 @ 5:23am


Postby Gar » Mar 20, 2008 @ 2:44am

good good study, day day up!
open heart every day ^!^
Gar
pm Member
 
Posts: 14
Joined: Mar 13, 2008 @ 2:03am


Postby edge » Mar 20, 2008 @ 10:24am

EDGELIB: Cross-platform mobile development at your fingertips
http://www.edgelib.com
User avatar
edge
pm Member
 
Posts: 1180
Joined: Aug 22, 2005 @ 3:42pm
Location: The Netherlands


Postby Petre » Mar 20, 2008 @ 10:58am

Petre
pm Member
 
Posts: 34
Joined: Apr 1, 2006 @ 4:34pm


Postby Gar » May 8, 2008 @ 2:26am

I can capture camera images now, but the type is char.
How can I copy them to the surface? Is it using the following?
ERESULT CreateSurface(E2DSurface *surface, void *imgmem, unsigned long memsize, unsigned long usetype = EST_DEFAULT)

If so, how can I get the memory size?

Thanks.
good good study, day day up!
open heart every day ^!^
Gar
pm Member
 
Posts: 14
Joined: Mar 13, 2008 @ 2:03am


Postby edge » May 8, 2008 @ 9:00am

EDGELIB: Cross-platform mobile development at your fingertips
http://www.edgelib.com
User avatar
edge
pm Member
 
Posts: 1180
Joined: Aug 22, 2005 @ 3:42pm
Location: The Netherlands


Postby Gar » May 12, 2008 @ 5:18am

Thank you, Edge.

The data returned is a char *, and I do not have a pitch member. I have modified the code you gave to me.

The result is not what I expected. You can easily to see the difference between two images as below. The first image is the 320 X 240 (RGBA)which from the camera. The second one is from the program. They should be the same, but they are quite different.

According to the width, some parts are missing, and divided into 4 parts. Some of the height parts are still missing.
Image

Image

Image



unsigned char *memptr = background.Lock(&info);
if (memptr)
{
unsigned long yctr;
for (yctr = 0; yctr <= (unsigned long)cparam.ysize; yctr++){
ClassEMemory::Copy(&memptr[yctr*info.width],&dataPtr[yctr*cparam.xsize],cparam.xsize*32/8);

}
background.Unlock();
}
DrawBackground(display);


cparam.ysize - height of the image (in pixels).
cparam.xsize - length of the image (in pixels).

I also find that info.width=256. info.height=256.
Therefore,the width is smaller than 320, and the height is larger than 240.

How can I fix such problem?

Thank you so much.
good good study, day day up!
open heart every day ^!^
Gar
pm Member
 
Posts: 14
Joined: Mar 13, 2008 @ 2:03am


Postby edge » May 12, 2008 @ 5:54pm

EDGELIB: Cross-platform mobile development at your fingertips
http://www.edgelib.com
User avatar
edge
pm Member
 
Posts: 1180
Joined: Aug 22, 2005 @ 3:42pm
Location: The Netherlands


Postby Gar » May 13, 2008 @ 12:37am

Hi Edge,

Thank you so much. I used the background image which is 256 X 256.
if (display->CreateSurface(&background, "background.jpg") != E_OK)
return (E_ERROR);

I changed it to
if (display->CreateSurface(&background, 320,240) != E_OK)
return(E_ERROR);

It works, is it correct? Do I need to modify some code in DrawBackground(ClassEDisplay *display)?
Because I am not quite understand this function.

void ClassMain::DrawBackground(ClassEDisplay *display)
{
#if defined(EGL_USEGL)
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
display->Perspective2D(256, 256, false);
//display->Perspective2D(320, 240, false);
display->BltFast(0, 0, &background, NULL);
#else
E2DBLTFX bltfx;
bltfx.flags = 0;
bltfx.property = 0;
bltfx.xscale = 65536 * display->buffer.GetWidth() / background.GetWidth();
bltfx.yscale = 65536 * display->buffer.GetHeight() / background.GetHeight();
bltfx.rotation = 0;
bltfx.flipflags = 0;
display->buffer.BltFx(display->buffer.GetWidth() / 2, display->buffer.GetHeight() / 2, &background, NULL, &bltfx);
#endif
}


Thank you so much!
good good study, day day up!
open heart every day ^!^
Gar
pm Member
 
Posts: 14
Joined: Mar 13, 2008 @ 2:03am


Postby edge » May 13, 2008 @ 7:40pm

EDGELIB: Cross-platform mobile development at your fingertips
http://www.edgelib.com
User avatar
edge
pm Member
 
Posts: 1180
Joined: Aug 22, 2005 @ 3:42pm
Location: The Netherlands


Postby Gar » May 13, 2008 @ 11:36pm

good good study, day day up!
open heart every day ^!^
Gar
pm Member
 
Posts: 14
Joined: Mar 13, 2008 @ 2:03am


Return to EDGELIB


Sort


Forum Description

Powerful and affordable C++ middleware solution covering true multi-platform 2D, 3D and network features for Apple iPhone, Windows Mobile, Symbian S60, UIQ, Linux and Windows desktop.

Moderator:

edge

Forum permissions

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

cron