![Maven Central Adds Sigstore Signature Validation](https://cdn.sanity.io/images/cgdhsj6q/production/7da3bc8a946cfb5df15d7fcf49767faedc72b483-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
This is a low level way of interacting with multiple cameras connected to different devices. If you want to contribute please have a look at the DEV_README.
Use the following command to install the package:
pip install camera-management
If you want to use AVT-Cameras or any camera that uses the Vimba / VimbaX backend, please read the section about AVT Cameras below.
This package aims to provide an easy solution for communicating with multiple Webcams and other Cameras. A basic example is shown below, more examples can be found on GitHub:
If you want to use the Manager to start all the camera Applications you can use the ManagerApp. This will start the desired camera backends, which can be accessed using the API-endpoints.
WARNING: If you want to have as little latency as possible and a high framerate consider using the standalone mode described below.
from camera_management.camera_management_app.manager_interface import ManagerApp
from pathlib import Path
manager_backend = ManagerApp(path_to_configs=Path(__file__).parent / "data", autostart=True)
manager_backend.start()
For a detailed explanation on how the configs work and how to build your own config see the section "configs" below. The config name can be anything you want.
127.0.0.1
.from camera_management.frontends.basic_frontend import manager_interface
manager_frontend = manager_interface(host="127.0.0.1", port=8090, autostart=True)
manager_frontend
to get an actual camera interface. The manager only manages the cameras, but it does not
provide any streams. It only provides the interfaces to the actual camera streams# Get all ports of the actual configured cameras
print(camera_infos = manager_frontend.get_configured_cams())
The command above might print something like:
CAM TYPE CAM SERIAL CONFIG TYPE CONFIG INDIVIDUAL PORT PORT ACTIVE CALIBRATION AVAILABLE
--------------------- -------------------- ------------- ------------------- ------ ------------- -----------------------
4K USB CAMERA 12567 True False 8091 True False
webcam V011R007C001B004 True False 8092 True False
Use this information to choose the camera you want to access.
# Get a camera interface by its port
camera_interface = manager_frontend.get_interface_by_port(8091)
while True:
data = camera_interface.fetch_image_data()
cv2.imshow("Stream", data.image)
if cv2.waitKey(20) == ord("q"):
break
The above while loop continuously polls the latest image from the camera backend and displays it using OpenCV. The
function fetch_data()
is a convenience
function, the same result can be achieved using the code below, using requests.
import requests
import pickle
import cv2
host = '127.0.0.1'
port = 8090
while True:
try:
response = requests.get(f"http://{host}:{port}/data/imageProcessor")
except requests.exceptions.ConnectionError:
continue
if response.status_code == 200:
cv2.imshow("Moin", pickle.loads(response.content).image)
if cv2.waitKey(20) == ord("q"):
break
set_general_setting
to set camera settings. Since this
library works for
a range of vastly different cameras, not every setting can be applied to each camera. Check your specific camera to
see, if a specific settings is applicable.
Below is an example of setting the CAP_PROP_FRAME_WIDTH
property, meaning the width of the output image
to 400
px. Afterward, the settings is read using
get_general_setting
. Finally, the current active camera description is shown using the description
property of
the camera interface.Important: When using the convenience function set_general_setting
, the setting is automatically read back, so you
can see if it was successful.
from camera_management import SETTINGS
print(camera_interface.set_general_setting(SETTINGS.CAP_PROP_FRAME_WIDTH, 400))
print(camera_interface.get_general_setting(SETTINGS.CAP_PROP_FRAME_WIDTH))
print(camera_interface.description)
If you want to achieve a higher FPS and lower latency you should use the standalone mode.
A valid camera description file can be created using the following code. It will create description files for every currently connected cam and save them to the supplied directory.
from pathlib import Path
from camera_management.tools.create_description import create_basic_description
create_basic_description(Path('<PATH_WHERE_CONFIG_SHOULD_BE_STORED>'))
This will create valid, yet empty description files in the given directory. A valid description file might look like this:
{
"information": {
"standard_resolution": {
"x": 1920,
"y": 1080,
"channels": 3
},
"available_resolutions": [
{
"x": 1920,
"y": 1080,
"channels": 3
}
],
"device": {
"path": 0,
"vendor_id": "0x4f2",
"product_id": "0xb79e",
"vendor": "SunplusIT Inc",
"product": "USB2.0 FHD UVC WebCam",
"serial": null,
"backend": 1200,
"transp_type": "usb ",
"unique_id": "0x14000004f2b79e",
"device_type": "AVCaptureDeviceTypeExternalUnknown",
"is_used": false
},
"resolution_roi_coupled": false
},
"calibration": {
"mode": "type",
"available": false,
"values": null,
"model": null
},
"config": {},
"debug": {
"last_updated": "22-01-2024 16:35:47",
"created_on_platform": "darwin"
}
}
AVT (Allied Vision Technologies) Cameras or all other cameras that use the Vimba or VimbaX backend are supported in this project, but need to be set up manually, since the Vimba / Vimba X python wrapper currently does not sit on pypi. Vimba X is currently the most recent version of Vimba. Although it shares many features with Vimba it is a standalone release. The python wrapper for Vimba X is called VmbPy (not to be confused with Vimba Python, which is the Python wrapper for Vimba - without X). To install VmbPy you have to follow the instructions here.
Warning: VmbaPy is not very stable at the moment and does require some tweaks to run on Linux with Ethernet Cams.
FAQs
Camera Management Module
We found that camera-management demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.