pageauc / speed-camera

A Unix, Windows, Raspberry Pi Object Speed Camera using python, opencv, video streaming, motion tracking. Includes a Standalone Web Server Interface, Image Search using opencv template match and a whiptail Admin Menu Interface Includes picam and webcam Plugins for motion track security camera configuration including rclone sync script. watch-app allows remotely controller camera configuration from a remote storage service name. Uses sqlite3 and gnuplot for reporting. Recently added openalpr license plate reader support.
Apache License 2.0
987 stars 173 forks source link

Upload speed image to server via FTP #125

Closed waubain closed 1 year ago

waubain commented 1 year ago

I am new to Python(I work mostly in PHP). I can upload a file saved in the images folder via FTP to my web server using this code.

import ftplib
import os

FTP_HOST = "myserver.com"
FTP_USER = "username"
FTP_PASS = "password"
from_path = 'speed-camera/media/images/'
filename = 'speed-20221222-131530.jpg' 

ftp = ftplib.FTP(FTP_HOST, FTP_USER, FTP_PASS)

ftp.cwd('public_html/speed-images/')

image_file = open(os.path.join(from_path, filename), 'rb')
ftp.storbinary('STOR {filename}', image_file)

image_file.close
ftp.quit()

I would like to have the image saved directly to my web server in addition to the images folder. It is unclear to me how I would go about doing this in speed-cam.py.

Any hints would be appreciated.

pageauc commented 1 year ago

You should add your code to user_motion_code.py. See comments in code.

https://github.com/pageauc/speed-camera/blob/master/user_motion_code.py

Various variables are passed to the function including the filenamePath. You would need to extract the filename without the path. Example below

filenameOnly = os.path.basename(filenamePath)

user_motion_code.py will automatically get executed when a speed camera image is triggered.

Let me know if this answers your question Merry Christmas Claude ...

On Thu, Dec 22, 2022 at 4:19 PM waubain @.***> wrote:

I am new to Python(I work mostly in PHP). I can upload a file saved in the images folder via FTP to my web server using this code.

import ftplib import os

FTP_HOST = "myserver.com" FTP_USER = "username" FTP_PASS = "password" from_path = 'speed-camera/media/images/' filename = 'speed-20221222-131530.jpg'

ftp = ftplib.FTP(FTP_HOST, FTP_USER, FTP_PASS)

ftp.cwd('public_html/speed-images/')

image_file = open(os.path.join(from_path, filename), 'rb') ftp.storbinary('STOR {filename}', image_file)

image_file.close ftp.quit()

I would like to have the image saved directly to my web server in addition to the images folder. It is unclear to me how I would go about doing this in speed-cam.py.

Any hints would be appreciated.

— Reply to this email directly, view it on GitHub https://github.com/pageauc/speed-camera/issues/125, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABNPKZBN2P5A2ROK44AAHXDWOTHVZANCNFSM6AAAAAATHFKVWE . You are receiving this because you are subscribed to this thread.Message ID: @.***>

-- YouTube Channel at https://www.youtube.com/user/pageaucp http://www.youtube.com/user/pageaucp GitHub Repository at https://github.com/pageauc

pageauc commented 1 year ago

FYI rclone also supports FTP. Speed camera installs rclone python library by default. For details see

https://rclone.org/ftp/

Also see speed camera sample shell scripts and the speed camera wiki entry Claude ..

On Thu, Dec 22, 2022 at 7:53 PM Claude Pageau @.***> wrote:

You should add your code to user_motion_code.py. See comments in code.

https://github.com/pageauc/speed-camera/blob/master/user_motion_code.py

Various variables are passed to the function including the filenamePath. You would need to extract the filename without the path

per filenameOnly = os.path.basename(filenamePath)

user_motion_code.py will automatically get executed when a speed camera is triggered.

Let me know if this answers your question Merry Christmas Claude ...

On Thu, Dec 22, 2022 at 4:19 PM waubain @.***> wrote:

I am new to Python(I work mostly in PHP). I can upload a file saved in the images folder via FTP to my web server using this code.

import ftplib import os

FTP_HOST = "myserver.com" FTP_USER = "username" FTP_PASS = "password" from_path = 'speed-camera/media/images/' filename = 'speed-20221222-131530.jpg'

ftp = ftplib.FTP(FTP_HOST, FTP_USER, FTP_PASS)

ftp.cwd('public_html/speed-images/')

image_file = open(os.path.join(from_path, filename), 'rb') ftp.storbinary('STOR {filename}', image_file)

image_file.close ftp.quit()

I would like to have the image saved directly to my web server in addition to the images folder. It is unclear to me how I would go about doing this in speed-cam.py.

Any hints would be appreciated.

— Reply to this email directly, view it on GitHub https://github.com/pageauc/speed-camera/issues/125, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABNPKZBN2P5A2ROK44AAHXDWOTHVZANCNFSM6AAAAAATHFKVWE . You are receiving this because you are subscribed to this thread.Message ID: @.***>

