RPI Camera using Fedora 31

Hi all-

I have added the camera module to my RPI3 for a time-lapse project. The RPI is headless, running Fedora 31 and the plan is to have it take a pic, then send it to a remote server where I can work with it.

I’m having a hard time getting the camera to take a pic. I’ve installed fswebcam, and running a simple capture like fswebcam -v -d /dev/video0 foo.jpg results in a lot of output (because of the -v) that indicates that it finds the camera on /dev/video0, and the light on the camera module turns on, but then it just hangs. And hangs hard; the process cannot be kill -9’ed and the whole pi needs to be rebooted (sometimes it locks to the point I have to pull the power).

Has anyone successfully used the RPI camera with Fedora? If so, what did you use?

Thanks,

Ron

1 Like

According to this you need to edit /boot/efi/config.txt and adjust the gpu_mem setting to be gpu_mem=80 .

I don’t know if it’s of use to you, but I’ve done exactly what you describe, but using Raspbian on the Pi and only the remote server was (is) running Fedora 31. Here’s how I did it in case it’s useful to you or anyone else reading later. All but one line in the pi script shown below could be identical.

Software on the Pi

I first wrote a simple script to capture a single still image and write it to a particular directory on the pi and then set up cron to run it every minute.

takephoto.sh

#!/bin/bash
DATE=$(date +"%F_%H%M")
# the following line would need to be changed for a Pi running Fedora
raspistill -n -o /home/pi/stills/$DATE.jpg

Code running on the Fedora server

I have ssh set up on the server with key-based access. This means that the communications to the server is secure and there is no need to put any server password on the pi. I won’t cover how to set all that up, but it’s well documented elsewhere.

I then have a script set up to run hourly via cron on the server. It fetches all of the still photos from the pi and then deletes them from the pi. I do that because it’s a lowly Pi Zero W without a lot of storage to spare.

movem.sh

#!/bin/bash
rsync --remove-source-files -aze 'ssh -i /home/me/picam_privkey'  pi@picam:/home/pi/stills /home/me/picam/.
for fn in /home/me/picam/stills/*.jpg; do /home/me/picam/annotate.sh $fn; done

As you can see, the remote machine is called picam and its private key is stored as picam_privkey. I didn’t want sensitive data on the Pi, but having credentials for the Pi on the server was not a security issue for me. The script above uses rsync to grab all of the files and delete them. Then each file is processed individually by another script on the server which is below.

annotate.sh

#!/bin/bash
stem=${1##*/}
stem="${stem%.*}"
outfile="/home/me/picam/small/$stem.jpg"
convert "$1" -resize 820x616 -fill yellow -gravity South -annotate +0+5 "$stem" "$outfile"
rm "$1"

This just picks up each picture from the stills directory, creates a visible timestamp based on the file name, puts the annotated file in the small directory, and then deletes the source file from stills. The timestamping is done with convert which is part of the excellent ImageMagick package.

Finally, I wanted to make a movie from the still pictures, so I wrote another script to do that. In my case, I run this manually because I usually just use the whole setup to capture a particular event and then shut it down again. Here’s that script:

movie.sh

#!/bin/bash
cat /home/me/picam/small/*.jpg | ffmpeg -y -f image2pipe -r 1 -vcodec mjpeg -i - -vcodec libx264 /home/me/picam/out.mp4
#ncftpput -f /home/me/picam/host.cfg public_html/pictures /home/me/picam/out.mp4

This creates a movie of the whole event uncreatively called out.mp4. The commented out line was to upload the file via FTP to a web site I operate.

Naturally these simple scripts have a lot of hardcoded file names and locations, so you’d have to modify them to work. If I had thought more about it, I might have made them a little more flexible, but they work for me as is, and perhaps they’ll be of some inspiration to you.

3 Likes

Ah ha! This was the missing part; on your suggestion I changed gpu_mem=80 and sure enough fswebcam worked perfectly.

Thanks for your fantastic writeup; I am basically copying what you did and this is an awesome guide to use, the only difference is that I’ll now be able to use Fedora on the Pi as well as the server. :slight_smile:

2 Likes

Glad to hear it worked! I learned something too. I hadn’t even thought about running Fedora on a Pi, but I might try that now.

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.