Skip to main content

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.

Quick Start

pip install NovitecCameraAPIWinPy
import sys

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

NovitecCameraAPIWinPy-0.0.5.tar.gz (2.2 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

NovitecCameraAPIWinPy-0.0.5-py3-none-any.whl (2.2 MB view details)

Uploaded Python 3

File details

Details for the file NovitecCameraAPIWinPy-0.0.5.tar.gz.

File metadata

  • Download URL: NovitecCameraAPIWinPy-0.0.5.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

Hashes for NovitecCameraAPIWinPy-0.0.5.tar.gz
Algorithm Hash digest
SHA256 b81bda82ec26c271b90f555ffe4dfc521b58290331617b84c65ae7f377dbe20d
MD5 b630dc28e12772faf964d0b56b179a67
BLAKE2b-256 6c2d94e1b4a07b9722bcd28ab32b728bd57d96ebf281702ce3dc8f933970459e

See more details on using hashes here.

File details

Details for the file NovitecCameraAPIWinPy-0.0.5-py3-none-any.whl.

File metadata

File hashes

Hashes for NovitecCameraAPIWinPy-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 2abc088dfe3cb2fda29f3139458c84cde8208c5613a36d9daae064997252c36d
MD5 7eeb1b41a356a9ad130e10236fba3c90
BLAKE2b-256 df07d8cdf1235184117a4631effc2d8861c1be44daf2f72cebafafbde68dab5e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page