Closed KrystofVydra closed 3 years ago
You will probably need to adapt the examples to suit your camera(s). Different cameras have different names for config items, and different value ranges. The camera-config-gui.py example should display all your camera's config items and allow you to experiment with setting them.
camera-config-gui.py won't even launch. this is what I get:
ubuntu@ubuntu:/usr/local/share/python-gphoto2/examples$ python3 camera-config-gui.py
Traceback (most recent call last):
File "camera-config-gui.py", line 28, in <module>
from PyQt5 import QtCore, QtWidgets
ModuleNotFoundError: No module named 'PyQt5'
I have no idea what I am doing wrong, I tried reinstalling everything updatin everything, even tried on my laptop but nothing (this is in virtual machine). I am kinda newbie to this, I usually program cpp.
Ok, I did also some googling and find out about installing PyQt5, so I did that and now I get another weird behavior.
I run python3 camera-config-gui.py
and get:
WARNING: gphoto2: (_get_config [config.c:8820]) Type of property 'Bulb Mode' expected: 0x0000 got: 0x0004
Traceback (most recent call last):
File "camera-config-gui.py", line 69, in event
self.initialise()
File "camera-config-gui.py", line 80, in initialise
top_widget = SectionWidget(self.config_changed, self.camera_config)
File "camera-config-gui.py", line 110, in __init__
tabs.addTab(SectionWidget(config_changed, child), label)
File "camera-config-gui.py", line 114, in __init__
self.layout().addRow(label, RangeWidget(config_changed, child))
File "camera-config-gui.py", line 163, in __init__
self.setRange(int(lo * self.inc), int(hi * self.inc))
OverflowError: argument 2 overflowed: value must be in the range -2147483648 to 2147483647
And the GUI window is blank (white) and "apply change" button is greyed out. My camera is connected.
Edit the camera-config-gui.py program, find the setRange
command and then comment out that line and the one after (insert ## at the start of the line to comment it out). Go from this:
lo, hi, self.inc = self.config.get_range()
value = self.config.get_value()
self.setRange(int(lo * self.inc), int(hi * self.inc))
self.setValue(int(value * self.inc))
self.sliderReleased.connect(self.new_value)
to this:
lo, hi, self.inc = self.config.get_range()
value = self.config.get_value()
## self.setRange(int(lo * self.inc), int(hi * self.inc))
## self.setValue(int(value * self.inc))
self.sliderReleased.connect(self.new_value)
Then try again.
PS I'd like to know what's causing the problem. If you get a chance, can you add a print statement and let me know what output you get:
lo, hi, self.inc = self.config.get_range()
value = self.config.get_value()
print(lo, hi, self.inc, value)
## self.setRange(int(lo * self.inc), int(hi * self.inc))
## self.setValue(int(value * self.inc))
self.sliderReleased.connect(self.new_value)
It is working now! even changing configs! I even managed to get the get-capture-target.py and set-capture-target.py to work (I replaced the config name with "iso" config just to try it)!
I added the print function (print(lo, hi, self.inc, value)) to the python3 camera-config-gui.py and this is the output:
I run $ python3 camera-config-gui.py
and I get (everything works fine):
WARNING: gphoto2: (_get_config [config.c:8820]) Type of property 'Bulb Mode' expected: 0x0000 got: 0x0004
0.0 4294.96728515625 1.0 33.911808013916016
0.0 655.3499755859375 0.009999999776482582 3.5
0.0 65535.0 1.0 350.0
0.0 4294967296.0 1.0 65586.0
2500.0 9900.0 100.0 4500.0
164.0 220.0 2.0 192.0
0.0 4294967296.0 1.0 33911808.0
0.0 65535.0 1.0 0.0
I guess 4294967296.0 is the culprit. I'll do some further investigation tomorrow.
Thanks for your help.
The Qt QSlider widget doesn't accept values outside the 32 bit integer range, which is why the setRange call fails.
Some of these "slider" range and increment values look rather strange. Increments of 1 or 2 are sensible, but 0.009999999776482582? And the first has an increment of 1.0 but a current value of 33.911808013916016. However, this looks rather like Property 0xd214:(readwrite) (type=0x6) Range [0 - 4294967295, step 1] value: 33911808
listed above, so I've no idea what the values are supposed to be.
I've modified the example program to limit the range in commit 6615e7a.
This page is for reporting problems with the Python interface to libgphoto2. If your question is about using libgphoto2 you should ask on the gphoto2 mailing list.
Your system What version of Python are you using?
What version of libgphoto2 have you installed?
How have you installed (or attempted to install) python-gphoto2?
Your problem Please describe what you are trying to do and what goes wrong. A short Python script that shows the problem may be useful.
Ubuntu 20.04 gphoto2 2.5.23 libgphoto2 2.5.24 libgphoto2_port 0.12.0 python3 3.8.2
I have installed python-gphoto2 with
sudo pip3 install gphoto2
python3 camera-summary.py
outputs this:So that works well, even the capture-image.py works perfect, choose-camera.py etc...
but I have issues with set-capture-target.py, get-capture-target.py and get-camera-clock.py none of them works.
python3 get-capture-target.py
outputs this:python3 set-capture-target.py
outputs the samepython3 get-camera-clock.py
outputs:Do you have any ideas what could go wrong? I just want to be able to change camera configs, that's my goal. (I got it working only in gphoto2 cli tool, and then tried a lot with libgphoto2 in c, in cpp, in python but no luck, so looks like I will probably end up using the gphoto2 cli in my script. I just want to avoid that, cuz it is pretty dirty solution.)