Can't open OS08A10 MIPI camera by OpenCV

Dear team,

Which Khadas SBC do you use?

VIM3 Basic

Which system do you use? Android, Ubuntu, OOWOW or others?\

Ubuntu

Which version of system do you use? Khadas official images, self built images, or others?

vim3-ubuntu-20.04-gnome-linux-4.9-fenix-1.1.1-220725-emmc.img

Please describe your issue below:

I try to open the MIPI camera using opencv on VIM3: $python3 mipi-camera.py, but I always get this error:
[ WARN:0] global …/modules/videoio/src/cap_v4l.cpp (887) open VIDEOIO(V4L2:/dev/video0): can’t open camera by index

I followed the example and we can use v4l2_test and guvcview to open the camera. I see this solution in our community: $sudo apt remove opencv3, $pip3 uninstall opencv-python, $sudo apt update, $sudo apt install libopencv-dev python3-opencv. But it doesn’t work.

Do you have any information about OpenCV support for the mipi camera?
@Frank @numbqq

I found this problem too.
@numbqq

@Jirat_Srisabye @JJ1997 It work for me.

  1. Burn with 220725 Ubuntu Image.
  2. Update & upgrade your system.
$ sudo apt update && sudo apt upgrade
  1. Install OpenCV.
sudo apt install libopencv-dev python3-opencv
  1. Test

Are you sure your camera is connected correctly?

Thanks for your reply @Frank.
I reconfigured a new VIM3 board following your steps and it works.
But after installing ksnn, the error of " can’t open camera by index" reproduced, because ksnn requires opencv-python==4.6.0.66 and it install it automatically. And I can’t find the same version opencv 4.2.0 in pip. How I can use the MIPI camera with KSNN ?

And here are the versions of opencv-python in python:
Could not find a version that satisfies the requirement opencv-python==4.2.0 (from versions: 3.4.0.14, 3.4.10.37, 3.4.11.39, 3.4.11.41, 3.4.11.43, 3.4.11.45, 3.4.13.47, 3.4.14.53, 3.4.15.55, 3.4.16.57, 3.4.16.59, 3.4.17.61, 3.4.17.63, 3.4.18.65, 4.3.0.38, 4.4.0.40, 4.4.0.42, 4.4.0.44, 4.4.0.46, 4.5.1.48, 4.5.2.54, 4.5.3.56, 4.5.4.58, 4.5.4.60, 4.5.5.62, 4.5.5.64, 4.6.0.66)

I found this works for me but not very smart. I can create a virtual python environment and remove opencv-python==4.6.0.66 after installing ksnn:

python3.8 -m venv --system-site-packages venv
source venv/bin/activate
pip install ksnn-1.3-py3-none-any.whl
pip uninstall opencv-python==4.6.0.66