[Free] DjMotionDetect Extension

This extension uses the Camera to detect motion within the CameraPreview. A threshold can be used to set the sensibility of Detection. When a motion is detected it triggers an event, where you can set a Alarm sound for example like in the test aia. You can also trigger to take a picture automaticly. The Images are stored in the Documents folder. Have fun!
[Edit} Updated.

DjMotionDetect

A motion sensor using the device camera

Events:

MovementDetected

MovementDetectedBlock
Triggered when movement is detected

PictureTaken

PictureTakenBlock
Triggered when a picture is taken

Parameter Type
filePath text

Methods:

SetupPreview

SetupPreviewBlock
Sets up the camera preview inside a given arrangement

Parameter Type
arrangement component

SetCamera

SetCameraBlock
Sets the camera to use. Use 'front' or 'back'

Parameter Type
cameraFacing text

StartDetection

StartDetectionBlock
Starts motion detection

StopDetection

StopDetectionBlock
Stops motion detection

TakePicture

TakePictureBlock
Takes a screenshot of the camera preview and saves it to the specified path with timestamp

Parameter Type
directoryPath text

Properties:

SetMotionThreshold

SetMotionThresholdBlock
Set the motion detection threshold. 0-100

This documentation was generated using Akshat Developer's Documentation Generator.

Update:
blocks (25)

DjMotionDetect.aia (62.5 KB)

com.django.djmotiondetect.aix (17.9 KB)

*** Tip for the Test Aia : When you switch to "photo" 2 Images/sec will be taken
and stored in your /Documents folder. Dont forget to stop detection when there
is heavy motion! ***

8 Likes

Tested your aia.

Unable to switch cameras ? Just get "selfie" camera (in notch on screen) - is this front or back ?
Tried several things but no change.

Motion detection works fine.

Companion app, Pixel 8a Android 15

[EDIT]

Got the "back" camera to come up using these blocks

image

but when starting motion detection the alarm sounds when there is no movement!

not able to switch cameras, probably need to reset the preview...

And what is OpenCamera for, it already opens with SetupPreview ?

Thanks for your suggestions! I made a quick fix, removed "OpenCamera" as it wasnt needed anymore. I did some fix on the camera switch issue. Hope it works now for you. Updated first post.

1 Like

Seems to be much better now, camera switching OK.

1 Like

The extension could still do with a method to unset the cameraPreview, and have the ability to restart it ? (It chews up the battery at 1% per minute...)

I am finding that "motion is detected" when I switch cameras ( I get the alarm ) even when there is no motion to be detected.

New Update. @TIMAI2 Thx again for your report!

1 Like

Thanks, I used it for my school project, in which we needed to use a sensor and I choose your extension to make a bell, worked perfectly!

Hi,
it appears that motion detection does not work in my app. Can you provide simple test blocks for cheking motion detection?

Example blocks are provided in the first post

Yes, I was following that but for some reason this block does not work:
blocks (3)

the correct values for the cameras are front and back not globalCam

Thanks. Have set that
blocks (5)

but no change. Any other idea?

Please read the example blocks again and use the correct ones to handle a detection event in your example (MovementDetected!).

What am I missing?

For starters:

1 Like

Does my provided test aia work for you? If yes, then better start from there.

Thanks TIMAI2, did I understand your tip well? Unfortunately it does not work.

I will need to dig out my working aia project on this. Back later...

Try this, works for me in Companion

DjMotionDetect_Demo.aia (81.5 KB)

Yes, your app works well - I will redesign it for my use. Thanks for that!