Skip to content

Commit

Permalink
release 6.00 Added optional free disk space and subdir creation features
Browse files Browse the repository at this point in the history
  • Loading branch information
pageauc committed Aug 11, 2017
1 parent 9a8d407 commit 1478b95
Show file tree
Hide file tree
Showing 6 changed files with 273 additions and 33 deletions.
23 changes: 15 additions & 8 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,21 @@

### For Details See [Speed Camera GitHub Wiki](https://github.com/pageauc/rpi-speed-camera/wiki)

* NEW: Added search-speed.py that uses opencv template matching to find similar images. To use,
copy one or more search image(s) to the default search folder media/search and run search-speed.py.
if the config.py variable copy_results_on=True then image match files including orignal search file
are copied to a subfolder with the same name as the search image filename but without the file extension.
If you set config.py gui_window_on=True a Searching and Target window will be displayed on the
RPI desktop. When a match is found it will be displayed for 4 seconds.
Results can also be reviewed from a web browser by running ./webserver.py and accessing link for search/subfolder
(Note: search-speed.py is still under development)
* 6.00 Added Optional SubDir creation by number of files or by SubDir Age
Also Added Disk Space Management that deletes oldest file in specified Dir Tree
to maintain a specified amount of Free disk space (default 500 MB)
Also added try, except, pass for loading of pi-camera libraries
This should allow speed-cam.py to work on Non RPI platforms with Web Cam eg Ubuntu or windows

* 5.00 Added search-speed.py that uses opencv template matching to find similar images. To use,
use menubox.sh menuing or command line to copy one or more search image(s) to the
default media/search folder and run search-speed.py.
if the config.py variable copy_results_on=True then image match files including orignal search file
are copied to a subfolder with the same name as the search image filename but without the file extension.
If you set config.py gui_window_on=True a Searching and Target window will be displayed on the
RPI desktop. When a match is found it will be displayed for 4 seconds.
Results can also be reviewed from a web browser by running ./webserver.py and accessing link for search/subfolder
(Note: search-speed.py is still under development)

* IMPORTANT: speed-cam.py release 5.x or above requires a full install.
It is advised that you rename/delete previous rpi-speed-camera folder
Expand Down
17 changes: 15 additions & 2 deletions config.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ---------------- User Configuration Settings for speed-cam.py ---------------------------------
# Ver 5.50 speed-cam.py 240p Stream Variable Configuration Settings
# Ver 6.00 speed-cam.py 240p Stream Variable Configuration Settings

#######################################
#
Expand Down Expand Up @@ -68,13 +68,26 @@
# ---------------------
image_path = "media/images" # folder name to store images
image_prefix = "speed-" # image name prefix
image_format = ".jpg" # default = ".jpg" image Formats .jpeg .png .gif .bmp
image_show_motion_area = True # True= Display motion detection rectangle area on saved images
image_filename_speed = False # True= Prefix filename with speed value
image_text_on = True # True= Show Text on speed images False= No Text on images
image_text_bottom = True # True= Show image text at bottom otherwise at top
image_font_size = 15 # Default = 15 Font text height in px for text on images
image_bigger = 2 # Default = 2 multiply saved speed image by value

image_max_files = 0 # 0=off or specify MaxFiles to maintain then oldest are deleted default=0 (off)

# Optional Manage SubDir Creation by time, number of files or both
# ----------------------------------------------------------------
imageSubDirMaxHours = 0 # 0=off or specify MaxHours - Creates New dated sub-folder if MaxHours exceeded
imageSubDirMaxFiles = 0 # 0=off or specify MaxFiles - Creates New dated sub-folder if MaxFiles exceeded

# Optional Manage Free Disk Space Settings
# ----------------------------------------
spaceTimerHrs = 0 # default= 0 0=off or specify hours frequency to perform free disk space check
spaceFreeMB = 500 # default= 500 Target Free space in MB Required.
spaceMediaDir = '/home/pi/rpi-speed-camera/media' # default= '/home/pi/rpi-speed-camera/media' Starting point for directory walk
spaceFileExt = 'jpg' # default= 'jpg' File extension to Delete Oldest Files

# Motion Event Exclusion Settings
# -------------------------------
Expand Down
17 changes: 15 additions & 2 deletions config.py.240
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ---------------- User Configuration Settings for speed-cam.py ---------------------------------
# Ver 5.50 speed-cam.py 240p Stream Variable Configuration Settings
# Ver 6.00 speed-cam.py 240p Stream Variable Configuration Settings

