Raspberry Pi (5): CSI camera vs USB Camera

0. Introduction

Raspberry Pi's CSI original camera with an ordinary USB camera What's the difference?
What CSI camera advantages and disadvantages ? We choose when choosing which one ?

When a recent acceleration of a project to produce such a question, began to compare the two cameras.

1. Preparations

I call opencv environment in python3 two cameras for evaluation
it is necessary to prepare the following:

  1. Enable Camera
    clicking upper left corner of Raspberry Pi -> Preference -> Raspberry Configuration, enable Camera, raspberry pie after the restart.

  2. Install opencv
    specific process See raspberry pie (4): Raspberry Pi python3 install opencv

2. CSI camera

2.1 installation of cameras

Here Insert Picture Description
When mounting CSI camera, not a charging operation , or easily burn the camera, when the cable installation, and raspberry come watch camera snap, snap-open and then inserted cable, then the cable card plugged buttoned good, and pay attention to the direction of the cable .

2.2 driver installation

In Deiki wrote in an article,

Raspberry Pi camera plugged into a dedicated CSI CSI ports raspberry pie and can be used in the open after the command Raspistill raspi-config used directly, but if you call CSI camera in OpenCV no data will appear in the phenomenon (cv2.VideoCapture ( 0) then no error).

This is because the Raspberry Pi camera module is placed in the / boot / directory is loaded as firmware, not a standard camera driver V4L2, so it will not be found after loading the device node / dev / video0 of. We add a line bcm2835-v4l2 (lowercase L) in the / etc / modules which will solve the problem.

I did not encounter this problem, that is, this step is not performed my opencv can directly call the CSI camera, probably Buster version solves this problem.

But sure, I still had this step.

2.3 Test

Write a simple program reads the camera image

import cv2

videoIn = cv2.VideoCaptire(0)
print("capture device is open: " + str(videoIn.isOpened()))
success,frame = videoIn.read()
while success:  
	cv2.imshow('Test camera',frame)
	success,frame = videoIn.read()
	if cv2.waitKey(1) & 0xFF == ord('q'):
		break
videoIn.release()

Here Insert Picture Description
test was successful!

3. USB Camera

USB camera is much more convenient, directly into the USB port (this time I removed the camera CSI), also run the above code
Here Insert Picture Description
test success!

4. Comparison of both

4.1 Model Description

CSI camera USB camera
Here Insert Picture Description Here Insert Picture Description

See the order, I noticed this USB camera price became 66, but is now generally USB camera twenty blocks can also buy a bar

4.2 image quality

CSI camera USB camera
Here Insert Picture Description Here Insert Picture Description

CSI camera biggest pain points ! Image quality is really bad ah! (Mainly low-light)

CSI has introduced the camera sentence

Excellent resolution (higher than most USB webcams) and excellent daytime image quality.

It seems it is only in the light of better quality in order to justify the situation. No wonder motocoder write in the forum

After several weeks of frustration with the Raspberry Pi Camera, I gave up on it and switched to a USB webcam. For those considering the camera board, I recommend you look into USB cameras as an alternative.

The primary reason that I switched was that the Raspberry Pi camera board has extremely bad low light issues. Trying to take a photo indoors, even with significant incandescent light, was resulting in black frames about 9 out of 10 times. 1 out of 10 times, it would produce a slightly underexposed photo instead, leading me to believe this might be a software bug rather than a hardware issue.

4.3 系统资源占用

测试3000帧图像,测试代码如下

import cv2
import time

videoIn = cv2.VideoCapture(0)
print("capture device is open: " + str(videoIn.isOpened()))
flag = 0
start = time.time()
success,frame = videoIn.read()
while success:    
	#cv2.imshow('Test camera',frame)
	success,frame = videoIn.read()
	flag += 1
	if cv2.waitKey(1) & 0xFF == ord('q'):
		break
	if flag == 3000:
		end = time.time()
		print("3000 frames use time is (s)")
		print(end - start)
		break
videoIn.release()

4.3.1 CSI摄像头

运行这段代码使用了100秒,基本是30帧/s。使用htop命令查看占用资源情况,CPU占用率基本是在20%波动。
Here Insert Picture Description

4.3.2 USB摄像头

USB摄像头运行了101秒(这个还算稳定,之前试过一个USB摄像头帧率极不稳定且帧率较低),CPU占用率则是在50%到80%波动。
Here Insert Picture Description
(截这个图的时候忘记上图对齐了,明天换一个)
USB摄像头通常是慢速、低帧率的,这一点是没有CSI那么好的。

4.3.3 二者对比

CSI摄像头 USB摄像头
CPU占用率在20%波动 CPU占用率在50%~80%波动

这次测试其实忘记看它们的输入大小了,直接对比结果不太严谨,不过基本也能从某些方面反映出结果了。(明天完善一下)

可以看到,USB摄像头的CPU占用率是比较高的。RPi是没有足够的CPU能力更高的帧速率、分辨率或高级视频压缩的

而CSI摄像头使用树莓派的GPU的话,h.264编码视频对CPU使用率影响很小

4.4 使用体验

使用体验上,USB摄像头就基本上完虐CSI摄像头了

4.4.1 CSI摄像头

  1. 易碎,易静电击穿
  2. 需要特定的软排线,短,易折,不灵活
  3. 接口特定,不通用

对于电路板裸露在外这一点真的是需要格外小心!我就一不小心将电路板背面碰到了树莓派的以太网接口(是金属的),树莓派立刻down掉了,屏幕立刻黑掉,心痛地重启后所幸无碍,说明还是有电源保护的麽

不过,之后我就遇到了下面这个问题
VIDIOC_DQBUF: Resource temporarily unavailable

出这个问题的时候用的是另一个USB摄像头,换了本文的USB摄像头就不会出现这个问题。

The problem is the camera on the computer can be used normally, and suspected abnormal power down when it is in the cache Raspberry Pi device management which is a problem, the first record, and then try to solve it

4.4.2 USB Camera

  1. Most have some type of head-mounted ball, you can easily adjust the angle of the camera according to need;
  2. There are long, flexible USB cable
  3. Plug and play, USB interface is very versatile

5. Other

Summary: The two sides have advantages and disadvantages of it, or look at your specific needs to choose a.

Currently, in my case, USB camera take up so much CPU resources really can not endure, I should give CSI camera to be a good package :)

Attached official forum to discuss the
Here Insert Picture Description
problem with more exchanges, the message can be e-mail, my mailbox is zhaodongyu Ait pku (here replaced by points) edu.cn.

Released six original articles · won praise 1 · views 2481

Guess you like

Origin blog.csdn.net/ZhaoDongyu_AK47/article/details/103981905