- Mastering OpenCV 4
- Roy Shilkrot David Millán Escrivá
- 347字
- 2021-07-02 14:47:38
Installing the Raspberry Pi Camera Module driver
First, let's temporarily load the v4l2 driver for the Raspberry Pi Cam to make sure our camera is plugged in correctly:
sudo modprobe bcm2835-v4l2
If the command failed (if it printed an error message to the console, it froze, or the command returned a number besides 0), then perhaps your camera is not plugged in correctly. Shut down and then unplug power from your Raspberry Pi and try attaching the flat white cable again, looking at photos on the web to make sure it's plugged in the correct way around. If it is the correct way around, it's possible the cable wasn't fully inserted before you closed the locking tab on the Raspberry Pi. Also, check whether you forgot to click Enable Camera when configuring your Raspberry Pi earlier, using the sudoraspi-config command.
If the command worked (if the command returned 0 and no error was printed to the console), then we can make sure the v4l2 driver for the Raspberry Pi Cam is always loaded on bootup by adding it to the bottom of the /etc/modules file:
sudo nano /etc/modules
# Load the Raspberry Pi Camera Module v4l2 driver on bootup:
bcm2835-v4l2
After you save the file and reboot your Raspberry Pi, you should be able to run ls /dev/video* to see a list of cameras available on your Raspberry Pi. If the Raspberry Pi Cam is the only camera plugged into your board, you should see it as the default camera (/dev/video0), or if you also have a USB webcam plugged in, then it will be either /dev/video0 or /dev/video1.
Let's test the Raspberry Pi Cam using the starter_video sample program we compiled earlier:
cd ~/opencv-4.*/samples/cpp
DISPLAY=:0 ./starter_video 0
If it's showing the wrong camera, try DISPLAY=:0 ./starter_video 1.
Now that we know the Raspberry Pi Cam is working in OpenCV, let's try Cartoonifier:
cd ~/Cartoonifier
DISPLAY=:0 ./Cartoonifier 0
Or, use DISPLAY=:0 ./Cartoonifier 1 for the other camera.
- ASP.NET Core:Cloud-ready,Enterprise Web Application Development
- Learning Scala Programming
- 程序員修煉之道:程序設計入門30講
- .NET 4.0面向對象編程漫談:基礎篇
- Learning SQLite for iOS
- 數據結構簡明教程(第2版)微課版
- C語言程序設計案例式教程
- Android開發案例教程與項目實戰(在線實驗+在線自測)
- Visual FoxPro程序設計習題集及實驗指導(第四版)
- Android開發三劍客:UML、模式與測試
- Visual FoxPro 6.0程序設計
- Scala Functional Programming Patterns
- 百萬在線:大型游戲服務端開發
- 編程的原則:改善代碼質量的101個方法
- C語言程序設計教程