LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 11-13-2014, 12:15 AM   #1
KansaiRobot
Member
 
Registered: Dec 2013
Location: Japan
Distribution: Debian...very few times Ubuntu
Posts: 51

Rep: Reputation: 0
Camera settings in Linux ...(V4L2 or UVC drivers)


Thank you everybody who has helped me so far. I appreciate it very much.

This time I would like to ask about connecting a camera to a linux system. I am a little confused about what exactly to ask so please bear with me

The situation

I have a USB camera that I connect to an arm microcontroller running linux (a variant of uCLinux)

since the manufacturer didnt provide any driver, but the camera is UVC compliant, the camera is recognized by the linux system.

Moreover, using V4L2, I can build a simple program that grabs some camera shots and save them as files

so far so good.

The question

Is there a way I can set up, or modify the settings of the camera (white balance, etc) with the tools I have (mentioned above) or others. In other words, I am not going to get a special driver made for the camera from the manufacturer.

Thank you very much for your comments and any help

Kansai
 
Old 11-13-2014, 09:10 AM   #2
j-ray
Senior Member
 
Registered: Jan 2002
Location: germany
Distribution: ubuntu, mint, suse
Posts: 1,591

Rep: Reputation: 145Reputation: 145
Install uvcdynctrl then these commands will help you:

uvcdynctrl -s 'Brightness' 120
uvcdynctrl -s 'Contrast' 35
uvcdynctrl -s 'Saturation' 50
uvcdynctrl -s 'Sharpness' 100
uvcdynctrl -s 'Focus, Auto'
 
1 members found this post helpful.
Old 11-26-2014, 11:30 PM   #3
KansaiRobot
Member
 
Registered: Dec 2013
Location: Japan
Distribution: Debian...very few times Ubuntu
Posts: 51

Original Poster
Rep: Reputation: 0
Thank you very much for your helpful reply.

I have installed uvcdynctrl and I have also installed cheese.

(well, I have cheese and guvcview are all buggy in my system, I dont know why but that is another issue)

the thing is, even when I change the exposure settings with uvcdynctrl , this is not reflected in the image I take.
For example if I put

Code:
uvcdynctrl -s Exposure,\ Auto 1
uvcdynctrl -s Exposure\ \(Absolute\) 100
the image is not dark. and if I set

Code:
uvcdynctrl -s Exposure\ \(Absolute\) 4800
the image is not all bright. In fact it doesnt change.

What am I doing wrong?

Kansai

P.S> I tried in guvcview to change the settings and it worked for a while. I could get some bright and dark images, but cheese remains unchanged and guvcview remains unchanged sometimes
P>S2 I also wrote a program to take photos and change exposure in V4l2 and the same, the pictures dont change
 
Old 11-27-2014, 01:35 AM   #4
j-ray
Senior Member
 
Registered: Jan 2002
Location: germany
Distribution: ubuntu, mint, suse
Posts: 1,591

Rep: Reputation: 145Reputation: 145
have you tried this way:

uvcdynctrl -s 'Exposure, Auto' 1

?
 
Old 11-27-2014, 02:35 AM   #5
KansaiRobot
Member
 
Registered: Dec 2013
Location: Japan
Distribution: Debian...very few times Ubuntu
Posts: 51

Original Poster
Rep: Reputation: 0
Thanks I did try this.

Let me clarify. I can change the exposure settings (with uvcdynctrl and my own program) but these changes aren't reflected in the photos I take (with cheese or my program)

Interesting thing though. I tried using luvcview. When I run it, the image I see does not reflect the changes either, however when I change the exposure value with luvcview I immediately can see an overexposed image or an underexpose one

however, if I close luvcview and start it again, it agains regain an auto regulated exposure, and only by changing it with the program can I see the difference

strange....

any help appreciated

Last edited by KansaiRobot; 11-27-2014 at 02:42 AM.
 
Old 11-27-2014, 03:09 AM   #6
j-ray
Senior Member
 
Registered: Jan 2002
Location: germany
Distribution: ubuntu, mint, suse
Posts: 1,591

Rep: Reputation: 145Reputation: 145
You can create and use a config file for the settings:

http://manpages.ubuntu.com/manpages/...uvcview.1.html :

-r Read and set control settings from the luvcview.cfg file in the
current directory. Such a configuration file can be created by
using the F1 key in the interface.
 
Old 11-28-2014, 12:42 AM   #7
KansaiRobot
Member
 
Registered: Dec 2013
Location: Japan
Distribution: Debian...very few times Ubuntu
Posts: 51

Original Poster
Rep: Reputation: 0
I am sorry, I dont understand
What for is the config file and what should I include there?
will it help me to correctly see the desired pics?
 
Old 11-30-2014, 09:16 AM   #8
j-ray
Senior Member
 
Registered: Jan 2002
Location: germany
Distribution: ubuntu, mint, suse
Posts: 1,591

