1

I have a raspberry pi on which I am executing a python script. This script has a while loop with the following statement in it

os.system('sudo raspistill -o img' + str(counter) +'.jpg')

This loop executes a 100 times and is supposed to take a hundred pictures (the counter number is incremented each time a picture is taken). I have verified that this code is working perfectly and the folder contains 100 pictures.

I added a background thread to execute in parallel. As soon as the main program snaps a picture and puts it in a folder, this thread copies this picture into another directory using the following command

os.system('sudo cp ' + sourceFilePath + ' ' + destinationFilepath)

However, with this copying thread on, some of the pictures seem to be completely black (and the size is really small, around 150kb). Does anyone know what is going on?

NOTE: Due to some reason, I have to use the os.system('sudo raspistill -o ') command. I can not use the picamera library

Umar Dastgir
  • 688
  • 9
  • 25
  • Is the only purpose of the thread to copy the pictures to other place?, – Cheche Nov 15 '18 at 02:00
  • @Cheche Yes. For some reason, I have to copy the pics to the other place as soon as they get taken by the Camera – Umar Dastgir Nov 15 '18 at 02:01
  • Can't you just store them in the other folder `os.system('sudo raspistill -o img' + '\home\pics\' + str(counter) + '.jpg')`?,... seems you're patching some issue with you raspberry making something that won't be efficient at all... – Cheche Nov 15 '18 at 02:03
  • Unfortunately, I can not. Storing at this other location takes a lot more time and I have a time constraint (max time between two pictures should be less than a particular value). – Umar Dastgir Nov 15 '18 at 02:09
  • Ok, understand. What about a queue? The point is that `thread` is not convenient on certain kind of processes because python will still be single-threaded. – Cheche Nov 15 '18 at 02:15

0 Answers0