May-24-2019, 04:05 PM
Hi all,
I've written a Raspberry Pi application (Ubuntu Mate) that's essentially a timed camera. Every 30 seconds, it snaps an image and writes it to disk.
When I start the application manually from the terminal, it works as expected.
When I configure the script to execute automatically at startup, (using crontab or systemd - It needs to be executed as root) the script runs without any error, but no images are written to the disk.
Any idea of what may be going on?
My script:
The camera class:
My crontab:
I've written a Raspberry Pi application (Ubuntu Mate) that's essentially a timed camera. Every 30 seconds, it snaps an image and writes it to disk.
When I start the application manually from the terminal, it works as expected.
When I configure the script to execute automatically at startup, (using crontab or systemd - It needs to be executed as root) the script runs without any error, but no images are written to the disk.
Any idea of what may be going on?
My script:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
import time from camera import * import cv2 count = 0 while True : # Open camera Camera01.GiGe. Open () # Turn on Light Camera01.Light.fill(( 255 , 255 , 255 , 255 )) # Snap Image image = Camera01.GiGe.GrabOne( 1000 ) # Convert image to OpenCV Array image = cv2.cvtColor(image.Array, cv2.COLOR_BAYER_BG2BGR) # Save image to disk cv2.imwrite( 'saved_images/image' + str (count) + '.png' , image) # Turn off Light Camera01.Light.fill(( 0 , 0 , 0 , 0 )) # Close camera Camera01.GiGe.Close() # Increment counter count = count + 1 time.sleep( 30 ) |
1 2 3 4 5 6 7 |
import neopixel import board from pypylon import pylon class Camera01: GiGe = pylon.InstantCamera(pylon.TlFactory.GetInstance().CreateFirstDevice()) Light = neopixel.NeoPixel(board.D18, 16 , bpp = 4 , auto_write = True ) |
@reboot python3 /var/www/camera/main.py > /var/log/cron/crontab.log 2>&1