Use a Digital Camera on Ubuntu

wsh
3 min readMay 1, 2019

--

Introduction

Since I’m studying about computer vision, one of the problems I sometimes encounter is how to use a digital camera in Ubuntu. Though there are a lot of webcams available in less than 30 bucks and they usually do not need any drivers or third-party installations, we cannot expect higher resolutions or frame rate to them. However, if we tried to use a digital camera on Ubuntu, it would not be an easy task since the drivers or utility applications provided by the manufacturer are usually available only on Windows or Mac systems.

So in this post, I introduce a way I discovered to connect a digital camera to an Ubuntu system and use it as a webcam, or sometimes to shoot remotely.

The system I used:

  • Ubuntu 18.04.2 LTS
  • AMD Threadripper 2950x
  • Canon EOS kiss x4

Details

This post is based on a post of StackExchange and this website. Thus if you want to know more details, please visit them.

We first install an application called Entangle. With this app we can shoot pictures remotely.
This app is available on Ubuntu Software:

At this point, this app does not recognize any camera just by physically connecting it to the machine:

It prompts that “No camera connected” in the Camera settings section.

So we need to install third-party programs to systematically connect the camera to the machine.
Run the following command to install the necessary programs in terminal:

sudo apt-get install gphoto2 v4l2loopback-utils

After installing them, you can check if there is any available camera with this command:

gphoto2 --abilities
The response looks like this if there is an available camera.

If there is no camera detected, the response would be like the following. In this case, make sure that the camera is turned on.

Once the camera is surely detected, then you can finally connect it with this command below. This make a new device video0in the /dev/ directory. This is all we have to do.

sudo modprobe v4l2loopback
A new device ‘video0’ is created.

If all the necessary process have successfully done, relaunch Entangle, and then the camera would be detected. When the app asks whether to unmount the camera, choose ‘yes’.

The camera has been successfully detected.

Conclusion

I have not yet tested if the camera is recognized also by OpenCV. If anyone does this, please let me know in the comment below!

[update]
A digital camera can also be used as an input device to the cv2.VideoCapture() function of OpenCV. I will show you how to do that in the future post.

References

[1] https://www.omgubuntu.co.uk/2017/04/tether-digital-camera-ubuntu-entangle

[2] https://askubuntu.com/questions/856460/using-a-digital-camera-canon-as-webcam

--

--

No responses yet