Giter Club home page Giter Club logo

computer-vision-with-rpi-usb's Introduction

Compatible codes of Coursera course Computer Vision with Embedded Machine Learning for USB cameras

I don't have a Raspberry Pi to test the course codes due to lack of stock and high prices, so I tried virtualizing the Raspberry Pi desktop OS and connecting inexpensive Raspberry Pi compatible USB cameras.

This is the Raspberry Pi desktop operating system:

https://www.raspberrypi.com/software/raspberry-pi-desktop/

It is a 32 bit or i386 system, NOT arm, it will install with a 64 bit kernel if the chosen processor is 64 bit. Raspberry Pi Desktop seems very compatible with the original Raspberry Pi, to avoid compatibility issues with programs compiled from source, I first chose a 32-bit processor or the qemu32 for the virtual machine. I have tried to install this linux in VirtualBox and in Qemu/KVM. In VirtualBox the USB cameras do not work as well as in Qemu, in addition, a command is also necessary for the cameras connected to a virtual machine, for example with this command in linux for the first webcam (.1):

VBoxManage controlvm "Raspberry Pi Desktop" webcam attach .1

In Qemu/KVM this step is not necessary, and it works much better, with more resolution options although at low fps (15 fps), it will surely work even better with IOMMU or hardware passthrough.

Some of the cameras I've tried:

https://es.aliexpress.com/item/1005003279752689.html

Cheap camera with Zoom:

https://es.aliexpress.com/item/1005003615538865.html

It is also possible to use the mobile cameras with DroidCam, in VirtualBox with Raspberry Pi Desktop it recognizes it the same as if it were a USB webcam and it works very well, with the high quality of the mobile camera, both by ADB and by Wifi, although much better by ADB. While it must be installed from source, I seem to recall that, at least for the optional GUI application, it is not compatible with the 64-bit amd64 kernel on a 32-bit Linux system. I also encountered problems with the Else Impulse software, it is not compatible with 32 bits kernel nor 64-bit amd64 kernel on a 32-bit Linux system.

https://www.dev47apps.com/droidcam/linux/

In short, the tests were satisfactory for the first two codes of the course, modified for USB cameras, but not for the following ones due to the incompatibility of the Edge Impulse software with linux i386 32 bits (although it is compatible with arm 32 bits and 64 bits).

Raspberry Pi Desktop is actually an exact copy of Debian 11 or Bullseye operating system, its repositories are all official Debian ones. It is then possible to install a 64-bit Debian system with the LXDE desktop, they are not aesthetically identical but the most important thing is to preserve similarity in the versions of the libraries between the virtualized system and an original RPI 4.

debian-live-11.4.0-amd64-lxde.iso from here:

https://www.debian.org/CD/live/

Some help for a Linux virtualized with Qemu/KVM:

https://askubuntu.com/questions/858649/how-can-i-copypaste-from-the-host-to-a-kvm-guest

https://ostechnix.com/setup-a-shared-folder-between-kvm-host-and-guest

https://superuser.com/questions/502205/libvirt-9p-kvm-mount-in-fstab-fails-to-mount-at-boot-time

An alternative to installing Debian 64-bit is to try to change the entire system to the amd64 architecture from a 32-bit Raspberry Pi Desktop installation. To try this option it would only be necessary to change the virtualizer configuration to a 64-bit processor. But several problems are to be expected due to some Raspberry modifications that will not be available in 64 bits, and furthermore this option does not seem necessary as they are two identical operating systems:

https://wiki.debian.org/CrossGrading

On a PC 64-bit Linux, there is no problem running Edge Impulse and the modified Python codes. The programs work on any amd64 64-bit linux, be it virtualized or bare metal, as long as the codes are modified for linux compatible USB cameras.

Compatible sample codes for USB cameras on linux 64 bits or Raspberry PI arm:

https://github.com/antor44/computer-vision-with-RPi-USB


pi_cam_preview_usb.py:

pi_cam_preview_usb.py

pi_cam_capture_usb.py:

pi_cam_capture_usb.py

An image captured:

An image captured

Image cropped and resized to configured sizes. Rotation is also available.

dnn-live-inference-pi-cam_usb.py:

dnn-live-inference-pi-cam_usb.py

dnn-live-inference-pi-cam_usb.py on a virtualized Debian 11 LXDE amd64.

dnn-live-colorspace_usb.py:

dnn-live-colorspace_usb.py

dnn-live-colorspace_usb.py to check if the color space of captured images is BGR, the codes for the Raspberry Pi camera module are for BGR color space and color order, just like these codes for cameras USB, due to the OpenCV library works in BGR color order when images are in color. In the image above, the first pixel (red) is processed correctly: [x x 255] (BGR).

computer-vision-with-rpi-usb's People

Contributors

antor44 avatar

Watchers

Kostas Georgiou avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.