Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Novice
2,420 Views

i want to capture a picture from a 2.0 usb webcam connected to usb host of galileo gen 2 and display it on my laptop or some lcd. laptop will be better. kindly help me asap. i would be very thankful.

Jump to solution

i have succeeded in connecting the board to laptop. have ran the blink code successfully as well. have connected board through a usb to serial converter to my laptop. the camera is a 2.0 usb webcam. the camera is connected through usb host of galileo gen 2. the camera connection is confirmed through serial moniter of arduino ide. kindly guide me how i will capture pictures with that cam and display it on my laptop on vlc or something else. i am using windows 7.


Accepted Solutions
Highlighted
Employee
6 Views

Hello haky,

Are you using the Galileo's uclibc image or the eglibc image? For this project I'd suggest you to use the eglibc image of Galileo since you will need a lot of packages that are not compatible with the uclibc image. You can get the eglibc image in https://software.intel.com/en-us/iot/hardware/galileo/downloads Intel® Galileo Downloads, there you will find a guide to learn how to set your SD card to be used with the eglibc image.

You could check https://github.com/drejkim/edi-cam/ edi-cam it is a project based on Edison but if you have a camera compatible, it should also work on the eglibc image of Galileo. You may also want to check chapter 7 of http://wearcam.org/ece516/ArduinoLinux_by_ManoelCarlosRamon_9781430268390.pdf Intel(R) Galileo and Intel(R) Galileo Gen 2 API Features... that book dedicates that whole chapter to projects like yours.

Peter.

View solution in original post

8 Replies
Highlighted
Employee
7 Views

Hello haky,

Are you using the Galileo's uclibc image or the eglibc image? For this project I'd suggest you to use the eglibc image of Galileo since you will need a lot of packages that are not compatible with the uclibc image. You can get the eglibc image in https://software.intel.com/en-us/iot/hardware/galileo/downloads Intel® Galileo Downloads, there you will find a guide to learn how to set your SD card to be used with the eglibc image.

You could check https://github.com/drejkim/edi-cam/ edi-cam it is a project based on Edison but if you have a camera compatible, it should also work on the eglibc image of Galileo. You may also want to check chapter 7 of http://wearcam.org/ece516/ArduinoLinux_by_ManoelCarlosRamon_9781430268390.pdf Intel(R) Galileo and Intel(R) Galileo Gen 2 API Features... that book dedicates that whole chapter to projects like yours.

Peter.

View solution in original post

Highlighted
Novice
6 Views

I am using this code from the same chapter you mentioned but am having some errors running it on Arduino ide for windows can you check how can these errors be solved.

# include

 

# include

 

# include

 

# include

# include /* getopt_long() */

# include /* low-level i/o */

 

# include

 

# include

 

# include

 

# include

 

# include

 

# include

 

# include

# include

# define CLEAR(x) memset(&(x), 0, sizeof(x))

enum io_method {

 

IO_METHOD_READ,

 

IO_METHOD_MMAP,

 

IO_METHOD_USERPTR,

 

};

struct buffer {

 

void *start;

 

size_t length;

 

};

static char *dev_name;

 

static enum io_method io = IO_METHOD_MMAP;

 

static int fd = -1;

 

struct buffer *buffers;

 

static unsigned int n_buffers;

 

static int out_buf;

 

static int force_format;

 

static int frame_count = 70;

static void errno_exit(const char *s)

 

{

 

fprintf(stderr, "%s error %d, %s\n", s, errno, strerror(errno));

 

exit(EXIT_FAILURE);

 

}

static int xioctl(int fh, int request, void *arg)

 

{

 

int r;

do {

 

r = ioctl(fh, request, arg);

 

} while (-1 == r && EINTR == errno);

return r;

 

}

static void process_image(const void *p, int size)

 

{

 

if (out_buf)

 

fwrite(p, size, 1, stdout);

fflush(stderr);

 

fprintf(stderr, ".");

 

fflush(stdout);

 

}

static int read_frame(void)

 