-- YouTube Channel at https://www.youtube.com/user/pageaucp http://www.youtube.com/user/pageaucp GitHub Repository at https://github.com/pageauc

-- YouTube Channel at https://www.youtube.com/user/pageaucp http://www.youtube.com/user/pageaucp GitHub Repository at https://github.com/pageauc

waubain commented 1 year ago

I stayed with your first option. The code was the most logical to me. We are having blizzard conditions here in the Midwest with cold and high winds. No one is out driving (a good thing). I had to wait awhile for a car to go by to test it out. Thank you for the information. Have a Merry Christmas and a great New Year.

Bob

On Fri, Dec 23, 2022 at 9:12 AM Claude Pageau @.***> wrote:

FYI rclone also supports FTP. Speed camera installs rclone python library by default. For details see

https://rclone.org/ftp/

Also see speed camera sample shell scripts and the speed camera wiki entry Claude ..

On Thu, Dec 22, 2022 at 7:53 PM Claude Pageau @.***> wrote:

You should add your code to user_motion_code.py. See comments in code.

https://github.com/pageauc/speed-camera/blob/master/user_motion_code.py

Various variables are passed to the function including the filenamePath. You would need to extract the filename without the path

per filenameOnly = os.path.basename(filenamePath)

user_motion_code.py will automatically get executed when a speed camera is triggered.

Let me know if this answers your question Merry Christmas Claude ...

On Thu, Dec 22, 2022 at 4:19 PM waubain @.***> wrote:

I am new to Python(I work mostly in PHP). I can upload a file saved in the images folder via FTP to my web server using this code.

import ftplib import os

FTP_HOST = "myserver.com" FTP_USER = "username" FTP_PASS = "password" from_path = 'speed-camera/media/images/' filename = 'speed-20221222-131530.jpg'

ftp = ftplib.FTP(FTP_HOST, FTP_USER, FTP_PASS)

ftp.cwd('public_html/speed-images/')

image_file = open(os.path.join(from_path, filename), 'rb') ftp.storbinary('STOR {filename}', image_file)

image_file.close ftp.quit()

I would like to have the image saved directly to my web server in addition to the images folder. It is unclear to me how I would go about doing this in speed-cam.py.

Any hints would be appreciated.

— Reply to this email directly, view it on GitHub https://github.com/pageauc/speed-camera/issues/125, or unsubscribe < https://github.com/notifications/unsubscribe-auth/ABNPKZBN2P5A2ROK44AAHXDWOTHVZANCNFSM6AAAAAATHFKVWE

. You are receiving this because you are subscribed to this thread.Message ID: @.***>

-- YouTube Channel at https://www.youtube.com/user/pageaucp http://www.youtube.com/user/pageaucp GitHub Repository at https://github.com/pageauc

-- YouTube Channel at https://www.youtube.com/user/pageaucp http://www.youtube.com/user/pageaucp GitHub Repository at https://github.com/pageauc

— Reply to this email directly, view it on GitHub https://github.com/pageauc/speed-camera/issues/125#issuecomment-1364031608, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHDABHQNHJLDUHA4NOYMVN3WOW6O5ANCNFSM6AAAAAATHFKVWE . You are receiving this because you authored the thread.Message ID: @.***>

pageauc commented 1 year ago

Hi Bob.

I would be interested in what web server type/ver and the speed code base you are using for the web server eg PHP, HTML, CSS, Java, etc Would it be possible to zip an example or supply link and send to me. I can give you my email address Have a Happy New Year Claude ...

waubain commented 1 year ago

Hi Claude, I use a hosting site with a shared Linux server. I am running the speed code on a PC with Windows 10. I use an IP camera mounted above my garage door. I think it is a little too far from the road I am a retired hospital pharmacist, with an interest in agriculture and weather. I have a website displaying data, combining data from both of those. My programming skills are beginner level and mostly everything I do is from manipulating examples I find on the web. My site is HTML, CSS, PHP and some Javascript (of the plain vanilla type) . All data is stored on a MySQL database on the hosted server.

I am going to store the images from the "speed-camera" program on my site, where only I can see, but the speed data, will be stored in a table and displayed on a web page similar to the images page on my site.

If you send me your email address I can send you the URL to my site. If you see something of interest I can send you a zip file.

On Tue, Dec 27, 2022 at 5:19 AM Claude Pageau @.***> wrote:

Hi Bob.

I would be interested in what web server type/ver and the speed code base you are using for the web server eg HTML, CSS, Java, etc Would it be possible to zip an example or supply link and send to me. I can give you my email address Have a Happy New Year Claude ...

— Reply to this email directly, view it on GitHub https://github.com/pageauc/speed-camera/issues/125#issuecomment-1365829136, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHDABHUA4U2CIR2ZBIAAYH3WPLGD3ANCNFSM6AAAAAATHFKVWE . You are receiving this because you authored the thread.Message ID: @.***>

pageauc commented 1 year ago

Everyone learns from others and most developers build a certain amount from other open source code or examples. Libraries a just shared code with good API structures for others to use. I like you FTP example.

