Project 27:Motion Detection–Based Greeting Device

In front of many convenience stores, welcome devices are commonly installed next to the doors. When a customer enters the set range, the system triggers the voice module to play "Welcome" and the LED light strip to flash. This function can be achieved with the UNIHIKER K10's motion detection function. In this lesson, we'll make such a device. 


Project Objectives


Knowledge Objectives


1.Experience motion detection.
2.Understand video frames and detection principle.


Practical Objective 


Implement the function to use the UNIHIKER K10 camera to detect object movement (e.g., a door) in the captured frame. When movement is detected, play welcome music, display an image and welcome words, and make the lights flash.

Materials List

HARDWARE LIST
1 UNIHIKER K10
1 USB Cable
1 MicroSD Memory Card
1 Card Reader
1 Driver Expansion Board
1 Expansion board power cable

Preparations


Hardware


Connect the UNIHIKER K10 to the computer using a USB Cable.

Software


Open Mind+, switch to“Upload Mode”, connect the UNIHIKER K10 as shown in the figure below, and load the UNIHIKER K10 library.

Hands-on Practice


Next, we'll learn the motion detection function of the UNIHIKER K10 and finish making the welcome device.


Code 


When displaying images via the TF card, first save the required images to the TF card in advance. The specific steps are as follows:

The graphical program blocks related to motion detection for the UNIHIKER K10 are under”AI”.we'll use these blocks: switch mode, set motion detection sensitivity, and motion detected (as shown below).

Now, we can implement the program following the logic of "enable camera show→switch mode motion detection→set motion detection sensitivity→ continuously detect motion". The sample implementation code is as follows:

Run the Code


Click the“Upload”button and wait for the upload to complete.
When the camera feed is displayed on the UNIHIKER K10 screen, insert it into the expansion board and secure it. Wave your hand or other objects in front of the camera, then observe the screen display and the played sound effects.

After the experience, you can adjust the "detection sensitivity" parameter in the program according to your own feeling.


Code Review


 

Category

Blocks

Function

Sets the motion detection sensitivity, the larger the setting value, the more sensitive the detection of motion, the range is 0-100.


Knowledge Base


Next, let's learn and summarize the hardware knowledge used in this lesson.


How Is Motion Detection Implemented?


The UNIHIKER K10 uses the frame difference method for motion detection, which detects pixel differences between two adjacent frames in the captured image. A frame is a single picture in a video, like a page in a flipbook, and when the pages are flipped, they create a moving effect.

If we reverse this process, the camera will automatically read each frame and analyze the difference between adjacent frames via image processing. Once a difference is detected, it indicates an object is moving in front of the camera.


So how does the UNIHIKER K10 detect the difference between each frame?


Whether it’s the UNIHIKER K10 or other devices, to“understand”an image, they must convert it into digital values. The smallest processed unit is the pixel. When zooming in, an image is found to consist of rows of pixels. The number and density of pixels determine the image’s clarity and detail. 
In practice, resolution (usually the number of horizontal and vertical pixels, width×height) is used to describe image clarity. For color images, each pixel is determined by the RGB color channels. For example, a pixel in pixel art with an RGB value of (255, 0, 0) is red.

For the UNIHIKER K10, a 240×320 pixel digital matrix is generated based on its screen size, with each pixel corresponding to an RGB value. It determines motion by comparing RGB differences of pixels at the same position in two adjacent frames. In the previous program, we set the sensitivity parameter: high sensitivity identifies even minor pixel differences as motion, while low sensitivity recognizes only relatively large changes as motion.


Challenge Task


What other scenarios can motion detection be applied to? For example, you can make a safe alarm device. Point the UNIHIKER K10 camera at a cabinet with important items. If the cabinet moves, the device will alarm. You can also use the IoT to send remote alarms (refer to Part 2's production process). Try it! 

icon project 27.zip 722KB Download(0)
License
All Rights
Reserved
licensBg
0