Skip to main content

Python wrapper for Hikrobot MVS cameras

Project description

Hikrobot SDK – Python Wrapper

A lightweight, Pythonic wrapper around the Hikrobot (Hikvision Industrial) MVS Camera SDK, simplifying device enumeration, camera detection, frame grabbing, and pixel format conversion.

This package includes a wrapper for the official MvCameraControl SDK through the MvImport Python bindings.


⭐ Features

  • Thread-safe device enumeration
  • Device list caching for performance
  • Find camera by serial number
  • Simple CameraDevice lifecycle
  • Raw frame grabbing (MV_CC_GetOneFrameTimeout)
  • Convert frames to RGB
  • Supports GigE & USB3 Hikrobot cameras
  • Set camera parameters (int, float, bool, enum, command)

📦 Installation

Note: The official Hikrobot MVS SDK must be installed separately.

Install via pip:

pip install hikrobot-sdk

Ensure the Hikrobot SDK is installed:

  • Linux: /opt/MVS/
  • Windows: C:\Program Files\MVS\Development\

📁 Package Structure

hikrobot/
│
├── hikrobot_sdk.py
└── MvImport/
    ├── MvCameraControl_class.py
    └── (other Hikrobot SDK Python files)

🚀 Quick Start

🔍 Enumerate Devices

from hikrobot import DeviceManager

devices = DeviceManager.enumerate()
print("Devices found:", devices.nDeviceNum)

🎯 Find a Camera by Serial Number

from hikrobot import DeviceManager

device_info = DeviceManager.find_camera("YOUR_CAMERA_SN")

if device_info:
    print("Camera found")
else:
    print("Camera not found")

📷 Open Camera and Grab a Frame

from hikrobot import CameraDevice, DeviceManager

device_info = DeviceManager.find_camera("YOUR_CAMERA_SN")
cam = CameraDevice(device_info)

if cam.create_handle_and_open():
    cam.start_grabbing()

    frame = cam.get_one_frame(1000)
    if frame:
        raw_bytes, info = frame
        print("Frame:", info.nWidth, "x", info.nHeight)

    cam.stop_grabbing()
    cam.close_and_destroy()

🎨 Convert Raw Frame to RGB

raw_bytes, info = cam.get_one_frame()
rgb_bytes = cam.convert_to_rgb(raw_bytes, info)

🔧 Set Camera Parameters

cam.set_value("ExposureTime", 12000)
cam.set_value("Gain", 5)
cam.set_value("TriggerMode", 1)

🧠 Class Overview

DeviceManager

  • Thread-safe device scanning
  • Caches device list
  • Extracts serial numbers for GigE & USB cameras

Methods:

  • enumerate()
  • find_camera(serial_number)
  • refresh()

CameraDevice

  • High-level wrapper around MvCamera instance

Methods:

  • create_handle_and_open()
  • start_grabbing()
  • stop_grabbing()
  • get_one_frame(timeout_ms)
  • convert_to_rgb(raw_bytes, frame_info)
  • close_and_destroy()
  • set_value(name, value)
  • _register_exception_callback()

📄 License

MIT License.

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

hikrobot_sdk-0.1.0.tar.gz (68.8 kB view details)

Uploaded Source

Built Distribution

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

hikrobot_sdk-0.1.0-py3-none-any.whl (70.6 kB view details)

Uploaded Python 3

File details

Details for the file hikrobot_sdk-0.1.0.tar.gz.

File metadata

  • Download URL: hikrobot_sdk-0.1.0.tar.gz
  • Upload date:
  • Size: 68.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.1

File hashes

Hashes for hikrobot_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 54eeb070a377e9c9ed3cae70049d4d8120e6f813162feb853f8637e9ce1a7db3
MD5 7d015c238d206eeac553e5b4d2f6d4ef
BLAKE2b-256 cbfeba2ad8ec8e0bbaef06d121ed9be98fd36dd36ccdd57e9ffb9b9e885355bb

See more details on using hashes here.

File details

Details for the file hikrobot_sdk-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: hikrobot_sdk-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 70.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.1

File hashes

Hashes for hikrobot_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d1b02393d6bc961f861eaed55cabfc583cf382641441dba2424caf61290556c1
MD5 065acd58611ffa51723832b35b312db7
BLAKE2b-256 70bd7d72b878620cbb9c4d26fbf4d5351dc606cfc2fec89158ee6d714c58ea60

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