@emeyeraway I would bet a small wager that if you are using an Arducam you need those libraries and sample code. Start over from the Arducam website reading about how to use their cameras, what libraries you need, and I am sure some sample code. I just went and checked the arducam site and see they may have compatible as well as proprietary cameras. What model do you have, please be very accurate, maybe a pic of the camera label or box or from your order paperwork.
First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.
I know you are not perusing the example code, it is a bit of extra learing for sure as it uses pyQt5 as its gui, but all these gui's (tkinter, kivy pyQt5 etc) need a bit of learning, and its the only way if one want to have a nice gui with push buttons etc in your code.
Anyway I did not like to leave an example up that did not close the program properly (albeit it was not mine) so I amended it to have an 'exit' push button to more cleanly quit the program.
#!/usr/bin/python3 # This example is essentially the same as app_capture.py, however here # we use the Qt signal/slot mechanism to get a callback (capture_done) # when the capture, that is running asynchronously, is finished. from PyQt5 import QtCore from PyQt5.QtWidgets import (QApplication, QHBoxLayout, QLabel, QPushButton, QVBoxLayout, QWidget) from picamera2 import Picamera2 from picamera2.previews.qt import QGlPicamera2 def post_callback(request): label.setText(''.join(f"{k}: {v}\n" for k, v in request.get_metadata().items())) picam2 = Picamera2() picam2.post_callback = post_callback picam2.configure(picam2.create_preview_configuration(main={"size": (800, 600)})) app = QApplication([]) def on_button_clicked(): button.setEnabled(False) cfg = picam2.create_still_configuration() picam2.switch_mode_and_capture_file(cfg, "test.jpg", signal_function=qpicamera2.signal_done) def on_button2_clicked(): picam2.stop() app.quit() exit() def capture_done(job): picam2.wait(job) button.setEnabled(True) qpicamera2 = QGlPicamera2(picam2, width=800, height=600, keep_ar=False) button = QPushButton("Click to capture JPEG") button2 = QPushButton("Exit Program") label = QLabel() window = QWidget() qpicamera2.done_signal.connect(capture_done) button.clicked.connect(on_button_clicked) button2.clicked.connect(on_button2_clicked) label.setFixedWidth(400) label.setAlignment(QtCore.Qt.AlignTop) layout_h = QHBoxLayout() layout_v = QVBoxLayout() layout_v.addWidget(label) layout_v.addWidget(button) layout_v.addWidget(button2) layout_h.addWidget(qpicamera2, 80) layout_h.addLayout(layout_v, 20) window.setWindowTitle("Qt Picamera2 App") window.resize(1200, 600) window.setLayout(layout_h) picam2.start() window.show() app.exec()
@byron I don't know for sure what the OP wants, but if it were my bird feeder camera, I would not need ANY gui, the pictures that are taken would be transferred to a computer via sneakernet where any post-processing would be done etc. However, the OP needs to tell us what his intentions are
First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.
I don't know for sure what the OP wants, but if it were my bird feeder camera, I would not need ANY gui, the pictures that are taken would be transferred to a computer via sneakernet where any post-processing would be done etc. However, the OP needs to tell us what his intentions are
Well maybe you wouldn't but then again perhaps you may change your mind. If the bird feeder camera was within wifi reach then you may consider it nice have a preview gui screen to enable you to enjoy looking at the birds from your lounge chair, and also to have a push button on the preview gui screen to take a picture when a blue tit flies in with a worm in its beak. Any nice birds (or other things to peer at) in your vicinity? 😀
Wouldn't any wifi capability have an adverse effect on the useful charge life of the battery ?
Anything seems possible when you don't know what you're talking about.
Sorry, I missed the part about a bird table, I thought we were still on game cameras.
If it's going to be that close, how about a long vacuum hose so that you can just suck the bird into the house for a closer look 🙂 🙂
Anything seems possible when you don't know what you're talking about.
@will, it all depends on the size of the birds. The blond bird accompanying the big blue tits may complain.
@will @byron From the original post
take pictures of wildlife in my yard.
some time later the specific use of on a birdfeeder might have been introduced by me, but that is still 'wildlife in my yard'.
First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.
I overlooked "wildlife in my yard" fair and square.
Anything seems possible when you don't know what you're talking about.
@emeyeraway PIN 17 is a 3.3V power pin. If that is what you used then the sketch will never work and maybe you damaged the PIR.
First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.
@zander @emeyeraway - physical pin number 17 is 3.3v but gpio pin 17 is physical pin 11. Usually when using the gpio libs its the gpio pin number that is used. It can be set that one uses the physical pin numbering so your cautionary post is wise, but I hope that in this case its gpio pin 17 (physical pin 11) that is being used. Theres better words to describe the numbering system, but I'm turning in for the night and not motivated to remember the correct terminology, but I hope you see what I'm getting at.
I'm using the BCM system, so pin 17 is not a 3.3v pin.
BTW, I have run the code you sent me successfully both while my raspi4 is connected directly to my monitor, and headlessly. But neither has affected "libcamera-hello" nor the subsequent running of the code either way. (And I'm just a little surprised that the ArduCam is cooperating!)
I'm currently working on naming the picture that's taken with the time it was taken. I have a snippet of code that produces just the time in pyQt5; I just need to figure out how to replace "test.jpg" with it.
I've done a bit of digging to learn where the TimeSensor output comes from in your code but haven't succeeded. I assume it's measuring the number of seconds since some date, but it can't be 1970 if my math is OK.
AFAIK the time sensor output should be seconds since 1970 per the libcamera docs (unix time), but perhaps the python api had modified it though I doubt it. Theres quite a bit to dig into, and as said, its all new to me. The demo program I copied, (and I should have saved it as per the example name, but i just called it test.py 🙄) is just a random example but interesting enough to get going with I guess.
It would be nice to find an example that enables all the parameters of the camera to be adjusted (there probably is one) and I envision having a program where one can set the desired camera options whilst looking at a preview screen, having the ability to save the parameters that are found best for the particular camera and where its situated as a config file, and to use that config to set up the camera if its being located where its not possible to look at a preview screen to make on the fly adjustments. But there a fair bit digging into the libcamera and the picamera2 docs before I get there. Much fun to come, but its not going to quick I fear.
Just in case it helps I give yet another version of the demo program that saves the file with a filename consisting of the date and time. See the extra function def file_name() and the following line in the function def on_buttion_clicked():
picam2.switch_mode_and_capture_file(cfg, file_name(), signal_function=qpicamera2.signal_done)
You may need amend the date/time format to your taste.
The new demo code:
#!/usr/bin/python3 # This example is essentially the same as app_capture.py, however here # we use the Qt signal/slot mechanism to get a callback (capture_done) # when the capture, that is running asynchronously, is finished. import time from PyQt5 import QtCore from PyQt5.QtWidgets import (QApplication, QHBoxLayout, QLabel, QPushButton, QVBoxLayout, QWidget) from picamera2 import Picamera2 from picamera2.previews.qt import QGlPicamera2 def file_name(): t = time.localtime() current_time = time.strftime("%Y%m%d %H:%M:%S", t) return current_time + ".jpg" def post_callback(request): label.setText(''.join(f"{k}: {v}\n" for k, v in request.get_metadata().items())) picam2 = Picamera2() picam2.post_callback = post_callback picam2.configure(picam2.create_preview_configuration(main={"size": (800, 600)})) app = QApplication([]) def on_button_clicked(): button.setEnabled(False) cfg = picam2.create_still_configuration() picam2.switch_mode_and_capture_file(cfg, file_name(), signal_function=qpicamera2.signal_done) def on_button2_clicked(): picam2.stop() app.quit() exit() def capture_done(job): picam2.wait(job) button.setEnabled(True) qpicamera2 = QGlPicamera2(picam2, width=800, height=600, keep_ar=False) button = QPushButton("Click to capture JPEG") button2 = QPushButton("Exit Program") label = QLabel() window = QWidget() qpicamera2.done_signal.connect(capture_done) button.clicked.connect(on_button_clicked) button2.clicked.connect(on_button2_clicked) label.setFixedWidth(400) label.setAlignment(QtCore.Qt.AlignTop) layout_h = QHBoxLayout() layout_v = QVBoxLayout() layout_v.addWidget(label) layout_v.addWidget(button) layout_v.addWidget(button2) layout_h.addWidget(qpicamera2, 80) layout_h.addLayout(layout_v, 20) window.setWindowTitle("Qt Picamera2 App") window.resize(1200, 600) window.setLayout(layout_h) picam2.start() window.show() app.exec()
Regarding the time for the file name, I should add it would probably be better to use the TimeSensor output that you mention, but I haven't look at grabbing it directly. Also, as the program already uses the qtPy5 event loop the time could be found by the following code snippet which I think was what your were referring to
from PyQt5 import QtCore as qtc def qt_time(): current_time = qtc.QDateTime.currentDateTime() return current_time.toString('dd/MM hh:mm') print(qt_time())