5556 views|34 replies

3386

Posts

0

Resources
The OP
 

MicroPython Hands-on (06) - Learn MaixPy monocular camera from scratch [Copy link]

 
 

Matching OV2640 camera: 2 million pixel universal 24P camera
It has 2 million pixels (1632x1232 pixels), small size, low operating voltage, and provides all the functions of a single-chip UXGA camera and image processor. Through SCCB bus control, it can output 10-bit sampling data of various resolutions such as full frame, sub-sampling, windowing, etc. The UXGA image of this product reaches up to 15 frames/second. Users can fully control the image quality, data format and transmission method. All image processing functions including gamma curve, white balance, saturation, chroma, etc. can be programmed through the SCCB interface. OmmiVision image sensors use unique sensor technology to improve image quality by reducing or eliminating optical or electronic defects such as fixed pattern noise, tailing, floating, etc., to obtain clear and stable color images.


This content is originally created by eagler8 , a netizen of EEWORLD forum. If you need to reprint or use it for commercial purposes, you must obtain the author's consent and indicate the source

Latest reply

Brother Strong   Details Published on 2024-8-27 10:08
 
 

3386

Posts

0

Resources
2
 

 
 
 

3386

Posts

0

Resources
3
 

OV2640 main parameters
Can support customized FPC length, lens angle (70-160 degrees)Can support customized FPC length, lens angle (70-160 degrees)
Photosensitive array 1632x1232 Maximum format UXGA
IO voltage 1.7V-3.3V Analog voltage 2.5-3.0v (internal LDO to power the core 1.2V)
Power consumption working TBD sleep <20μATemperature
operation -30℃ to 70℃
Stable operation 0℃ to 50℃
Output format (8-bit) YUV/YCbCr4:2:2 RGB565/555/444 GRB4:2:2 Raw RGB DataOptical
size 1/4"
Field of view 70 degrees
Maximum frame rate 15fps SXGA
Sensitivity 1.3V/(Lux-sec)
Signal-to-noise ratio 40 dB
Dynamic range 50
dBBrowsing mode progressive
Electronic exposure 1 line to 1247 lines
Pixel area 2.2μm x 2.2μm
Dark current 15mV/s at 60℃
Working current 40mA

 
 
 

3386

Posts

0

Resources
4
 

OV2640 internal block diagram

 
 
 

1w

Posts

25

Resources
5
 

Now the core is the algorithm, not the hardware.

Comments

I just started to use Python and I don't understand it. I will learn from the moderator slowly in the future.  Details Published on 2020-4-4 15:18
 
 
 

1

Posts

0

Resources
6
 

praise

Comments

Thanks for the encouragement  Details Published on 2020-4-4 15:18
 
 
 

3386

Posts

0

Resources
7
 
This post was last edited by eagle8 on 2020-4-4 15:36
dcexpert published on 2020-4-4 11:30 Now the core is the algorithm, not the hardware.

I tried to learn Arduino in May last year, and came into contact with Python by chance in the middle of last month. It turned out that I had no basic knowledge of Python. Haha, it was quite difficult. I will learn from the moderator slowly in the future

 
 
 

3386

Posts

0

Resources
8
 

Thanks for the encouragement

 
 
 

3386

Posts

0

Resources
9
 

 
 
 

3386

Posts

0

Resources
10
 

Camera electrical schematic

 
 
 

3386

Posts

0

Resources
11
 

 
 
 

3386

Posts

0

Resources
12
 
#MicroPython Hands-on (06) - Learn MaixPy monocular camera from scratch
# Experimental procedure 1: Testing the monocular camera

#MicroPython动手做(06)——零基础学MaixPy之单目摄像头
#实验程序之一:测试单目摄像头

import sensor    
import lcd

lcd.init()

sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.run(1)

while True:
    img = sensor.snapshot()
    lcd.display(img)

 
 
 

3386

Posts

0

Resources
13
 

 
 
 

3386

Posts

0

Resources
14
 

 
 
 

3386

Posts

0

Resources
15
 

Monocular camera sensor driver
Sensor module, for camera configuration and image capture, etc., used to control the development board camera to complete the camera task.

1. Initialize the monocular camera
Reset and initialize the monocular camera
sensor.reset([freq=24000000, set_regs=True, dual_buff=False])

