Lesson11: HuskyLens Camera with an AI Machine Vision Sensor
Photographs are the universal language of our era. With the rapid development of smartphones, phone photography has become more and more popular. Convenient operations and numerous creative apps are changing people's habits of recording images. There are no strict rules for phone photography, no professional equipment is needed, only a pair of eyes that can discover beauty would suffice.
It is not difficult to find in life that more and more people are holding mobile phones to record life, scenery, food, flowers and plants. Different phone photography themes all express their perception of beauty and love for life!
Is AI Machine Vision Sensor Huskylens related to cameras? Absolutely! AI Machine Vision Sensor Huskylens also has the capability to take photos. Now, let's use AI Machine Vision Sensor Huskylens and micro:bit to build our very own HUSKYLENS camera!
Learning Objectives
1. Learn the principle of pinhole image and the origin of the first camera
2. Learn the principle of AI Machine Vision Sensor HuskyLens photography
3. Learn to use AI Machine Vision Sensor HuskyLens to make a camera
Preparation
Note: SD card and card reader are not included in the kit.
Learning Content
What is a camera? Why does the objective scene freeze on the film as soon as the shutter rings? Especially nowadays, digital cameras and mobile phones are popular with people, and the fixed images that are shot can be immediately seen in the viewfinder of the LCD screen. How are these almost magical operations realized?
The Origin of the First Camera and the Principle of Pinhole Imaging
1. The first camera-Camera obscura
Before the camera was invented, people had begun to use the principle of "pinhole imaging" to make optical imaging devices, which are called "Camera obscura". In the first half of the 19th century, people finally found the method and medium to preserve the optical image on the projection surface in the camera obscura. Therefore, the camera obscura is considered the ancestor of the camera.
2. What is pinhole imaging?
Use a plate with a pinhole between the screen and the object, and an inverted image of the object will be formed on the screen. We call this phenomenon pinhole imaging. Moving the plate back and forth, the size of the image will also change accordingly. This functional phenomenon reflects the nature of light propagating along a straight line. The imaging principle of the camera is to use "pinhole imaging". The light enters through the pinhole and maps on the photosensitive film to form an image.
AI Machine Vision Sensor HuskyLens Photograph Principle
1. Can HuskyLens photograph?
You must be thinking that you are already familiar with the usage and functions of HuskyLens, but you have not found the camera function at all, and there is no shoot button. Is it impossible for HuskyLens to take pictures?
HuskyLens can be used for photograph. As a vision sensor, the HuskyLens has a rear camera with 5 million pixels. Taking pictures is the most basic function. Whether you are using a mobile phone or a camera to take a photo, the photo you take needs to be stored on the SD card or the memory space. Therefore, HuskyLens also needs an SD card to store photos. The SD card is inserted as follows:
2. AI Machine Vision Sensor HuskyLens photography principle
Traditional cameras use "film" as the carrier for recording information, and the "film" of HuskyLens cameras is its photosensitive sensor. The light sensor is the core of the HuskyLens camera and the key technology for taking pictures. It can convert light into electric charge, which is converted into digital signal through an analog-to-digital converter, and the digital signal is saved by the SD card after being compressed.
AI Vision Project Practice
When using a mobile phone to take a photo, you need to trigger the camera button to take a photo, and then three different ways to trigger the camera function.
Task 1: Touch
Use the touch LOGO of micro:bit V2 to simulate the camera button of a mobile phone. Touch the LOGO once, and HuskyLens will take a picture and store it on the SD card.
Task 2: Voice-activated
A Voice-activated camera is mainly used to take photos by voice. A microphone which can detect sound is added to the micro:bit V2 main control board. When the detected sound value is greater than 100, HuskyLens will perform the camera function.
Task 3: Time-lapse
Time-lapse photography is mainly used to take group photos. Usually, the camera is fixed in a position and set at an appropriate time-lapse, and then the photo is taken.
Task1: Touch
Hardware connection
Program design
Function instruction:
Touching to take pictures is the easiest way to take pictures in HuskyLens cameras. The HuskyLens camera program is called by triggering the touch LOGO of the micro:bit.
Flowchart Analysis
The MakeCode Sample Program
Makecode Sample Program link : https://makecode.microbit.org/_2tk7UETMhKXY
AI Vision Project Operating Effect
Run the program and touch the micro:bit LOGO. If a "middle C" tone is played, it means that the photo was taken successfully. Then you can view the photos using the card reader.
Task2: Voice-activated
Hardware connection
Program design
AI Vision Function Explain:
Voice-activated photography is mainly achieved by judging the value of the voice. A microphone is integrated on the micro:bit V2 main control board, and the sound level can be detected through the microphone. When the detected "sound loudness"> 100, the camera program is executed and the micro vibration module vibrates.
Flowchart Analysis
The MakeCode Sample Program
Makecode Sample Program link : https://makecode.microbit.org/_Jh3U1bhyDWF9
AI Vision Project Operating Effect
Run the program, the small red microphone on the micro:bit will be lit up. When we speak loudly, HuskyLens will execute the camera command and the vibration module will vibrate. The vibration module vibrates every shoot.
Task3: Time-lapse
Hardware connection
Program design
AI Vision Function Explain:
In this project, set a 3S delay and use button A on the micro:bit to trigger the camera program. Click button A, the words 3, 2, and 1 will be displayed on the HuskyLens screen, and the "heart" pattern will be displayed on the micro:bit matrix screen to indicate the success of the photography.
Flowchart Analysis
The MakeCode Sample Program
Makecode Sample Program link : https://makecode.microbit.org/_FJ03ADUpweYH
AI Vision Project Operating Effect
Run the program and press button A, the HuskyLens screen displays the numbers 3, 2, and 1 in a decreasing manner. When the micro:bit dot matrix screen displays the "heart" pattern, it means the photo is taken.
Project Review
In this project, we mainly learned the principle of pinhole imaging and the principle of HuskyLens photography. Using HuskyLens to take pictures, we simulate the most commonly used phone photography in our lives.
The three tasks are mainly to trigger the camera function through three different hardware methods, which make up for the disadvantage of HuskyLens without a camera button. What other hardware methods can we use to trigger the camera function?
Project Development
Have you ever thought of using the eight built-in functions of HuskyLens to trigger the camera function? For example, what should you do if you only want to take pictures with puppies?
Tip: You can use the object classification function to learn pictures of puppies, and trigger the camera function by judging whether there are puppies in the picture.
Click Buy Study Pack of HUSKYLENS for micro:bit
Click Buy Huskylens - An Easy-to-use AI Camera | Vision Sensor
Click Buy Study Pack with HUSKYLENS and micro:bit V2
Engage in learning the next AI vision project : Emergency Lane Watchdog with an AI Machine Vision Sensor
Engage in learning the previous AI vision project : Decrypt Binary with an AI Machine Vision Sensor