OCCRA
Go to Post Understand that not only can you learn from other experienced engineers, but also mechanics, farmers, and craftsmen. - Andy Baker [more]
Home
Go Back   Chief Delphi > Technical > Programming > Python
CD-Media  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 05-26-2017, 07:25 PM
Manusha4Lyfe Manusha4Lyfe is offline
Registered User
FRC #5124
 
Join Date: Jan 2015
Location: Torrance
Posts: 11
Manusha4Lyfe is an unknown quantity at this point
Question Cscore changing camera settings

I'm having trouble changing the exposure setting of my Playstation Eye camera through python-cscore on my raspberry pi 3.

Code:
cam = cscore.UsbCamera("usbcam", 0)
cam.setVideoMode(cscore.VideoMode.PixelFormat.kYUYV, 320, 240, 30)
cam.setExposureManual(0)
The code runs and I'm able to see the output from the camera, but the exposure remains unchanged and the terminal outputs this error when the code runs:

Code:
CS: ERROR: ioctl VIDIOC_S_EXT_CTRLS failed at UsbCameraProperty.cpp:66: Invalid argument (UsbUtil.cpp:122)
I'm also running an mjpeg server and I'm able to change the exposure through that, so I'm not sure what I'm doing wrong. Thanks for the help in advance.
Reply With Quote
  #2   Spotlight this post!  
Unread 05-27-2017, 12:37 AM
virtuald's Avatar
virtuald virtuald is offline
RobotPy Guy
AKA: Dustin Spicuzza
FRC #6367 (), FRC #7240 ()
Team Role: Mentor
 
Join Date: Dec 2008
Rookie Year: 2003
Location: Boston, MA
Posts: 1,409
virtuald has a reputation beyond reputevirtuald has a reputation beyond reputevirtuald has a reputation beyond reputevirtuald has a reputation beyond reputevirtuald has a reputation beyond reputevirtuald has a reputation beyond reputevirtuald has a reputation beyond reputevirtuald has a reputation beyond reputevirtuald has a reputation beyond reputevirtuald has a reputation beyond reputevirtuald has a reputation beyond repute
Re: Cscore changing camera settings

Sounds like something that cscore doesn't properly support yet. Recommend filing a bug at https://github.com/wpilibsuite/cscore
__________________
Maintainer of RobotPy (Python for FRC) & WPILib Contributor
Creator of pyfrc (Robot Simulator + utilities for Python), pynetworktables/pynetworktables2js (NetworkTables for Python & Javascript), and lots more...

Team #1418 (remote mentor): Newton Quarterfinalists, 2016 Chesapeake District Champion, 2x Innovation in Control award, 2x district event winner
Team #1418: 2015 DC Regional Innovation In Control Award, #2 seed; 2014 VA Industrial Design Award; 2014 Finalists in DC & VA
Team #2423: 2012 & 2013 Boston Regional Innovation in Control Award


Resources: FIRSTWiki (relaunched!) | My Software Stuff
Reply With Quote
  #3   Spotlight this post!  
Unread 05-27-2017, 11:43 AM
Manusha4Lyfe Manusha4Lyfe is offline
Registered User
FRC #5124
 
Join Date: Jan 2015
Location: Torrance
Posts: 11
Manusha4Lyfe is an unknown quantity at this point
Re: Cscore changing camera settings

Will do, thanks for the reply.
Reply With Quote
  #4   Spotlight this post!  
Unread 05-27-2017, 12:48 PM
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,979
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Have you looked at the supported properties either through the enumeratePropertiesAPI or the cscore web server?
Reply With Quote
  #5   Spotlight this post!  
Unread 05-27-2017, 01:34 PM
Manusha4Lyfe Manusha4Lyfe is offline
Registered User
FRC #5124
 
Join Date: Jan 2015
Location: Torrance
Posts: 11
Manusha4Lyfe is an unknown quantity at this point
Re: Cscore changing camera settings

Sorry I'm new to all of this, but by the cscore web server, are you referring to the mjpeg server or something else? If you're talking about the mjpeg server, I am able to change the exposure by setting the exposure to manual using the radio buttons and then changing the exposure slider. As for the enumerate properties, I have added the following line:

Code:
print(cam.enumerateProperties())
and I get the following output:

Code:
[<cscore._cscore.VideoProperty object at 0x769fda28>,
<cscore._cscore.VideoProperty object at 0x769fd4b8>,
<cscore._cscore.VideoProperty object at 0x769fd6c8>, 
<cscore._cscore.VideoProperty object at 0x6eafdaa0>, 
<cscore._cscore.VideoProperty object at 0x6eafda88>, 
<cscore._cscore.VideoProperty object at 0x6eb6b3b0>, 
<cscore._cscore.VideoProperty object at 0x6eb6b1d0>, 
<cscore._cscore.VideoProperty object at 0x6eb6b2f0>, 
<cscore._cscore.VideoProperty object at 0x6eb6b320>, 
<cscore._cscore.VideoProperty object at 0x6eb6b2d8>, 
<cscore._cscore.VideoProperty object at 0x6eb6b908>, 
<cscore._cscore.VideoProperty object at 0x6e921218>, 
<cscore._cscore.VideoProperty object at 0x6e921230>, 
<cscore._cscore.VideoProperty object at 0x6e921248>, 
<cscore._cscore.VideoProperty object at 0x6e921260>, 
<cscore._cscore.VideoProperty object at 0x6e921278>, 
<cscore._cscore.VideoProperty object at 0x6e921290>, 
<cscore._cscore.VideoProperty object at 0x6e9212a8>, 
<cscore._cscore.VideoProperty object at 0x6e9212c0>, 
<cscore._cscore.VideoProperty object at 0x6e9212d8>]
I don't know what any of this means so if you can help me or point me in the right direction that would be appreciated.
Reply With Quote
  #6   Spotlight this post!  
