Home  |  Contents 

Microcontroller and PC projects
  Forum Index : Microcontroller and PC projects         Section
Subject Topic: OV7670 camera with movement detection Post ReplyPost New Topic
Message << Prev Topic | Next Topic >>

Joined: 11 December 2012
Location: United Kingdom
Online Status: Offline
Posts: 2622
Posted: 09 July 2018 at 11:48pm | IP Logged Quote matherp

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
  If a > pixels_affected And resetcount=0 Then
    Box 0,0,MM.HRes,20,,RGB(red),RGB(red)
    resetcount =3
  If resetcount<>0 Then resetcount=resetcount-1

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

Back to Top View matherp's Profile Search for other posts by matherp

Joined: 02 June 2014
Location: Germany
Online Status: Offline
Posts: 641
Posted: 10 July 2018 at 12:39am | IP Logged Quote twofingers

Hi Peter,

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

Kind regards
Back to Top View twofingers's Profile Search for other posts by twofingers
Senior Member
Senior Member

Joined: 18 March 2014
Location: Austria
Online Status: Offline
Posts: 112
Posted: 11 July 2018 at 6:39pm | IP Logged Quote PicFan


SUPER cool, very good job - thank you !

Back to Top View PicFan's Profile Search for other posts by PicFan

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Search the forums using Google.
Post ReplyPost New Topic
Printable version Printable version
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum

Powered by Web Wiz Forums version 7.8
Copyright ©2001-2004 Web Wiz Guide

This page was generated in 0.0938 seconds.
Privacy Policy     Process times : 0, 0, 0, 0.09