hikrobotcamlib 1.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,8 @@
1
+ """ Package HIK Robotics camera drivers and some helpers"""
2
+ from .types import Frame, DeviceList, DeviceTransport
3
+ from .wrapper import Camera
4
+
5
+ __version__ = "1.0.0" # NOTE Use `bump2version --config-file patch` to bump versions correctly
6
+
7
+
8
+ __all__ = ["Frame", "Camera", "DeviceList", "__version__", "DeviceTransport"]
@@ -0,0 +1,34 @@
1
+ """CLI entrypoints for hikrobotcamlib"""
2
+ import logging
3
+
4
+ import click
5
+ from libadvian.logging import init_logging
6
+
7
+ from hikrobotcamlib import __version__, DeviceList
8
+ from hikrobotcamlib.types import DeviceTransport
9
+
10
+ LOGGER = logging.getLogger(__name__)
11
+
12
+
13
+ @click.command()
14
+ @click.version_option(version=__version__)
15
+ @click.option("-l", "--loglevel", help="Python log level, 10=DEBUG, 20=INFO, 30=WARNING, 40=CRITICAL", default=30)
16
+ @click.option("-v", "--verbose", count=True, help="Shorthand for info/debug loglevel (-v/-vv)")
17
+ @click.option("--usb", is_flag=True, help="Use USB transport")
18
+ @click.option("--gige/--no-gige", is_flag=True, help="Use GigE transport", default=True)
19
+ def hikrobotcamlib_cli(loglevel: int, verbose: int, usb: bool, gige: bool) -> None:
20
+ """List cameras"""
21
+ if verbose == 1:
22
+ loglevel = 20
23
+ if verbose >= 2:
24
+ loglevel = 10
25
+ init_logging(loglevel)
26
+ LOGGER.setLevel(loglevel)
27
+ transports = 0
28
+ if usb:
29
+ transports |= DeviceTransport.USB
30
+ if gige:
31
+ transports |= DeviceTransport.GIGE
32
+
33
+ for dev in DeviceList(transports):
34
+ click.echo("Found {}".format(dev))
@@ -0,0 +1,71 @@
1
+ """Errors"""
2
+ from typing import Optional
3
+
4
+ from .hiklibs import MvErrorDefine_const
5
+
6
+ MV_ERROR_CODES = {
7
+ getattr(MvErrorDefine_const, name): name for name in dir(MvErrorDefine_const) if name.startswith("MV_")
8
+ }
9
+
10
+
11
+ class HIKException(Exception):
12
+ """Generic baseclass for catching things"""
13
+
14
+
15
+ class EnumerationError(HIKException, RuntimeError):
16
+ """Failure to enumerate cameras"""
17
+
18
+
19
+ class CamHandleError(HIKException, RuntimeError):
20
+ """Errors related to camera handles"""
21
+
22
+
23
+ class HandleCreateError(CamHandleError):
24
+ """Failure to create a handle for the camera"""
25
+
26
+
27
+ class HandleDestroyError(CamHandleError):
28
+ """Failure to destroy a handle for the camera"""
29
+
30
+
31
+ class CamStateError(HIKException, RuntimeError):
32
+ """Errors related to camera state, like open/close"""
33
+
34
+
35
+ class CamOpenError(CamStateError):
36
+ """Could not open camera"""
37
+
38
+
39
+ class CamCloseError(CamStateError):
40
+ """Could not close camera"""
41
+
42
+
43
+ class CamSettingsError(CamStateError):
44
+ """Could not not set some camera value"""
45
+
46
+
47
+ class CamClosed(CamStateError):
48
+ """Camera is closed and action needs it to be open"""
49
+
50
+
51
+ class InvalidTransport(HIKException, ValueError):
52
+ """A problem with the transport value"""
53
+
54
+
55
+ class FrameError(HIKException, RuntimeError):
56
+ """A problem with frames"""
57
+
58
+
59
+ class CamCommandError(HIKException, RuntimeError):
60
+ """Errors related to sending commands to camera, like SW trigger"""
61
+
62
+
63
+ class CamReadError(HIKException, RuntimeError):
64
+ """Errors related to reading values from the camera"""
65
+
66
+
67
+ def mv_errstr(code: int) -> Optional[str]:
68
+ """Return the constant name that matches the error code"""
69
+ if code not in MV_ERROR_CODES:
70
+ return None
71
+ return MV_ERROR_CODES[code]
@@ -0,0 +1,21 @@
1
+ """helpers"""
2
+ from typing import Tuple, Iterable
3
+
4
+
5
+ def get_octets(src: int) -> Tuple[int, int, int, int]:
6
+ """Get the octets from an integer, useful for ips etc. returned highest first"""
7
+ nip1 = (src & 0xFF000000) >> 24
8
+ nip2 = (src & 0x00FF0000) >> 16
9
+ nip3 = (src & 0x0000FF00) >> 8
10
+ nip4 = src & 0x000000FF
11
+ return nip1, nip2, nip3, nip4
12
+
13
+
14
+ def get_str(cstr: Iterable[int]) -> str:
15
+ """Convert C string from the camera structs into str"""
16
+ ret = ""
17
+ for val in cstr:
18
+ if val == 0x0:
19
+ break
20
+ ret += chr(val)
21
+ return ret
@@ -0,0 +1,39 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Don't change this file, it was auto generated by Const_file_Generater.py.
3
+ # pylint: skip-file
4
+
5
+ MV_UNKNOW_DEVICE = 0x00000000 # ch:未知设备类型,保留意义 | en:Unknown Device Type, Reserved
6
+ MV_GIGE_DEVICE = 0x00000001 # ch:GigE设备 | en:GigE Device
7
+ MV_1394_DEVICE = 0x00000002 # ch:1394-a/b 设备 | en:1394-a/b Device
8
+ MV_USB_DEVICE = 0x00000004 # ch:USB3.0 设备 | en:USB3.0 Device
9
+ MV_CAMERALINK_DEVICE = 0x00000008 # ch:CameraLink设备 | en:CameraLink Device
10
+ INFO_MAX_BUFFER_SIZE = 64
11
+ MV_MAX_TLS_NUM = 8
12
+ MV_MAX_DEVICE_NUM = 256
13
+ MV_IP_CFG_STATIC = 0x05000000
14
+ MV_IP_CFG_DHCP = 0x06000000
15
+ MV_IP_CFG_LLA = 0x04000000
16
+ MV_NET_TRANS_DRIVER = 0x00000001
17
+ MV_NET_TRANS_SOCKET = 0x00000002
18
+ MV_MATCH_TYPE_NET_DETECT = 0x00000001 # ch:网络流量和丢包信息 | en:Network traffic and packet loss information
19
+ MV_MATCH_TYPE_USB_DETECT = (
20
+ 0x00000002 # ch:host接收到来自U3V设备的字节总数 | en:The total number of bytes host received from U3V device
21
+ )
22
+ MV_MAX_XML_NODE_NUM_C = 128
23
+ MV_MAX_XML_NODE_STRLEN_C = 64
24
+ MV_MAX_XML_STRVALUE_STRLEN_C = 64
25
+ MV_MAX_XML_DISC_STRLEN_C = 512
26
+ MV_MAX_XML_ENTRY_NUM = 10
27
+ MV_MAX_XML_PARENTS_NUM = 8
28
+ MV_MAX_XML_SYMBOLIC_STRLEN_C = 64
29
+ MV_MAX_XML_SYMBOLIC_NUM = 64
30
+ MV_EXCEPTION_DEV_DISCONNECT = 0x00008001 # ch:设备断开连接 | en:The device is disconnected
31
+ MV_EXCEPTION_VERSION_CHECK = 0x00008002 # ch:SDK与驱动版本不匹配 | en:SDK does not match the driver version
32
+ MV_ACCESS_Exclusive = 1
33
+ MV_ACCESS_ExclusiveWithSwitch = 2
34
+ MV_ACCESS_Control = 3
35
+ MV_ACCESS_ControlWithSwitch = 4
36
+ MV_ACCESS_ControlSwitchEnable = 5
37
+ MV_ACCESS_ControlSwitchEnableWithKey = 6
38
+ MV_ACCESS_Monitor = 7
39
+ MAX_EVENT_NAME_SIZE = 128 # 相机Event事件名称最大长度 | en:Max length of event name