Reputation: 117
I am trying to do face recognition of multiple people using logitech c930e webcam. so i want to zoom the c930e webcam using opencv Programming in python.
I had tried resizing the image but i want camera should be zoom and focused on a fixed distance using python programming.
I expect multiple webcam to be connected on one computer and all webcam is having different value of fixed zoom using programming.
Upvotes: 2
Views: 5073
Reputation: 11301
According to its specs, the C930e is UVC-compatible (as most webcams are), and it most likely allows zoom level control via UVC.
To figure out what controls the camera provides via UVC, on Ubuntu you can use v4l2-ctl
, which is in package v4l-utils
. Here part of the output of v4l2-ctl -d 0 -l
for a Microsoft LifeCam Cinema:
...
focus_absolute (int) : min=0 max=40 step=1 default=0 value=8
focus_auto (bool) : default=0 value=0
zoom_absolute (int) : min=0 max=10 step=1 default=0 value=0
You can change the controls, e.g., with v4l2-ctl -d 0 -c zoom_absolute=10
.
To do this from Python, I used subprocess.check_output()
. The utility function I wrote for getting and setting V4L2 controls is on GitHub and has a bunch of additional functionality such as handling of default values, multiple controls, and multiple batches of controls, which makes the code more intricate than a simple "change zoom level" example would be. (The function is part of SkinnerTrax, a real-time tracker for Drosophila I wrote.) There is also pyuvc, which seems relatively cross-platform but I have not tried it.
Upvotes: 8
Reputation: 2917
Logitech c930e webcam is just an external hardware and if you want it to zoom and focus using python programming, you need a library to control the webcam (unfortunately, there isn't any library for it). Without library to control the webcam, you can only do zooming and focus by software way, i.e using opencv, there is no other available way. Or you can get a programmable camera such as a Canon digital camera and use the library canon-remote to control it.
Upvotes: 0