473,383 Members | 1,958 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Access USB Webcam using c++ on linux (asus eee)

Hi

I am attempting to get access to the data stream from the webcam on my asus eee, I have no clue as to where to start. I am trying to get to the stream so that I can distribute it over a local wireless network. I am OK with the socket programming bit, it is just getting to the stream which I am finding hard. There is little info that I can find on the web so any help would be appreciated.

I am thinking that I may want to store the stream in a temporary buffer, before encrypting a chunk of it and sending it via a udp socket?
Aug 18 '08 #1
15 11847
The best place to start is by determining what driver is being used. From there, search for what functionality that driver has and what calls are supported. Then all you need to do is make those calls in your program.

Interfacing with a webcam, even if a driver exists can be difficult. I would look for examples of code which are interfacing with the same/or a similar driver and use those as a template.

Edward
Aug 18 '08 #2
OK I will look into that, even when I have the calls how do you connect to the camera to send them? Am I right in saying that it is done in the same way as opening a file but with the usb devices mounted name as the filename?

Cheers
Aug 19 '08 #3
TamusJRoyce
110 100+
It seems like you are needing to deal with video4linux. Kernel hacking is about the best way, since you are dealing with encryption and streaming (two things linux excells at).

With video4linux, it makes it pretty simple to access any and all cameras supported's frame-buffer pretty easy (once you get through setting everything up).

I don't remember the link (and linking to there is forbidden, if I remember correctly), but I know there is excellent documentation out there. Just make sure you use v4l2 documentation instead of v4l1 because of several major differences in the api.

As for whether you need it in user mode or kernel mode...

Hopefully this helps you stream your webcam : )
Aug 19 '08 #4
It seems like you are needing to deal with video4linux. Kernel hacking is about the best way, since you are dealing with encryption and streaming (two things linux excells at).

With video4linux, it makes it pretty simple to access any and all cameras supported's frame-buffer pretty easy (once you get through setting everything up).

I don't remember the link (and linking to there is forbidden, if I remember correctly), but I know there is excellent documentation out there. Just make sure you use v4l2 documentation instead of v4l1 because of several major differences in the api.

As for whether you need it in user mode or kernel mode...

Hopefully this helps you stream your webcam : )
OK, i have had a look at the v4l2 stuff and the examples that I have found which use the code are huge. I really am just looking for simple code that will allow me to store frames in a buffer/data structure before being encrypted and sent over a socket. If no one knows of a solution then maybe a book/resource could be recommended.

Thanks
Aug 19 '08 #5
The three tasks you mentioned are not really do-able with just a simple program. My suggestion would be to study the example code and break it down to the bare minimum. As for the encryption and sockets, I would suggest finding libraries that take care of the tasks. Even using libraries, the program is not likely to be simple.

Edward
Aug 19 '08 #6
The three tasks you mentioned are not really do-able with just a simple program. My suggestion would be to study the example code and break it down to the bare minimum. As for the encryption and sockets, I would suggest finding libraries that take care of the tasks. Even using libraries, the program is not likely to be simple.

Edward
The sockets and encryption are the easy bit as I have done them before, but I was hoping that the frame capture wouldnt be too hard, the other option would be to buy an IP camera I suppose because that stream would be in packets already...
Aug 19 '08 #7
If you post the specifics for the camera (manufacturer and model number should work) you are tyring to use I can try to write/find some simple code though I will not be able to test it as I wont have the same camera. If you know the specific driver you want to use that would work as well.

One other matter to consider is what format the frame needs to be stored as. This could potentially make a big difference in how easy it is. (I have done some basic work with capturing images from webcams but I only had to deal with the most basic functionality as someone had written a header file to do most of the work.)

Edward
Aug 19 '08 #8
I will try to find out the make and model, It is the built in webcam on the asus eee701 laptop if that helps?

Regards

Scott
Aug 19 '08 #9
Try going to the terminal and typing lsusb (I think that is the command). If the webcam is connected via usb (which seems to be the case in most laptops now days) then you should be able to determine the make and model by looking at the resulting list of usb devices.

Hope that helps.

Edward

Edit: After a little research it apears that the webcam is connected by usb so the above command should yield results.
Aug 19 '08 #10
Try going to the terminal and typing lsusb (I think that is the command). If the webcam is connected via usb (which seems to be the case in most laptops now days) then you should be able to determine the make and model by looking at the resulting list of usb devices.

Hope that helps.

Edward

Edit: After a little research it apears that the webcam is connected by usb so the above command should yield results.
I will see if that works when I get home later and have acces to the laptop
Aug 20 '08 #11
TamusJRoyce
110 100+
Oh... I thought with the encryption you where being "high tech."

Only reason I know about v4l2 is because I had a malfunctioning cheap camera whose driver didn't quite work. A project that was never completed because it's above my head as well.

Your best bet is to use sdl. It has a module which will interact with v4l giving you an easy to access frame buffer.

Agg. Well, on windows that's the case. I think the one for the Panasonic camera sdl_camera addon would work for any camera, but I dunno.

I hope this answers your question. Never used sdl's camera on linux, though sdl runs great on linux, from what I've done.

