EbenKouao / pi-camera-stream-flask

Create your own live camera stream using a Raspberry Pi 4
MIT License
319 stars 125 forks source link

Rpi stream images to PC for image recognition #21

Open Aoi-00 opened 2 years ago

Aoi-00 commented 2 years ago

Hi! I chanced upon this project while looking for ways to link my rpi ( & pi camera) to send images continuously to my PC. The PC will then run image recognition and processing (yolov5) on it for my project.

However, most guides I came across shows the pi camera just streaming the feed to a website. Is it possible to send the images to a PC instead for processing? Is there a way I can edit your implementation for this use case? If not, are you able to provide any guidance or codes?

Thank you in advance and sorry for the trouble! Really cool project by the way!

Nichevo commented 2 years ago

What I did was to stream the images to a Dropbox account folder that is linked on my PC so then the images were immediately available. The Dropbox api is fairly simple.

Aoi-00 commented 2 years ago

Oh! Does this not mean your dropbox folder gets increasingly bigger in size as the stream goes on?

Nichevo commented 2 years ago

Yes, it will end up using dropbox space but I didn't find it too much of a problem. You can clear them out onto your PC to keep the dropbox not getting too full if that's a problem. If you are streaming large volumes of pictures it might not be ideal and you might be better creating a server connection.

Here is an example of the code which uploads to a dropbox account

import dropbox import re

TOKEN = 'asdfafdafasf'

dbx = dropbox.Dropbox(TOKEN)

print(dbx.users_get_current_account())

sfilename = 'dropboxuploadtest3.py' spath = '/Users/PythonProjects/' sfile = spath + sfilename

stopath = '/' + sfilename with open(sfile, "rb") as f: dbx.files_upload(f.read(), stopath, mode=dropbox.files.WriteMode("overwrite"))

sstorefile = 'piclist.csv' with open(spath + sstorefile,'a') as file: file.write(sfilename + ',')

stopath = '/' + sstorefile sfile = spath + sstorefile with open(sfile, "rb") as f: dbx.files_upload(f.read(), stopath, mode=dropbox.files.WriteMode("overwrite"))