{

 

struct v4l2_buffer buf;

 

unsigned int i;

switch (io) {

 

case IO_METHOD_READ:

 

if (-1 == read(fd, buffers[0].start, buffers[0].length)) {

 

switch (errno) {

 

case EAGAIN:

 

return 0;

case EIO:

 

/* Could ignore EIO, see spec. */

/* fall through */

default:

 

errno_exit("read");

 

}

 

}

process_image(buffers[0].start, buffers[0].length);

 

break;

case IO_METHOD_MMAP:

 

CLEAR(buf);

buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;

 

buf.memory = V4L2_MEMORY_MMAP;

if (-1 == xioctl(fd, VIDIOC_DQBUF, &buf)) {

 

switch (errno) {

 

case EAGAIN:

 

return 0;

case EIO:

 

/* Could ignore EIO, see spec. */

/* fall through */

default:

 

errno_exit("VIDIOC_DQBUF");

 

}

 

}

assert(buf.index < n_buffers);

process_image(buffers[buf.index].start, buf.bytesused);

if (-1 == xioctl(fd, VIDIOC_QBUF, &buf))

 

errno_exit("VIDIOC_QBUF");

 

break;

case IO_METHOD_USERPTR:

 

CLEAR(buf);

buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;

 

buf.memory = V4L2_MEMORY_USERPTR;

if (-1 == xioctl(fd, VIDIOC_DQBUF, &buf)) {

 

switch (errno) {

 

case EAGAIN:

 

return 0;

case EIO:

 

/* Could ignore EIO, see spec. */

/* fall through */

default:

 

errno_exit("VIDIOC_DQBUF");

 

}

 

}

for (i = 0; i < n_buffers; ++i)

 

if (buf.m.userptr == (unsigned long)buffers[i].start

 

&& buf.length == buffers[i].length)

 

break;

assert(i < n_buffers);

process_image((void *)buf.m.userptr, buf.bytesused);

if (-1 == xioctl(fd, VIDIOC_QBUF, &buf))

 

errno_exit("VIDIOC_QBUF");

 

break;

 

}

return 1;

 

}

static void mainloop(void)

 

{

 

unsigned int count;

count = frame_count;

while (count-- > 0) {

 

for (;;) {

 

fd_set fds;

 

struct timeval tv;

 

int r;

FD_ZERO(&fds);

 

FD_SET(fd, &fds);

/* Timeout. */

 

tv.tv_sec = 2;

 

tv.tv_usec = 0;

r = select(fd + 1, &fds, NULL, NULL, &tv);

if (-1 == r) {

 

if (EINTR == errno)

 

continue;

 

errno_exi...
0 Kudos
Highlighted
Employee
6 Views

That code can't be compiled on the Arduino IDE because it is supposed to be compile with a regular C compiler such as GCC. If you wat to run this code you will have to use the Galileo's full yocto image that you can find in https://software.intel.com/en-us/iot/hardware/galileo/downloads Intel® Galileo Downloads and access the board's Linux console as explained in http://www.intel.com/content/www/us/en/support/boards-and-kits/intel-galileo-boards/000006142.html How to Connect the Intel Galileo Board to Linux using the correct serial cable as stated in http://www.intel.com/content/www/us/en/support/boards-and-kits/intel-galileo-boards/000006343.html Console Serial Cables. Once you've done that you should be able to compile this code directly on Linux.

If you don't know how to do it, here's a brief explanation:

  1. Copy the code and in Linux enter the command vi test.c
  2. Hit I on your keyboard so you can edit the file and paste the code
  3. Exit vi by hitting the escape button and type the following :wq and hit enter
  4. Compile the code and create an executable file with the command gcc test.c -o output
  5. Run the code with the command ./output

I hope this helps.

Peter.

0 Kudos
Highlighted
Novice
6 Views

Which linux should i use for this task.

0 Kudos
Highlighted
Novice
6 Views

whixh linux should i use for this task.

0 Kudos
Highlighted
Employee
6 Views

I'd suggest you to use http://downloadmirror.intel.com/25384/eng/iot-devkit-201510010757-mmcblkp0-galileo.direct.xz this one (the eglibc image). You can find in https://software.intel.com/en-us/programming-blank-sd-card-with-yocto-linux-image-windows here a guide on how to setup your SD Card to be used on your Galileo with this image.

Peter.

0 Kudos
Highlighted
Novice
6 Views

@Intel_Peter then this code should also run on eclipse

0 Kudos
Highlighted
Employee
6 Views

Yes, the code should run fine on Eclipse as well. However, if you run it from Eclipse, the script will not be stored permanently, so I'd suggest you to create a system service that starts the script instead.

Peter.

0 Kudos