peterlite
Posts: 1049
Joined: Sun Apr 17, 2016 4:00 am

Dashcam with distance measurement by a Pi

Tue Jun 06, 2023 7:10 am

Dashcams are nice and the ones I looked at do not let you control anything useful. I would like 2K video 30 fps without massive compression damage. Plus distance measurement to the next car. A Pi would let me choose the storage sufficient for 8 hours or 108 hours or whatever I need.

Distance measurement can be done by stereoscopic measurements. Some models of Pi allow two cameras. Has anyone used that type of setup for measuring distances from 1 metre to about 200 metres? What model Pi? What camera model/resolution?

I am looking at the minimum Pi 4 as a starting point for development. I currently have a 2 GB. I also have a 3B and an old Zero. The new Zero 2 is not currently available. The 3B had speed limitations when I experimented with other video related software. The differences in cost are not significant when compared to dashcams with high resolution and significant storage. I prefer to have the flexibility to change storage and everything else at any time.

What software packages would I use? My programming experience covers almost every language except Python so any Python stuff would have to be simple. :D

peterlite
Posts: 1049
Joined: Sun Apr 17, 2016 4:00 am

Re: Dashcam with distance measurement by a Pi

Wed Jun 07, 2023 5:41 am

The following link requires external hardware, a HAT, to synchronize two cameras for microscopic comparison. A car depth measurement does not need the detail of synced clocks.
https://www.arducam.com/raspberry-pi-st ... -tutorial/

A car compared to the distant background should show up easily even without syncing camera clocks. Tye cameras can be set 200 mm or more apart for better depth measurement. The image frames will be within a 30th of a second.

The software would record the stream from one camera and periodically, say once per second, request a frame from the other stream. The second stream could be recorded for later analysis.The streams would need time coding for matching. I do not know what video file formats include time signals.

localacol
Posts: 1
Joined: Sat May 13, 2023 10:25 am

Re: Dashcam with distance measurement by a Pi

Sat Jun 10, 2023 7:12 pm

You can do this with a Pi connected to an Oak D or D Lite module. Unfortunately Python knowledge helps immensely with this.

* https://docs.luxonis.com/projects/hardw ... M9095.html

pidd
Posts: 4944
Joined: Fri May 29, 2020 8:29 pm
Location: Wirral, UK

Re: Dashcam with distance measurement by a Pi

Sat Jun 10, 2023 9:07 pm

peterlite wrote:
Wed Jun 07, 2023 5:41 am
A car depth measurement does not need the detail of synced clocks.
That is assuming the car in front is at a constant distance, if it is moving towards you or away you are going to have to be pretty tight on timing to get an accurate depth measurement.

I'm also trying to figure out how many pixels at 200m with a reasonably wide lens would say 1cm be?

A 90 degree arc at 200m would be 314m long which is 31400 times 1cm.

So divide your camera x pixel count by 31400 to get the pixel count for 1cm.

After that I'm a bit lost how to convert that into resolution for depth, heatwave not helping me think. I suspect the accuracy is not going to be good at that distance.

Rooksu
Posts: 11
Joined: Sun Mar 22, 2015 2:04 am

Re: Dashcam with distance measurement by a Pi

Mon Jun 12, 2023 9:48 pm

OP have you considered using methods other than stereoscope, or are you set on that for distances?

Instead of a second camera, you could use a purpose-built sensor like the Garmin LIDAR-Lite to calculate distances. This would save you a lot of Python.

If you want to calculate with stereoscope, one other project to look at is https://github.com/LearnTechWithUs/Stereo-Vision

peterlite
Posts: 1049
Joined: Sun Apr 17, 2016 4:00 am

Re: Dashcam with distance measurement by a Pi

Mon Jun 12, 2023 11:15 pm

The Lidar approach is interesting and the Garmin device version 4 is listed as having a range up to 10 metres, way to short. Lidar also works in only one direction. Without a machine to direct it, it could not follow a car overtaking you or continue to track a car as you go around a corner.

The link to the stereo software is excellent. I guess I have to learn Python despite it using whitespace as code delimiters.

ame
Posts: 7862
Joined: Sat Aug 18, 2012 1:21 am
Location: New Zealand

Re: Dashcam with distance measurement by a Pi

Mon Jun 12, 2023 11:31 pm

peterlite wrote:
Mon Jun 12, 2023 11:15 pm
I guess I have to learn Python despite it using whitespace as code delimiters.
What a drag.
Oh no, not again.

peterlite
Posts: 1049
Joined: Sun Apr 17, 2016 4:00 am

Re: Dashcam with distance measurement by a Pi

Tue Jun 13, 2023 4:12 am

Will be programming language 2? something, maybe 30+. Without counting major new versions.

Return to “Advanced users”