Comments (9)
from speed-camera.
Hi Claude,
Many thanks for the quick and in-depth reply. I will investigate the SQL option and cloud storage options. What I will probably do is use your example sql query (thank you), and convert the resultset into json for a curl call to input to elasticsearch for now. That is probably easiest.
Not sure what you mean by calculate speeds differently on direction. Currently there is only one calibration for both directions. Not sure if you want separate calibration settings for L2R and R2L or different unit of speed like ft/sec. Needs more explaining.
By this I mean the direction of travel. Folks going Southbound on my camera at 10 pixels smaller than those going Northbound. I would like to be able to set the calculations correspondingly, for example:
L2R = 45
R2L = 55
I am noticing that when I get friends to drive past at 40mph, the closest lane readings are about 10mph over the furthest lane readings. I presume this is explained by the difference in reality vs pixel size?
The DB facilities in the system are already great. What I am trying to do is summarise a number of camera locations in one page. This is what I have so far. This dashboard is showing data from one camera. Once the other cameras are placed around the village, it will be interesting to watch the dataset grow over time.
Cheers,
Richie
from speed-camera.
from speed-camera.
from speed-camera.
Hi Claude,
I've tested it. Unfortunately, it stops working after one capture. Please see output below:
pi@pi5:~/speed-camera $ ./speed-cam.py
Loading ...
----------------------------------------------------------------------
speed-cam.py 9.20 written by Claude Pageau
----------------------------------------------------------------------
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=False
show_out_range=True
Plugins ......... pluginEnable=False pluginName=picam720
Calibration ..... cal_obj_px_L2R=60 px cal_obj_mm_L2R=5182 mm speed_conv_L2R=0.19320
cal_obj_px_R2L=75 px cal_obj_mm_R2L=5182 mm speed_conv_R2L=0.15456
(Change Settings in /home/pi/speed-camera/config.py)
Logging ......... Log_data_to_CSV=True log_filename=speed-cam.csv (CSV format)
loggingToFile=True 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 > 10 mph
and track_counter >= 10 consecutive motion events
Exclude Events .. If x_diff_min < 1 or x_diff_max > 20 px
If y_upper < 130 or y_lower > 180 px
or x_left < 20 or x_right > 300 px
If max_speed_over < 10 mph
If event_timeout > 0.30 seconds Start New Track
track_timeout=0.00 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
Motion Settings . Size=320x240 px px_to_kph_L2R=0.310920 px_to_kph_R2L=0.248736 speed_units=mph
OpenCV Settings . MIN_AREA=100 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=20 fps video stream speed
Sub-Directories . imageSubDirMaxHours=0 (0=off) imageSubDirMaxFiles=1000 (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)
----------------------------------------------------------------------
Logging to File speed-cam.log (Console Messages Disabled)
Traceback (most recent call last):
File "./speed-cam.py", line 1466, in <module>
speed_camera() # run main speed camera processing loop
File "./speed-cam.py", line 1268, in speed_camera
% (quote,
NameError: global name 'quote' is not defined
Oh, and I've almost got the sqlite3 => elasticsearch finished. Tomorrow... I'll share it after some zzzz :D
Have a good day!
Cheers,
Richie
from speed-camera.
Hi Claude,
I think I've found it - this line was missing:
quote = '"' # Used for creating quote delimited log file of speed data
Waiting for a car at 1.30am ;)
...
...
Just had one - and it worked :)
Cheers,
Richie
from speed-camera.
Btw - this is what I have so-far:
import simplejson
import sqlite3
import time
import sys
import os
import hashlib
import requests
import urllib3
import socket
from subprocess import check_output
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
DB_PATH = '/home/pi/speed-camera/data/speed_cam.db'
DB_TABLE = 'speed'
REPORT_QUERY = ('''select * from speed''')
IP_ADDRESS = check_output(['hostname', '--all-ip-addresses']).strip()
def Main():
connection = sqlite3.connect(DB_PATH)
connection.row_factory = sqlite3.Row
cursor = connection.cursor()
cursor.execute(REPORT_QUERY)
while True:
row = cursor.fetchone()
if row is None:
break
unique_hash = hashlib.sha1(str(tuple(row)) + IP_ADDRESS).hexdigest()
if row["direction"] == "L2R":
direction = "Southbound"
else:
direction = "Northbound"
record = {
'@timestamp' : make_date(row["log_date"]) + "T" + row["log_hour"] + ":" + row["log_minute"] + ":00",
'speed' : row["ave_speed"],
'direction' : direction,
'source' : IP_ADDRESS
}
#print(repr(record))
url = 'https://172.24.42.100:9243/chailey-' + IP_ADDRESS + '-' + make_date(row["log_date"]) + '/record/'+unique_hash
resp = requests.post(url,auth=('elastic','yF1PQEh8AfiMquEG0sSW'),verify=False,json=record)
print(unique_hash + ": " + str(resp.status_code))
last_date = "log_date"
cursor.close()
connection.close
def make_date(string):
string = string[:4] + '-' + string[4:]
return string[:7] + '-' + string[7:]
if __name__ == "__main__":
Main()
from speed-camera.
from speed-camera.
Hi Claude,
Many many thanks. I am testing at the moment. I will let you know how it goes.
I've put my speedcam2es into: https://github.com/richiejarvis/speedcam2es
I'll report back once I have more updates.
Cheers,
Richie
from speed-camera.
Related Issues (20)
- Improvement: Majority Vote for Direction? --- Tracking seems to use "direction" of last track event to set direction of overall track - conflicts if last track mis-identifies direction HOT 5
- Cannot run speed-cam.py - states "Could not import cv2 library" HOT 8
- No Window to view camera HOT 6
- Windows not displaying on host machine HOT 1
- Clarification on calibration HOT 4
- Frames dropped due to contour out of bounds? HOT 2
- Docker Install always 11.22 HOT 1
- Calibration with different Screen Ratio and Framerate HOT 1
- No detections or speed calcs HOT 2
- No images
- How do I manually trigger the camera? HOT 4
- Can I reposition calibration marks? HOT 1
- Capture being triggered by small objects and missing all vehicles. HOT 1
- Warnings in startup log: "Unsupported V4L2 pixel format" HOT 1
- Vehicles at higher speeds being missed. HOT 4
- search-speed / Not compatible with the major rewrite? HOT 2
- Bigger resolution - `picam720` plugin - `speed_camera Out - 0/6` messages HOT 1
- Vehicles detected twice: Ideal `MO_TRACK_EVENT_COUNT`
- `MO_MIN_AREA_PX` is not the area of the rectangle
- Capture video HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from speed-camera.