Rep: Reputation: 145Reputation: 145
I took a closer look at it and it seems that this option does not help. One can only set the luvcview options there I guess.
 
Old 12-01-2014, 01:19 AM   #9
KansaiRobot
Member
 
Registered: Dec 2013
Location: Japan
Distribution: Debian...very few times Ubuntu
Posts: 51

Original Poster
Rep: Reputation: 0
at the same time as using luvcview and uvcdynctrl I am also doing my own program. And I found something interesting.
I am not going to write the whole program here but algorithmically it used to go like this

Code:
open device
init device
set settings <== here I set the exposure and stuff
start capturing
take several photos
stop capturing
close device
Well, id didnt work, the settings were not reflected on the image.

I changed the code to include settings inside the "take several photos" function

So now after each photo I change the settings

and it worked! I can see the photos reflecting the new settings

ONLY ONE PROBLEM! For some reason the photos don't reflect the settings immediately after changing them. It takes three photos to waste and the fourth photo after changing the settings is the one that reflects the settings correctly.

I have no idea why this is so... any idea???
 
Old 12-01-2014, 02:04 AM   #10
j-ray
Senior Member
 
Registered: Jan 2002
Location: germany
Distribution: ubuntu, mint, suse
Posts: 1,591

Rep: Reputation: 145Reputation: 145
A while ago I have written a perl script that runs a camera with mplayer then takes a photo with fbi and saves it somewhere. Before opening the screen it calls a 2nd script called "setCam.pl" that uses uvcdynctrl to reset the camera.



Quote:
system($DIR."setCam.pl &");
system("mplayer tv:///dev/video0 ");
system("fbi $pic");

#setCam
#!/usr/bin/perl

#delay the execution for screen needs some time to start
sleep(4);

# Logitech HD 720p Autofocus
#system("uvcdynctrl -s 'Brightness' 120");
#system("uvcdynctrl -s 'Contrast' 35");
#system("uvcdynctrl -s 'Saturation' 50");
#system("uvcdynctrl -s 'Sharpness' 100");
#system("uvcdynctrl -s 'Focus, Auto' 1");


# Microsoft LiveCam Studio
system("uvcdynctrl -s 'Exposure, Auto' 1");
system("uvcdynctrl -s 'Exposure (Absolute)' 20");
system("uvcdynctrl -s 'Brightness' 150");
#system("uvcdynctrl -s 'Brightness' 250");
system("uvcdynctrl -s 'Contrast' 25");
system("uvcdynctrl -s 'Saturation' 200");
system("uvcdynctrl -s 'Sharpness' 100");
system("uvcdynctrl -s 'Focus, Auto' 1");
Maybe that helps? This way we get good photos with a raspi.

Last edited by j-ray; 12-01-2014 at 02:10 AM.
 
Old 12-02-2014, 07:01 PM   #11
KansaiRobot
Member
 
Registered: Dec 2013
Location: Japan
Distribution: Debian...very few times Ubuntu
Posts: 51

Original Poster
Rep: Reputation: 0
quick question.

When I do

>uvcdynctrl -g 'Exposure, Auto'

I get the value of manual or automatic.

However one colleague using ubuntu when he does the same thing gets nothing.

Wonder why this is so?
 
Old 12-03-2014, 01:46 AM   #12
j-ray
Senior Member
 
Registered: Jan 2002
Location: germany
Distribution: ubuntu, mint, suse
Posts: 1,591

Rep: Reputation: 145Reputation: 145
Same camera model?
 
Old 03-11-2015, 07:33 PM   #13
KansaiRobot
Member
 
Registered: Dec 2013
Location: Japan
Distribution: Debian...very few times Ubuntu
Posts: 51

Original Poster
Rep: Reputation: 0
Well just to close this thread and write a solution in case someone else have a similar problem...

I finally solved the issue. The thing is that I had to change the Exposure and the Gain settings after I started the photo capturing not before (all other settings are to be set before). In addition Gain can only be set when Exposure is set to manual.

I also had to throw away the first three pics cause they don't reflect a stabilized camera.

With these changes, I built a program that could set parameters and take pics successfully.

Thanks for all the help
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Adjusting v4l2 settings after launching mplayer to framebuffer in console? MattHabermehl Linux - Software 2 10-09-2014 04:49 AM
Baud rate and other settings settings for Linux UART drivers through ioctls. kauuttt Linux - Kernel 1 10-18-2012 12:50 PM
v4l2 App to display video image as if from camera radiodee1 Debian 1 10-05-2011 07:23 AM
Logitech QuickCam E 3500 - works perfectly with standard UVC drivers Rud Linux - Hardware 2 03-08-2009 01:36 AM
Installing Linux-UVC drivers in Slackware 12 Poetics Slackware 2 02-04-2008 11:18 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:31 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration