Page 1 of 1

How to use the camera as the input?

PostPosted: Mar 19, 2008 @ 4:16am
by Gar
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.

PostPosted: Mar 19, 2008 @ 8:42pm
by Gar

PostPosted: Mar 20, 2008 @ 1:55am
by Kzinti

PostPosted: Mar 20, 2008 @ 2:44am
by Gar

PostPosted: Mar 20, 2008 @ 10:24am
by edge

PostPosted: Mar 20, 2008 @ 10:58am
by Petre

PostPosted: May 8, 2008 @ 2:26am
by Gar
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.

PostPosted: May 8, 2008 @ 9:00am
by edge

PostPosted: May 12, 2008 @ 5:18am
by Gar
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.

PostPosted: May 12, 2008 @ 5:54pm
by edge

PostPosted: May 13, 2008 @ 12:37am
by Gar
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!

PostPosted: May 13, 2008 @ 7:40pm
by edge

PostPosted: May 13, 2008 @ 11:36pm
by Gar