How to make the CSI camera on the Raspberry Pi work?

My camera is the Raspberry Pi NolR camera V2, and the camera is connected to the Raspberry Pi through the CSI interface.
I get the following error when I run the python code:

import cv2

cap = cv2.VideoCapture(10)

[ WARN:0] global /build/opencv/src/opencv-4.4.0/modules/videoio/src/cap_gstreamer.cpp (480) isPipelinePlaying OpenCV | GStreamer warning: GStreamer: pipeline have not been created
[ WARN:0] global /build/opencv/src/opencv-4.4.0/modules/videoio/src/cap_v4l.cpp (893) open VIDEOIO(V4L2:/dev/video10): can't open camera by index

The contents of my /dev directory are as follows:

autofs           dri        input  loop7         null   ram14   raw             tty    tty18  tty28  tty38  tty48  tty58    ttyprintk  vcs3   vcsm-cma     video10
block            fb0        kmsg   loop-control  port   ram15   rfkill          tty0   tty19  tty29  tty39  tty49  tty59    uhid       vcs4   vcsu         video11
btrfs-control    fd         kvm    mapper        ppp    ram2    rpivid-h264mem  tty1   tty2   tty3   tty4   tty5   tty6     uinput     vcs5   vcsu1        video12
bus              full       log    media0        ptmx   ram3    rpivid-hevcmem  tty10  tty20  tty30  tty40  tty50  tty60    urandom    vcs6   vcsu2        video13
cachefiles       fuse       loop0  media1        pts    ram4    rpivid-intcmem  tty11  tty21  tty31  tty41  tty51  tty61    v4l        vcsa   vcsu3        video14
char             gpiochip0  loop1  mem           ram0   ram5    rpivid-vp9mem   tty12  tty22  tty32  tty42  tty52  tty62    vchiq      vcsa1  vcsu4        video15
console          gpiochip1  loop2  mmcblk0       ram1   ram6    shm             tty13  tty23  tty33  tty43  tty53  tty63    vcio       vcsa2  vcsu5        video16
cpu_dma_latency  gpiomem    loop3  mmcblk0p1     ram10  ram7    snd             tty14  tty24  tty34  tty44  tty54  tty7     vc-mem     vcsa3  vcsu6        watchdog
cuse             hidraw0    loop4  mmcblk0p2     ram11  ram8    stderr          tty15  tty25  tty35  tty45  tty55  tty8     vcs        vcsa4  vga_arbiter  watchdog0
disk             hidraw1    loop5  mqueue        ram12  ram9    stdin           tty16  tty26  tty36  tty46  tty56  tty9     vcs1       vcsa5  vhci         zero
dma_heap         hwrng      loop6  net           ram13  random  stdout          tty17  tty27  tty37  tty47  tty57  ttyAMA0  vcs2       vcsa6  vhost-net    zram0

What should I do to make the camera work properly?

What way is the cable facing?

The cable facing is of course correct.
There is no video0 in /dev, but there are video10 to video16.
It is a pity that video10 to video16 are not valid.
I guess there may be no CSI related driver in the system, but I don’t know where to find it.

The camera equipment is no problem.
I can use it normally in Raspberry Pi OS.

Put start_x=1 in /boot/config.txt and reboot.

1 Like

Thanks. I Was starting to scratch my head. About this…

1 Like

Now the camera is working, but the image it transmits is strange (I am very sure that the camera is not damaged), like this:

This strange picture will flicker and will not be displayed continuously.
At the same time there will be some information:

[ WARN:0] global /build/opencv/src/opencv-4.4.0/modules/videoio/src/cap_gstreamer.cpp (480) isPipelinePlaying OpenCV | GStreamer warning: GStreamer: pipeline have not been created

Can recompiling opencv solve this problem?
In other words, what should I do to solve this problem?

I have no clue. I do not have a camera and know nothing about opencv. I do know some others here have gotten their camera’s working.

Well, I will try to solve this problem.
Thank you very much for your answers.

I solved this problem.

  1. If there is no video0 in the /dev directory, you need to add start_x=1 in /boot/config.txt.
  2. The screen flickers because the camera’s resolution setting is incorrect. The Raspberry Pi Camera V2 (8 million pixels) only supports the ratio of 4:3 (it should be), and the camera can work normally when the resolution is 1024×768.

Thank you @Darksky and @Jtyle6 for helping me.


  1. /dev目录下没有video0的,需要在/boot/config.txt中添加start_x=1
  2. 出现画面闪烁是因为没有设置正确的摄像头的分辨率,Raspberry Pi camera V2(800万像素的)只支持4:3的比例(应该是这样),使用1024×768的分辨率时摄像头就能正常工作了(或者2048×1536,只要宽高比是4:3的分辨率,并且总像素在800万像素以下的应该都可以)

感谢帮我解决问题的 @Darksky@Jtyle6

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.