Later on you may get an idea of your own and develop your own solution. That is fun for me.

My Email address is

@.***

zip file would be appreciated.

Thanks Claude ...

On Wed, Dec 28, 2022 at 9:01 AM Bob Shaw @.***> wrote:

Hi Claude, I use a hosting site with a shared Linux server. I am running the speed code on a PC with Windows 10. I use an IP camera mounted above my garage door. I think it is a little too far from the road I am a retired hospital pharmacist, with an interest in agriculture and weather. I have a website displaying data, combining data from both of those. My programming skills are beginner level and mostly everything I do is from manipulating examples I find on the web. My site is HTML, CSS, PHP and some Javascript (of the plain vanilla type) . All data is stored on a MySQL database on the hosted server.

I am going to store the images from the "speed-camera" program on my site, where only I can see, but the speed data, will be stored in a table and displayed on a web page similar to the images page on my site.

If you send me your email address I can send you the URL to my site. If you see something of interest I can send you a zip file.

On Tue, Dec 27, 2022 at 5:19 AM Claude Pageau @.***> wrote:

Hi Bob.

I would be interested in what web server type/ver and the speed code base you are using for the web server eg HTML, CSS, Java, etc Would it be possible to zip an example or supply link and send to me. I can give you my email address Have a Happy New Year Claude ...

— Reply to this email directly, view it on GitHub < https://github.com/pageauc/speed-camera/issues/125#issuecomment-1365829136 , or unsubscribe < https://github.com/notifications/unsubscribe-auth/AHDABHUA4U2CIR2ZBIAAYH3WPLGD3ANCNFSM6AAAAAATHFKVWE

. You are receiving this because you authored the thread.Message ID: @.***>

— Reply to this email directly, view it on GitHub https://github.com/pageauc/speed-camera/issues/125#issuecomment-1366713993, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABNPKZDMGZPK43PQ24FV6GDWPRI6BANCNFSM6AAAAAATHFKVWE . You are receiving this because you commented.Message ID: @.***>

-- YouTube Channel at https://www.youtube.com/user/pageaucp http://www.youtube.com/user/pageaucp GitHub Repository at https://github.com/pageauc

waubain commented 1 year ago

Claude, Github seems to be encrypting all the email addresses. Can you send me a message through my profile at GitHub? Bob

On Wed, Dec 28, 2022 at 5:54 PM Claude Pageau @.***> wrote:

Everyone learns from others and most developers build a certain amount from other open source code or examples. Libraries a just shared code with good API structures for others to use. I like you FTP example.

Later on you may get an idea of your own and develop your own solution. That is fun for me.

My Email address is

@.***

zip file would be appreciated.

Thanks Claude ...

On Wed, Dec 28, 2022 at 9:01 AM Bob Shaw @.***> wrote:

Hi Claude, I use a hosting site with a shared Linux server. I am running the speed code on a PC with Windows 10. I use an IP camera mounted above my garage door. I think it is a little too far from the road I am a retired hospital pharmacist, with an interest in agriculture and weather. I have a website displaying data, combining data from both of those. My programming skills are beginner level and mostly everything I do is from manipulating examples I find on the web. My site is HTML, CSS, PHP and some Javascript (of the plain vanilla type) . All data is stored on a MySQL database on the hosted server.

I am going to store the images from the "speed-camera" program on my site, where only I can see, but the speed data, will be stored in a table and displayed on a web page similar to the images page on my site.

If you send me your email address I can send you the URL to my site. If you see something of interest I can send you a zip file.

On Tue, Dec 27, 2022 at 5:19 AM Claude Pageau @.***> wrote:

Hi Bob.

I would be interested in what web server type/ver and the speed code base you are using for the web server eg HTML, CSS, Java, etc Would it be possible to zip an example or supply link and send to me. I can give you my email address Have a Happy New Year Claude ...

— Reply to this email directly, view it on GitHub <

https://github.com/pageauc/speed-camera/issues/125#issuecomment-1365829136

, or unsubscribe <

https://github.com/notifications/unsubscribe-auth/AHDABHUA4U2CIR2ZBIAAYH3WPLGD3ANCNFSM6AAAAAATHFKVWE

. You are receiving this because you authored the thread.Message ID: @.***>

— Reply to this email directly, view it on GitHub < https://github.com/pageauc/speed-camera/issues/125#issuecomment-1366713993 , or unsubscribe < https://github.com/notifications/unsubscribe-auth/ABNPKZDMGZPK43PQ24FV6GDWPRI6BANCNFSM6AAAAAATHFKVWE

. You are receiving this because you commented.Message ID: @.***>

-- YouTube Channel at https://www.youtube.com/user/pageaucp http://www.youtube.com/user/pageaucp GitHub Repository at https://github.com/pageauc

— Reply to this email directly, view it on GitHub https://github.com/pageauc/speed-camera/issues/125#issuecomment-1366986913, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHDABHS7BPRUP43HC2AQFC3WPTHMHANCNFSM6AAAAAATHFKVWE . You are receiving this because you authored the thread.Message ID: @.***>