Using a webcam connected to mini2440

Chinmay Duvedi
Hello everyone

I am trying to get my mini2440 to capture an image using a logitesh usb
webcam. When i plug in the device it /dev/video0 gets installed.
Here is the part of the code I used to open the device

int cam = 0;
cam = open("dev/video0", 0);
if(cam < 0)
{
    printf("Error opening camera");
}

after this how should i capture an image?
will using the read() function work?
if yes how many bytes do i need to read?

is there any shell command to do the same?.. spacacat() did not work... 
it said 
"/bin/sh command not found"

please help
Thanks in advance
Chinmay

azzido
Hi Duvedi,

Why don't you try to get a capture using v4l ? it's easier and you have
more features.

look here:
http://read.pudn.com/downloads48/sourcecode/unix_linux/165274/capture.c_...

Regards,
    azzido

Chinmay Duvedi
Hi azzido,
Thanks for your reply
I will try to do that and  get back to you

Just one thing.. I have not gone thru your source code yet.. but will it
allow me to access my webcam to get pictures whenever i want... or will it
keep buffering video?

I am a newbie.. please bear with me

Cheers
Chinmay

azzido
Hi Duvedi,

You can access your camera and get captures. A video is represent as a
continue sequence of frames (captures).

Try what I gave you and run it first using ./capture -h to see the help.

regards,
azzido

Chinmay Duvedi
Hi azzido,
Thanks a lot 
I will let u know as soon as have something

Cheers
Chinmay

Chinmay Duvedi
Hi azzido,
I tries to run the code you gave me
But there seems to be a problem :(

#include <sys stat.h="">  
#include <sys types.h="">  
#include <sys time.h="">  
#include <sys mman.h="">  
#include <sys ioctl.h="">  
  
#include <asm types.h="">  


i am getting an error while compiling these files...
It cannot find the file to include

Please tell me where i am going wrong..

Chinmay

azzido
Hi Duvedi,

The header files are not right included, they should be included without
="" . But from here you can download the original version of code:

http://v4l2spec.bytesex.org/v4l2spec/capture.c

Regards
azzido

Chinmay Duvedi
Hi azzido,
Thanks a lot
i will take a look and try again

Chinmay