Acessing GPIOs with pypylon - python

I am using the Basler Racer raL2048-48gm camera and need to access the GPIOS via pypylon API (pylon for python ). I'm used to programming in c ++ version of pylon, there to access a GPIO from a camera you write something like this:
// some code ....
Camera_t Camera (pTl-> CreateDevice (info1));
Camera.UserOutputSelector.SetValue (UserOutputSelector_UserOutput2);
Camera.UserOutputValue.SetValue (true);
// some code ....
I didn't find anything in the pypylon API that would allow me to access the camera's GPIOS ... Does anyone know how to do this?

I solved the problem. I was not calling camera.open() before trying to access the camera parameters. More info.
Thanks everyone that tried answer this question.

Related

Python OpenCV with Imaging device USB3 Vision compliant camera - VideoCapture() index of camera not found

I have a problem with using external camera in Python OpenCV.
I am using Windows.
In device manager, camera is not under "Cameras", but under "Imaging devices" and is called USB3 Vision compliant camera.
The camera is working fine on app given by company (UcamViewer).
I want to connect to this camera using cv2.VideoCapture().
I have of course tried:
cv2.VideoCapture(k)
for k = [0..100]
Only k = 0 is occupied and works - that is my webcam.
I have also tried adding multiple possible values to the second parameter of the VideoCapture(), which did not work.
how to get video from a "USB3 Vision" device?
This question suggested to use cv.CAP_XIMEA as the second parameter of VideoCapture(), but CAP_XIMEA does not seem to be a possible value.
If I can not fix this issue and use VideoCapture(), what would you suggest to use to capture the video and convert it to format that can be used by openCV methods?
Any ideas how could I solve this issue will be appreciated.
Thank you for your help.

how to calibrate mpu6050 sensor using python and multiwii serial protocol?

I have multiwii board connected to raspberry pi 3A and I want to calibrate the mpu6050 sensor from raspberry pi using python programming, can anyone help me out on how I can program this, please?
Try to be more specific in you questions for te next times.
But, to calibrate a Gyro you should take a look at this tutorial.. Or if you are a really begginer and wants to learn how to use the sensor, take a look to this.
This and this tutorial are also useful.

how to connect lsm9ds1 to respeaker using mraa?

I am new here, so please be patient with me
I have bought a respeaker device. I wanted to connect a bunch of sensors to it (bme280,lsm9ds1,tsl2561) but it turns out that I can't use the same raspberry pi code with it instead I have to use mraa and upm.
The bme280 worked fine with the upm library but the lsm9ds1 and tsl2561 did not work.
So is there any mraa code for these sensors or I have to write it my self? and if so how can I get started?
note: all these sensors are from adafruit.
Thanks anyway :)
DIY
use the library that I have created https://github.com/omar7altawil/LSM9DS1-I2C

Python Wifi Issue Connect to Mysterious Camera

I have been working with some drones and robotics projects using arduino and python. There was a kickstarter project for a neat little hex copter, that hasn't been managed well.
I was lucky, i got my copter and then some time later after some frustrated email exchanges, i finally recieved the camera as well. To this day, their forum has people still complaining. Their maker forum is now down and their wiki hasn't been updated with any specifics on the camera.
http://www.flexbot.cc/wiki/index.php?title=Main_Page#Hardware
Their app to accompany the drone still doesn't support the camera module. Not that it'd matter, as their code isn't very well documented or annotated.
https://github.com/HexAirbot
There are some tips on switching the camera on the comments page of their kickstarter campaign.
https://www.kickstarter.com/projects/1387330585/hex-a-copter-that-anyone-can-fly/posts/1093716
So, sob story over, i'm stuck with this neat little wifi camera that i am unsure on how to connect to. I know how to switch it on and it does have a micro-usb port on it.
What library in Python could i use to stream an image from this camera given that it is a wifi camera. If i wanted the video stream as a numpy matrix.
I need to interface with the camera, so i can connect and disconnect.
Then, be able to read images frame by frame with ffmpeg. I have some python modules that can detect and read from a camera, but how can my code ensure that the camera is connected?
Totally stuck. Any help would be appreciated.
Considering you are building for the android platform, you will more than likely need to use some sort of java/python driver/interface, unless you just use java.
Here is an article on java/python, and using python from within java.
Using Python from within Java

