Python wrapper for Novitec Camera API (Windows only)
Project description
NovitecCameraAPIWinPy
NovitecCameraAPIWinPy is a Python API for the Novitec Camera API in C++ (Windows only).
With NovitecCameraAPIWinPy, you can:
- Control the camera
- Capture images
Documentation
See documentation.
Basic Installation
pip install NovitecCameraAPIWinPy
Check the Currently Installed Version
pip show NovitecCameraAPIWinPy
Upgrade to the Latest Version
pip install --upgrade NovitecCameraAPIWinPy
Quick Start
pip install NovitecCameraAPIWinPy
import sys
from ctypes import *
from NovitecCameraAPIWinPy import NovitecCamera
import numpy as np
import cv2
cv2.namedWindow("image", flags=cv2.WINDOW_NORMAL)
cv2.resizeWindow(winname="image", width=512, height=270)
# Create an instance of the NovitecCamera class
novitec_camera = NovitecCamera()
# Discover available devices
novitec_camera.discover()
# Connect to the device using its serial number
serial_number = "S3XS0001" # Example serial number
ret = novitec_camera.connect_by_serial_number(serial_number)
if ret.errCode != 0:
print(f"Connection failed for the device with serial number {serial_number}: {ret.errMessage}")
sys.exit()
else:
print(f"Connection successful for the device with serial number {serial_number}")
# Start streaming
ret = novitec_camera.start()
if ret.errCode != 0:
print(f"Failed to start streaming: {ret.errMessage}")
sys.exit()
# Capture and display images in a loop until 'q' is pressed
while cv2.waitKey(1) & 0xFF != ord('q'):
ret, image = novitec_camera.get_image()
if ret.errCode == 0:
try:
if image.payloadType == 1: # Raw image
cv_img = np.frombuffer(image.data, dtype=np.uint8).reshape((image.height, image.width))
cv_img_color = cv2.cvtColor(cv_img, cv2.COLOR_BayerBG2BGR)
cv2.imshow("image", cv_img_color)
elif image.payloadType == 5: # JPEG image
data_pointer = cast(image.data, POINTER(c_ubyte))
jpeg_data = np.ctypeslib.as_array(data_pointer, shape=(image.dataSize,))
cvimgColor = cv2.imdecode(jpeg_data, cv2.IMREAD_COLOR)
if cvimgColor is not None:
cv2.imshow("image", cvimgColor)
else:
print("Error: Could not decode the image.")
except Exception as e:
print(f"Exception occurred: {e}")
# Destroy all OpenCV windows
cv2.destroyAllWindows()
# Stop streaming
ret = novitec_camera.stop()
if ret.errCode != 0:
print(f"Failed to stop streaming: {ret.errMessage}")
# Disconnect the camera
ret = novitec_camera.disconnect()
if ret.errCode != 0:
print(f"Failed to disconnect the device: {ret.errMessage}")
else:
print("Disconnected successfully")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file NovitecCameraAPIWinPy-0.0.6.tar.gz.
File metadata
- Download URL: NovitecCameraAPIWinPy-0.0.6.tar.gz
- Upload date:
- Size: 2.2 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b4d775ef38f577801c63775f80cc15fe33aeaf9df03a682bb10ea77e87be33f6
|
|
| MD5 |
65bdebff5a548928a464259a28f62f94
|
|
| BLAKE2b-256 |
265137b65ebe15157880c5e9848082d10ea9b4cca011e447749d4f97fab45199
|
File details
Details for the file NovitecCameraAPIWinPy-0.0.6-py3-none-any.whl.
File metadata
- Download URL: NovitecCameraAPIWinPy-0.0.6-py3-none-any.whl
- Upload date:
- Size: 2.2 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2d5eb8559102d02cc0c87e95e03438ace6a47aaf81fd59f8666f70d53da01454
|
|
| MD5 |
efd54597c97a61d544272a69b4c0712a
|
|
| BLAKE2b-256 |
c12fe0feb5a32186aa79bda9747488f45bdaf0dd17e7fd3b9dff083705b76979
|