Unread 05-28-2017, 01:35 AM
Peter Johnson Peter Johnson is offline
Volunteer WPILib Developer, CSA
no team (WPILib)
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Redondo Beach, CA
Posts: 545
Peter Johnson has a reputation beyond reputePeter Johnson has a reputation beyond reputePeter Johnson has a reputation beyond reputePeter Johnson has a reputation beyond reputePeter Johnson has a reputation beyond reputePeter Johnson has a reputation beyond reputePeter Johnson has a reputation beyond reputePeter Johnson has a reputation beyond reputePeter Johnson has a reputation beyond reputePeter Johnson has a reputation beyond reputePeter Johnson has a reputation beyond repute
Re: Cscore changing camera settings

Quote:
Originally Posted by Manusha4Lyfe View Post
Sorry I'm new to all of this, but by the cscore web server, are you referring to the mjpeg server or something else? If you're talking about the mjpeg server, I am able to change the exposure by setting the exposure to manual using the radio buttons and then changing the exposure slider. As for the enumerate properties, I have added the following line:

Code:
print(cam.enumerateProperties())
I don't know what any of this means so if you can help me or point me in the right direction that would be appreciated.
Yes, the mjpeg server page where you change the settings, we need to know the actual settings names.

In code, You need to call getName() on each property, e.g.
Code:
for prop in cam.enumerateProperties():
    print(prop.getName())
__________________
WPILib Developer, 2014-Present:
  • Author of cscore - WPILib CameraServer for 2017+
  • Author of ntcore - WPILib NetworkTables for 2016+
Creator of RobotPy - Python for FRC
Mentor, Team 294, 2008-2018 (World Champions FRC 2010 & FTC 2008)
Reply With Quote
  #7   Spotlight this post!  
Unread 05-28-2017, 01:37 AM
virtuald's Avatar
virtuald virtuald is offline
RobotPy Guy
AKA: Dustin Spicuzza
FRC #6367 (), FRC #7240 ()
Team Role: Mentor
 
Join Date: Dec 2008
Rookie Year: 2003
Location: Boston, MA
Posts: 1,409
virtuald has a reputation beyond reputevirtuald has a reputation beyond reputevirtuald has a reputation beyond reputevirtuald has a reputation beyond reputevirtuald has a reputation beyond reputevirtuald has a reputation beyond reputevirtuald has a reputation beyond reputevirtuald has a reputation beyond reputevirtuald has a reputation beyond reputevirtuald has a reputation beyond reputevirtuald has a reputation beyond repute
Re: Cscore changing camera settings

If you run this script it will enumerate all available properties and their parameters:

https://github.com/robotpy/robotpy-c...es/settings.py
__________________
Maintainer of RobotPy (Python for FRC) & WPILib Contributor
Creator of pyfrc (Robot Simulator + utilities for Python), pynetworktables/pynetworktables2js (NetworkTables for Python & Javascript), and lots more...

Team #1418 (remote mentor): Newton Quarterfinalists, 2016 Chesapeake District Champion, 2x Innovation in Control award, 2x district event winner
Team #1418: 2015 DC Regional Innovation In Control Award, #2 seed; 2014 VA Industrial Design Award; 2014 Finalists in DC & VA
Team #2423: 2012 & 2013 Boston Regional Innovation in Control Award


Resources: FIRSTWiki (relaunched!) | My Software Stuff
Reply With Quote
  #8   Spotlight this post!  
Unread 05-28-2017, 01:25 PM
Manusha4Lyfe Manusha4Lyfe is offline
Registered User
FRC #5124
 
Join Date: Jan 2015
Location: Torrance
Posts: 11
Manusha4Lyfe is an unknown quantity at this point
Re: Cscore changing camera settings

After the settings.py, this is the output I get:

Code:
CS: usbcam: Connecting to USB camera on /dev/video0
CS: usbcam: set format 1 res 320x240
Properties:
raw_brightness (int): value=0 min=0 max=255 step=1 default=0
brightness (int): value=0 min=0 max=100 step=1 default=0
raw_contrast (int): value=32 min=0 max=255 step=1 default=32
contrast (int): value=12 min=0 max=100 step=1 default=12
raw_saturation (int): value=64 min=0 max=255 step=1 default=64
saturation (int): value=25 min=0 max=100 step=1 default=25
raw_hue (int): value=0 min=-90 max=90 step=1 default=0
hue (int): value=50 min=0 max=100 step=1 default=50
white_balance_automatic (bool) value=1 default=1
exposure (int): value=120 min=0 max=255 step=1 default=120
gain_automatic (bool) value=1 default=1
raw_gain (int): value=20 min=0 max=63 step=1 default=20
gain (int): value=31 min=0 max=100 step=1 default=31
horizontal_flip (bool) value=0 default=0
vertical_flip (bool) value=0 default=0
power_line_frequency (enum): value=0    0: Disabled    1: 50 Hz
raw_sharpness (int): value=0 min=0 max=63 step=1 default=0
sharpness (int): value=0 min=0 max=100 step=1 default=0
auto_exposure (enum): value=0    0: Auto Mode    1: Manual Mode
I was able to change the exposure setting using:

Code:
cam.getProperty("auto_exposure").set(1)
cam.getProperty("exposure").set(0)
Is this the correct way to change the settings? If so, thanks for all your guys' help, I couldn't have figured it out without you.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 10:44 AM.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi