Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 17:01 11 Nov 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : OV7670 camera with movement detection

Author Message
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10570
Posted: 01:48pm 09 Jul 2018
Copy link to clipboard 
Print this post

The MMX supports the OV7670 camera module but doesn't have enough memory to hold a memory image such that a new image can be compared to the stored one to look for movement. The STM32H743 running the Armmite firmware does (640x480x2 bytes):

Watch the demo

I'll post the new firmware on the Armmite thread when I have tidied it up. The birdsnest is impossible to tidy up





The way the detection works is as follows:

An image is captured from the camera in RGB565 and stored in memory .
As the next image is read, both it and the stored image are converted to greyscale and the pixels compared. If the difference between the stored pixel and the new one is greater than a user settable parameter (sensitivity in the example program) then a count is incremented. Once the new image is complete the count of differences is returned to Basic and the user can then take an appropriate action. The resetcount parameter controls how often movement will trigger an action - in this case 3 compare cycles.

In the demo the action is just to flash a red banner on the screen as I waggle a wire or my finger in front of the camera, but it could store the image to disk or sound an alarm etc.

The Basic code is simplicity itself:

dim integer resetcount=0
dim integer sensitivity = 7
dim pixels_affected=1000
Camera open
Pause 5000 'allow time for AGC to work
Camera capture
Do
a=MOVEMENT(sensitivity)
If a > pixels_affected And resetcount=0 Then
Box 0,0,MM.HRes,20,,RGB(red),RGB(red)
resetcount =3
EndIf
If resetcount<>0 Then resetcount=resetcount-1
Loop


The time to read in an image and compare it with the stored version is approximately 250mSec



 
twofingers

Guru

Joined: 02/06/2014
Location: Germany
Posts: 1671
Posted: 02:39pm 09 Jul 2018
Copy link to clipboard 
Print this post

Hi Peter,

very cool and useful. I'll try when I get my STM32H743 boards. Thanks a lot!

Kind regards
causality ≠ correlation ≠ coincidence
 
PicFan
Senior Member

Joined: 18/03/2014
Location: Austria
Posts: 133
Posted: 08:39am 11 Jul 2018
Copy link to clipboard 
Print this post

@matherp

SUPER cool, very good job - thank you !


Wolfgang
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025