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

Install-Script issues #116

Closed will-code-for-pizza closed 2 years ago

will-code-for-pizza commented 2 years ago

On Rasberry Pi OS 32 Bit (Debian 11) the install script throws serveral issues...

The following packages have unmet dependencies:
  python-picamera : Depends on: python (>= 2.7)
                    Depends on: python (< 2.8)
                    Depends on: python-numpy but is not installable
E: Unable to correct problems, you have held defective packages.

---> should be 'python3-numpy' and 'python3-picamera'
Package python3-imaging is not available but is provided by another package
referenced. This can mean that the package is missing, that it has been detached
or is only available from another source.
However, the following packages replace it:
   python3-pil

E: There is no installation candidate for package 'python3-imaging'.
Package python-matplotlib is not available but is provided by another package
referenced. This can mean that the package is missing, that it has been detached
or is only available from another source.

E: There is no installation candidate for package 'python-matplotlib'.

---> should be 'python3-matplotlib'
will-code-for-pizza commented 2 years ago

And some serveral issues while trying to start speed-cam: (possibly related to the above errors..)

$ ./webserver.py 
/home/wartung/speed-camera/./webserver.py:172: SyntaxWarning: "is not" with a literal. Did you mean "!="?
  if not self.path is "/":   # Display folder Back arrow navigation if not in web root
/home/wartung/speed-camera/./webserver.py:197: SyntaxWarning: "is not" with a literal. Did you mean "!="?
  if (not self.path is "/") and display_entries > 35:   # Display folder Back arrow navigation if not in web root
Traceback (most recent call last):
  File "/home/wartung/speed-camera/./webserver.py", line 9, in <module>
    import SocketServer
ModuleNotFoundError: No module named 'SocketServer'

In Python3, module name is 'socketserver'

will-code-for-pizza commented 2 years ago

I have seen in your 'speed-install.sh' that you install python and python3 packages the hard way for default... Probably it would be better to catch the return code from an 'apt-get install' and do necessary actions after it... ?

will-code-for-pizza commented 2 years ago
$ ./webserver.py 
/home/wartung/speed-camera/./webserver.py:173: SyntaxWarning: "is not" with a literal. Did you mean "!="?
  if not self.path is "/":   # Display folder Back arrow navigation if not in web root
/home/wartung/speed-camera/./webserver.py:198: SyntaxWarning: "is not" with a literal. Did you mean "!="?
  if (not self.path is "/") and display_entries > 35:   # Display folder Back arrow navigation if not in web root
Traceback (most recent call last):
  File "/home/wartung/speed-camera/./webserver.py", line 14, in <module>
    from SimpleHTTPServer import SimpleHTTPRequestHandler
ModuleNotFoundError: No module named 'SimpleHTTPServer'

In Python3 module name is 'http.server'

will-code-for-pizza commented 2 years ago
$ ./webserver.py 
/home/wartung/speed-camera/./webserver.py:174: SyntaxWarning: "is not" with a literal. Did you mean "!="?
  if not self.path is "/":   # Display folder Back arrow navigation if not in web root
/home/wartung/speed-camera/./webserver.py:199: SyntaxWarning: "is not" with a literal. Did you mean "!="?
  if (not self.path is "/") and display_entries > 35:   # Display folder Back arrow navigation if not in web root
Traceback (most recent call last):
  File "/home/wartung/speed-camera/./webserver.py", line 16, in <module>
    from StringIO import StringIO
ModuleNotFoundError: No module named 'StringIO'

In Python3 module name is 'io' --> from io import StringIO

will-code-for-pizza commented 2 years ago

As I mentioned HERE I did a totally new deployment and discovered some issues here...

https://pastebin.com/9i9siRjS

Package python-imaging is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
  python-pil

E: Package 'python-imaging' has no installation candidate

Cause of this, I installed 'python-pil' manually, but it was already there.

To get pretty sure, I really have the latest plugins, I did

cd ~/speed-camera
cp config.py config.py.bak
cp config.py.new config.py
mv plugins pluginsold
./menubox.sh   --> UPGRADE --> Quit --> Reboot

I changed NOTHING in config.py and tried to start the speedcam. (the red LED on my RaspiCam 1.3 is enabled):

 ./speed-cam.py
----------------------------------------------------------------------
speed-cam.py 11.23  written by Claude Pageau
Motion Track Largest Moving Object and Calculate Speed per Calibration.
----------------------------------------------------------------------
Loading  Wait ...
2022-06-20 12:15:02 ERROR    <module>   Pi Camera Module Not Found supported=0 detected=0
2022-06-20 12:15:02 ERROR    <module>   if supported=0 Enable Camera per command sudo raspi-config
2022-06-20 12:15:02 ERROR    <module>   if detected=0 Check Pi Camera Module is Installed Correctly
2022-06-20 12:15:02 ERROR    <module>   speed-cam.py 11.23 Exiting Due to Error

I enabled the Raspi-Cam in raspi-config and rebooted the PI...

The red LED turned of and I started speed-cam again:

$ ./speed-cam.py
----------------------------------------------------------------------
speed-cam.py 11.23  written by Claude Pageau
Motion Track Largest Moving Object and Calculate Speed per Calibration.
----------------------------------------------------------------------
Loading  Wait ...
2022-06-20 12:19:50 INFO     <module>   Pi Camera Module is Enabled and Connected supported=1 detected=1
2022-06-20 12:19:58 INFO     <module>   Initializing Pi Camera ....
2022-06-20 12:20:01 INFO     show_settings Creating Image Storage Folder media/images
2022-06-20 12:20:01 INFO     show_settings Create Recent Folder media/recent
2022-06-20 12:20:01 INFO     show_settings Creating Search Folder media/search
2022-06-20 12:20:01 INFO     show_settings Creating html Folder media/html
----------------------------------------------------------------------
Note: To Send Full Output to File Use command
python -u ./speed-cam.py | tee -a log.txt
Set log_data_to_file=True to Send speed_Data to CSV File speed-cam.log
----------------------------------------------------------------------

Debug Messages .. verbose=True  display_fps=False calibrate=True
                  show_out_range=True
Plugins ......... pluginEnable=False  pluginName=picam240
Calibration ..... cal_obj_px_L2R=80 px  cal_obj_mm_L2R=4700 mm  speed_conv_L2R=0.21150
                  cal_obj_px_R2L=85 px  cal_obj_mm_R2L=4700 mm  speed_conv_R2L=0.19906
                  (Change Settings in /home/pi/speed-camera/config.py)
Logging ......... Log_data_to_CSV=False  log_filename=speed-cam.csv (CSV format)
                  loggingToFile=False  logFilePath=speed-cam.log
                  SQLITE3 DB_PATH=/home/pi/speed-camera/data/speed_cam.db  DB_TABLE=speed
Speed Trigger ... Log only if max_speed_over > 0 kph
                  and track_counter >= 6 consecutive motion events
Exclude Events .. If  x_diff_min < 1 or x_diff_max > 24 px
                  If  y_upper < 90 or y_lower > 150 px
                  or  x_left < 50 or x_right > 250 px
                  If  max_speed_over < 0 kph
                  If  event_timeout > 0.30 seconds Start New Track
                  track_timeout=0.50 sec wait after Track Ends (avoid retrack of same object)
Speed Photo ..... Size=960x720 px  image_bigger=3.0  rotation=0  VFlip=False  HFlip=False 
                  image_path=media/images  image_Prefix=speed-
                  image_font_size=12 px high  image_text_bottom=True
                  image_jpeg_quality=98  image_jpeg_optimize=True
Motion Settings . Size=320x240 px  px_to_kph_L2R=0.211500  px_to_kph_R2L=0.199059 speed_units=kph
                  CAM_LOCATION= None
OpenCV Settings . MIN_AREA=200 sq-px  BLUR_SIZE=10  THRESHOLD_SENSITIVITY=20  CIRCLE_SIZE=5 px
                  WINDOW_BIGGER=1 gui_window_on=False (Display OpenCV Status Windows on GUI Desktop)
                  CAMERA_FRAMERATE=22 fps video stream speed
Sub-Directories . imageSubDirMaxHours=0 (0=off)  imageSubDirMaxFiles=2000 (0=off)
                  imageRecentDir=media/recent imageRecentMax=100 (0=off)
Disk Space  ..... Disabled - spaceTimerHrs=0  Manage Target Free Disk Space. Delete Oldest jpg Files
                  spaceTimerHrs=0 (0=Off) Target spaceFreeMB=500 (min=100 MB)

----------------------------------------------------------------------
2022-06-20 12:20:01 WARNING  isSQLite3  File Not Found /home/pi/speed-camera/data/speed_cam.db
2022-06-20 12:20:01 INFO     isSQLite3  Create sqlite3 database File /home/pi/speed-camera/data/speed_cam.db
2022-06-20 12:20:01 INFO     isSQLite3  Success: Created sqlite3 Database /home/pi/speed-camera/data/speed_cam.db
2022-06-20 12:20:01 INFO     db_check   Success: sqlite3 Connected to DB /home/pi/speed-camera/data/speed_cam.db
2022-06-20 12:20:01 INFO     speed_camera sqlite3 DB is Open /home/pi/speed-camera/data/speed_cam.db
2022-06-20 12:20:01 INFO     speed_notify Plugin Disabled per pluginEnable=False
2022-06-20 12:20:01 INFO     speed_notify Logging to Console per Variable verbose=True
2022-06-20 12:20:01 INFO     speed_notify Press ctrl-c in this terminal session to Quit
2022-06-20 12:20:01 WARNING  speed_notify IMPORTANT: Camera Is In Calibration Mode ....
2022-06-20 12:20:01 INFO     speed_notify Begin Motion Tracking .....
2022-06-20 12:20:48 INFO     speed_camera Reset- event_timer 47.53>0.30 sec Exceeded
----------------------------------------------------------------------
2022-06-20 12:20:48 INFO     speed_camera New  - 0/6 xy(151,8) Start New Track

So it seems, everything is still fine with this project... Probably it depends on my personal config.py. I will report that.

Thanks a lot, Claude !

will-code-for-pizza commented 2 years ago

Closed