maybe you need a command line tool or something to capture the frame buffer for you. "tv tools" pick up web cam's just as easy as tv-tuner cards. All based ontop of v4l. Or maybe their is an easy to use api they might implement.
Aug 20 '08 #12
Oh... I thought with the encryption you where being "high tech."

Only reason I know about v4l2 is because I had a malfunctioning cheap camera whose driver didn't quite work. A project that was never completed because it's above my head as well.

Your best bet is to use sdl. It has a module which will interact with v4l giving you an easy to access frame buffer.

Agg. Well, on windows that's the case. I think the one for the Panasonic camera sdl_camera addon would work for any camera, but I dunno.

I hope this answers your question. Never used sdl's camera on linux, though sdl runs great on linux, from what I've done.

maybe you need a command line tool or something to capture the frame buffer for you. "tv tools" pick up web cam's just as easy as tv-tuner cards. All based ontop of v4l. Or maybe their is an easy to use api they might implement.
I have tried looking online at SDL and it appears to be for producing graphics/games etc. but I cannot see anything about accessing images from cameras?
Aug 20 '08 #13
TamusJRoyce
110 100+
sdl-camera was what I was talking about. It says it does streaming using video4linux.

Patched to work with gentoo (though not required shows it's compatible with the latest & greatest). Look thought the code to see if it's right. Again, I've only used webcams with windows, so I could be wrong about this.

Try looking at v4l2 example (at http://v4l2spec.bytesex.org/v4l2spec-0.24.tar.bz2) for example.c and videodev2.h

Try accessing the buffer in buffers. maybe that would help? Or look at sdlcam above to see how it accesses v4l.

I doubt you want to access your camera low level through it's driver, and so far those are the only two alternatives I've pulled up so far. I'll be looking for another...
Aug 22 '08 #14
TamusJRoyce
110 100+
Ah... Look here . Search for "Applications and Libraries."

You probably would want to use DirectFB, which is a simple way to access the Frame Buffer *hits self on head and says duh* and is suppose to be similar to directx (hence me referring you to sdl, with it being cross platform). It's linux specific and uses v4l which is what I was looking for in the first place.

It also shows Xawtv which may also have some good tools/api's to access your webcam? Dunno if you can program with it, but I've used xawtv for tv-tuner card as well as webcams. Maybe an api for accessing it exists?

Unfortunately the data doesn't come in streams, but rather an area in memory where the pixels are refreshed according to the camera's refresh rate. You may be able to open that part of memory like a file, but who knows what format it will be in, or if the memory is even linear (meaning the camera only uses a part of the whole memory and determining the size is almost impossible, scewing your video line by line across the screen).

That's where SDL, DirectX, DirectFB, and such come in. They do the conversion to what you want for you. Just takes a bit to set them up.

Alter an example and ignore the setup part of the code. Just know you can access that array of bytes in the format you need it.

Yay. DirectFB for the win! Simple way to access the FB of your webcam? Now only if it worked in lolcode :P

Post back if this helps and if you have any success with it.
Aug 22 '08 #15
I had a look and play around with that directfb stuff but it doesnt seem to have much support for webcams??? I have come across libfg but am having trouble with that also? Any other ideas?
Oct 7 '08 #16

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Steven Burn | last post by:
Thats the headline this morning. In the latest issue of The Register (my favourite online newsletter), there's a story (see URL below) about Microsoft using Linux temporarily, for their...
1
by: xtanto | last post by:
Hi All, We need to develope application & report that run on windows accessing Oracle on Linux. and we use Crystal Report as reporting tool. Can Crystal Report on windows access...
2
by: SBK | last post by:
I'm having a problem: I connect to an MS access db using jet oledb (it has a password). If the db doesn't have a password, everything works fine. If i do, access gets locked down (.ldb) with the...
1
by: Joris Kempen | last post by:
Hi people, I know that the question has come around sometimes: How to open an Access Report using ASP and export it to for example RTF. I'm trying to implement the first method of David...
3
by: mairhtin o'feannag | last post by:
Hello, Since DB2 Cluster Certification Guide is out of print and I cannot seem to get my hands on a copy, is there a publication that would give me a "cookbook" approach to setting up a cluster...
2
by: KemperR | last post by:
Hi All, does anybody have a good idea how I can run access 2002 on a Linux server ? I own a Suse professional 8.2 Linux Thanks Rolf
0
by: nostradumbass77 | last post by:
Using Enterprise Library 2.0 (Jan 06) and .NET 2.0 (VB.Net 2005) Dim dbPF As Data.Common.DbProviderFactory Try dbPF = Data.Common.DbProviderFactories.GetFactory("System.Data.OleDb") db = New...
3
by: hanz | last post by:
Hello everyone, I am trying to create an MS Access file using Perl in a Linux environment. By the way I am on a SuSE Linux envrironment. I have already installed the DBI module. I am looking...
1
by: ezat azah | last post by:
I am doing a project in C++ to retrieve stream of images from webcam using Codegear compiler. Honestly I am new in C++ languages. After a few research I found out that C++ can do the filtering to...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.