#######################################
#
Expand Down Expand Up @@ -68,13 +68,26 @@ CAMERA_HFLIP = False # Flip the camera image horizontally if required
# ---------------------
image_path = "media/images" # folder name to store images
image_prefix = "speed-" # image name prefix
image_format = ".jpg" # default = ".jpg" image Formats .jpeg .png .gif .bmp
image_show_motion_area = True # True= Display motion detection rectangle area on saved images
image_filename_speed = False # True= Prefix filename with speed value
image_text_on = True # True= Show Text on speed images False= No Text on images
image_text_bottom = True # True= Show image text at bottom otherwise at top
image_font_size = 15 # Default = 15 Font text height in px for text on images
image_bigger = 2 # Default = 2 multiply saved speed image by value

image_max_files = 0 # 0=off or specify MaxFiles to maintain then oldest are deleted default=0 (off)

# Optional Manage SubDir Creation by time, number of files or both
# ----------------------------------------------------------------
imageSubDirMaxHours = 0 # 0=off or specify MaxHours - Creates New dated sub-folder if MaxHours exceeded
imageSubDirMaxFiles = 0 # 0=off or specify MaxFiles - Creates New dated sub-folder if MaxFiles exceeded

# Optional Manage Free Disk Space Settings
# ----------------------------------------
spaceTimerHrs = 0 # default= 0 0=off or specify hours frequency to perform free disk space check
spaceFreeMB = 500 # default= 500 Target Free space in MB Required.
spaceMediaDir = '/home/pi/rpi-speed-camera/media' # default= '/home/pi/rpi-speed-camera/media' Starting point for directory walk
spaceFileExt = 'jpg' # default= 'jpg' File extension to Delete Oldest Files

# Motion Event Exclusion Settings
# -------------------------------
Expand Down
17 changes: 15 additions & 2 deletions config.py.720
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ---------------- User Configuration Settings for speed-cam.py ---------------------------------
# Ver 5.51 speed-cam.py 720p Stream Variable Configuration Settings
# Ver 6.00 speed-cam.py 720p Stream Variable Configuration Settings

#######################################
#
Expand All @@ -10,7 +10,7 @@
# Calibration Settings
# ===================
calibrate = True # Create a calibration image file with calibration hash markers 10 px per mark
cal_obj_px = 90 # Length of a calibration object in pixels
cal_obj_px = 310 # Length of a calibration object in pixels
cal_obj_mm = 4330.0 # Length of the calibration object in millimetres

# Crop Area for motion detection Tracking
Expand Down Expand Up @@ -74,6 +74,19 @@ image_text_on = True # True= Show Text on speed images False= No Text
image_text_bottom = True # True= Show image text at bottom otherwise at top
image_font_size = 20 # default = 20 Font text height in px for text on images
image_bigger = 1 # Default = 1 multiply saved speed image by value
image_max_files = 0 # 0=off or specify MaxFiles to maintain then oldest are deleted default=0 (off)

# Optional Manage SubDir Creation by time, number of files or both
# ----------------------------------------------------------------
imageSubDirMaxHours = 0 # 0=off or specify MaxHours - Creates New dated sub-folder if MaxHours exceeded
imageSubDirMaxFiles = 0 # 0=off or specify MaxFiles - Creates New dated sub-folder if MaxFiles exceeded

# Optional Manage Free Disk Space Settings
# ----------------------------------------
spaceTimerHrs = 0 # default= 0 0=off or specify hours frequency to perform free disk space check
spaceFreeMB = 500 # default= 500 Target Free space in MB Required.
spaceMediaDir = '/home/pi/rpi-speed-camera/media' # default= '/home/pi/rpi-speed-camera/media' Starting point for directory walk
spaceFileExt = 'jpg' # default= 'jpg' File extension to Delete Oldest Files

# Motion Event Exclusion Settings
# ===============================
Expand Down
9 changes: 7 additions & 2 deletions search-speed.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
crop_x_R = (x_right - 10) * image_bigger
crop_y_U = (y_upper + 10) * image_bigger
crop_y_D = (y_lower - 10) * image_bigger
blank = " "

#-----------------------------------------------------------------------------------------------
def print_at(x, y, text):
Expand Down Expand Up @@ -214,8 +215,12 @@ def search_for_match(search_image, search_rect):
(work_count, work_end - work_start, result_count))
return result_list

blank = " "
# Start Main
# ------------------- Start Main --------------------------------

if not os.path.isdir(search_dest_path):
print("Creating Search Folder %s" % ( search_dest_path))
os.makedirs(search_dest_path)

search_list = glob.glob(search_dest_path + '/*jpg')
target_total = len(search_list)
try:
Expand Down
Loading

0 comments on commit 1478b95

Please sign in to comment.