Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Python: USBCamera does not work? (http://www.chiefdelphi.com/forums/showthread.php?t=134022)

team-4480 05-02-2015 11:33

Python: USBCamera does not work?
 
Hi! We ran into a problem when trying to set up a USBCamera with RobotPy and Python. This code gives us an error:
Code:

        self.usb_camera=wpilib._impl.USBCamera()
wpilib._impl.CameraServer.setAutomaticCapture(self.usb_camera)

We get a module has no attribute to USBCamera and CameraServer error. I tried importing wpilib._impl but that didn't help anything. Thanks a bunch in advance!

TimTheGreat 05-02-2015 14:43

Re: Python: USBCamera does not work?
 
I had the same problem and it took quite a while to figure out.

Code:

try:
            self.camera = wpilib.USBCamera()
            self.camera.startCapture()
            self.camServ = wpilib.CameraServer()
            self.camServ.startAutomaticCapture(self.camera)
        except:
            self.camera = None

So you create a camera object, start it, then start the camera server. The try/except is in case you want to test without the camera, and it won't break.


All times are GMT -5. The time now is 01:43.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi