Taking snapshot immediately.

Discussion related to "under the hood" OpenMV topics.
jimmie
Posts: 22
Joined: Wed Aug 21, 2019 11:22 pm

Taking snapshot immediately.

Postby jimmie » Sun Sep 01, 2019 4:34 am

I have been testing the "Snapshot on Movement" example outdoors.

The program works but the snapshot is executed after a relatively long time even though the motion itself is very pronounced (big object passing in front of lens).

How can I execute a snapshot IMMEDIATELY upon detecting a pronounced motion?

Thanks in advance.
User avatar
iabdalkader
Posts: 1143
Joined: Sun May 24, 2015 3:53 pm

Re: Taking snapshot immediately.

Postby iabdalkader » Sun Sep 01, 2019 12:08 pm

The example saves the image after detecting 10 frames of motion, try this:

Code: Select all

    while(True):
        img = sensor.snapshot()
        img.difference("temp/bg.bmp")
        stats = img.statistics()
        if (stats[5] > 20):
            img.save("temp/snapshot-%d.jpg" % pyb.rng()) # Save Pic.
jimmie
Posts: 22
Joined: Wed Aug 21, 2019 11:22 pm

Re: Taking snapshot immediately.

Postby jimmie » Sun Sep 01, 2019 12:49 pm

iabdalkader wrote:
Sun Sep 01, 2019 12:08 pm
The example saves the image after detecting 10 frames of motion, try this:

Code: Select all

    while(True):
        img = sensor.snapshot()
        img.difference("temp/bg.bmp")
        stats = img.statistics()
        if (stats[5] > 20):
            img.save("temp/snapshot-%d.jpg" % pyb.rng()) # Save Pic.
Thank you Ibrahim.

Does the example show 10 frames or 20?
User avatar
iabdalkader
Posts: 1143
Joined: Sun May 24, 2015 3:53 pm

Re: Taking snapshot immediately.

Postby iabdalkader » Sun Sep 01, 2019 1:02 pm

The example waits until it counts 10 frames where motion is detected. The 20 is a threshold for the difference.

Code: Select all

    diff = 10 # We'll say we detected motion after 10 frames of motion.
jimmie
Posts: 22
Joined: Wed Aug 21, 2019 11:22 pm

Re: Taking snapshot immediately.

Postby jimmie » Sun Sep 01, 2019 5:05 pm

Thank you.

Return to “Technical Discussion”

Who is online

Users browsing this forum: MSN [Bot] and 3 guests