PS3 controller driver -> uinput-> python? somehow?

I'm trying to read from a PS3 controller in python on Ubuntu and I'm not having much luck. I started with the ps3joy driver from Willow Garage (http://www.ros.org/wiki/ps3joy) which supposedly publishes all the important bits of the PS3 controller to something I had never heard of called "uinput". Apparently it's a linux feature that allows userspace drivers to provide system events. ...Why the WG driver requires root access given that it's supposedly a userspace driver is beyond me, but that's not my question.
Anyway, the current state of me trying to get it to work is that I've got the driver working, and I've verified that it responds to button presses on the controller, but I don't know how to pull any of that data out so I can use it.
My first guess was to use pygame to (hopefully) read from /dev/uinput (which I'm pretty sure is where the driver sends the data):
from pygame import joystick
if not joystick.get_init():
joystick.init()
js = joystick.Joystick(0) # there is only one joystick... even if the driver isn't running(!)
js.init()
print js.get_numbuttons() # perhaps coincidentally correctly prints 17 which is the number of buttons on a PS3 controller
for i in range(js.get_numaxes()):
print js.get_axis(i) # always prints 0, no matter what I'm doing with the controller
but it didn't work. The most telling part of the problem is that it does the same thing if I don't have the WG driver running at all.
I'm sure this is something easy, that I'm just not reading the right information, but googling has not helped me find what the right information is and I'm getting tired and desperate.
You don't need the driver. Assuming the controller exposes itself as a HID, you can use the event subsystem to read controller events directly from the device.
I know it's too late, but if anyone will ever need the code or is struggling with it, you can use mine. I've wrote a script in python that gets ps3 data from USB and sends it to specific a MAC address via PC's bluetooth (you can use ps3controller.py only for data).
This was made for my quadcopter project.
https://github.com/urbanzrim/ps3controller
Try
pygame.event.pump()
before you read the joystick. I needed it to work with the 360 controller
I believe you need the following at the very least:
from pygame import joystick, event, display
display.init()
joystick.init()
js=joystick.Joystick(0)
js.init()
...
for foo in bar:
event.pump()
...
if foo:
event.pump()
...
while bar:
event.pump()
...
I believe that display.init() has to be there because it is needed for event handling...
Also, you can skip a lot of that with
import pygame
pygame.init()
js=pygame.joystick.Joystick(0)
js.init()
...
for foo in bar:
pygame.event.pump()
...
if foo:
pygame.event.pump()
...
while bar:
pygame.event.pump()
....
I could be wrong, but I think your issues are:
A) No event.pump in your if/while/for clauses
B) No display.init()
Sources:
http://webcache.googleusercontent.com/search?q=cache:I56GyE7I4CkJ:iamtherockstar.com/archive/making-hid-devices-easier-using-pygame-joysticks/+&cd=1&hl=en&ct=clnk&gl=us
and
http://www.pygame.org/docs/ref/event.html
"The input queue is heavily dependent on the pygame display module."
Solving similar problem right now: communicate/receive data from PS3 bluetooth remote with python in GNU/Linux.
What i found helpful:
Debugging PS3 Controller http://www.pabr.org/sixlinux/sixlinux.en.html
Looks like working project, for PS3 Remote http://kitlaan.twinaxis.com/projects/bluez-ps3remote/ (it requires to patch bluez 1st) did not tested, yet.
pybluez BT wrapper http://code.google.com/p/pybluez/ (checking it right now)

Categories

Resources