Image capturing with GPIO pin (Trigger a webcam with push button)

Hi I want to capture image with my webcam using GPIO from Jetson Nano. So when I run my python program, the webcam will turn on its video mode and once I press the button, the webcam will capture the image and saved inside my file. But it will not do nothing when I release the button. But there are some error with capturing code. So, do anyone have any suggestion for that? I have provided the code also. But it is still not correct and I am trying to improve on that. Welcome for suggestion.

ImageCaptuirng - Python Repl - Replit
https://projects-raspberry.com/trigger-a-webcam-with-a-button-and-raspberry-pi/

hello kmyat3116,

what’s the expectation when the button release? could you please share the failure for reference,
for your reference, here’s sample pipeline to enable webcam and take a snapshot.
$ gst-launch-1.0 v4l2src num-buffers=1 ! "video/x-raw, format=(string)UYVY, width=(int)1280, height=(int)800, framerate=(fraction)30/1" ! nvvidconv ! nvjpegenc ! filesink location=cam0.jpg

Thank you so much Jerry. I am also thinking about it. So let say if I use two push button? One used to capture and another push button to break the program. Can it be possible? But I don’t know how to write condition for these buttons. Do we have any sample code to follow? Open for any suggestion.

hello kmyat3116,

there’s argus_camera sample application to have button events. however, it doesn’t works with webcam.
you may enable 3rdparty application, such as cheese, to launch webcam through v4l2src.
note, you’ll need patches from Topic 168303 to include the fixes for libv4l2 on r32.5 release. thanks

Hi Jerry,
Could you please kindly show the link about argus_camera with button events? Because I am not sure which one to see. Thank you.

you’re working with webcam, right? argus_camera sample application doesn’t support with that.

Acutally I also have another camera mounted on my jetson nano. 8MP 160 degree fov camera.

hello kmyat3116,

there’s SDKManger installation process to include MMAPI,
you could manually install MMAPI as following, $ sudo apt-get install nvidia-l4t-multimedia
after that, you’ll see the Argus sources, for example, /home/nvidia/jetson_multimedia_api/argus/
thanks

ok so I have installed MMAPI and pointed argus folder. After that I don’t know how to proceed to next step. Could you help me with that? Thank you.

hello kmyat3116,

what’s your next step?
you may enable argus_camera sample application for demonstration. there’s README.TXT include the steps for building and installing.
thanks

Thank you. This is what I need. I will get back to you when I got confused.

I wrote the code that does image capturing with press button but there is an error called "This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings. Runtime Warning (Closing).

The connection is 3.3V to one end of push button,another end the signal pin, resistor to ground.