Parameter
freq: Set the camera clock frequency. The higher the frequency, the higher the frame rate, but the image quality may be worse. The default is 24MHz. If the camera has color spots (ov7740), you can adjust it down to 20MHz.
Set_regs: Allow the program to write to the camera registers. The default is True. If you need to customize the reset sequence, you can set it to False, and then use the sensor.__write_reg(addr, value) function to customize the write register sequence.
Dual_buff: Allow the use of double buffering, which will increase the frame rate, but the memory usage will also increase (about 384KiB)

2. Image capture control
Enable or disable the image capture function (by default, the camera will automatically start after resetting, setting the frame size, and setting the pixel format. Image acquisition will also start even if run(1) is not called)
sensor.run(enable)

Parameter
enable: 1 means enable, 0 means disable

Return value
return: return 1

3. Set frame size
Used to set the camera output frame size. The maximum supported frame size of k210 is VGA. If it is larger than VGA, the image cannot be obtained.
The screen resolution of the MaixPy development board is 320*240. It is recommended to set it to QVGA format
sensor.set_framesize(framesize[, set_regs=True])

Parameters
framesize: frame size
set_regs: Allows the program to write camera registers, the default is True. If you need to customize the sequence of setting the frame size, you can set it to False, and then use the sensor.__write_reg(addr, value) function to customize the write register sequence

Return value
True: Setting successful
False: Setting error

 
 
 

3386

Posts

0

Resources
16
 
#MicroPython Hands-on (06) - Learn MaixPy monocular camera from scratch
#Test procedure 2: Try to take a photo

#MicroPython动手做(06)——零基础学MaixPy之单目摄像头
#测试程序之二:尝试拍一张照片

import sensor, lcd, image

print("init")
lcd.init(freq=15000000)
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.run(1)
sensor.skip_frames(40)
print("init ok")

path = "/sd/image.jpg"
img = sensor.snapshot()
print("save image")
img.save(path)

print("read image")
img_read = image.Image(path)
lcd.display(img_read)
print("ok")

 
 
 

3386

Posts

0

Resources
17
 

Serial port output
init
init i2c2
[MAIXPY]: find gc3028
True
True
init ok
save image
{"w":320, "h":240, "type"="rgb565", "size":153600}
read image
ok
MicroPython v0. 5.0-31-gd3e71c0 on 2020-03-13; Sipeed_M1 with kendryte-k210

 
 
 

3386

Posts

0

Resources
18
 

 
 
 

3386

Posts

0

Resources
19
 

Monocular camera sensor driver
Sensor module, for camera configuration and image capture, etc., used to control the development board camera to complete the camera task.

4. Set the frame format
Used to set the camera output format.
The screen configured by the MaixPy development board uses RGB565. It is recommended to set it to RGB565 format
sensor.set_pixformat(format[, set_regs=True])

Parameter
format: frame format
set_regs: allows the program to write camera registers, default is True. If you need to customize the sequence of setting pixel format, you can set it to False, and then use sensor.__write_reg(addr, value) function to customize the write register sequence
Optional frame formats are GRAYSCALE, RGB565, YUV422

Return value
True: Setting successful
False: Setting error

5. Image capture control
Image capture function control
sensor.run(enable)

Parameter
enable: 1 means start capturing images 0 means stop capturing images

Return value
True: Setting successful
False: Setting error

6. Take an image
Use the camera to take a photo
sensor.snapshot()

Parameters
None

Return value
img: the returned image object

 
 
 

3386

Posts

0

Resources
20
 

#MicroPython Hands-on (06) - Learn MaixPy monocular camera from scratch
#Test program 3: Record a video (30 seconds)

#MicroPython动手做(06)——零基础学MaixPy之单目摄像头
#测试程序之三:录制一段视频(30秒)

import video, sensor, image, lcd, time

lcd.init(freq=15000000)
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.run(1)
sensor.skip_frames(30)
v = video.open("/sd/capture.avi", record=1, interval=200000, quality=50)
i = 0
tim = time.ticks_ms()
while True:
    tim = time.ticks_ms()
    img = sensor.snapshot()
    lcd.display(img)
    img_len = v.record(img)
    # print("record",time.ticks_ms() - tim)
    i += 1
    if i > 100:
        break
print("finish")
v.record_finish()
lcd.clear()

 
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list