API Reference#

pyDCAM.dcamapi module#

exception pyDCAM.dcamapi.DCAMError(error_code)[source]#

Bases: Exception

class pyDCAM.dcamapi.HDCAM(index=0)[source]#

Bases: object

Camera handle.

It’s recommended to use with statement to ensure the camera is closed properly.

Parameters:

index (int, optional) – The index of the camera to open. Defaults to 0.

Examples

>>> with HDCAM() as hdcam:
>>>     print(hdcam.model)
>>>     print(hdcam.camera_id)
property bus: str#
property camera_id: str#

The camera ID.

dcambuf_alloc(framecount=64)[source]#

Allocates internal image buffers for image acquisition.

This function does not start the capture. To start capture, dcamcap_start() should be called.

When the internal buffers are no longer necessary, call dcambuf_release() to release them.

Parameters:

framecount (int, optional) – The number of frames to allocate. Defaults to 64.

dcambuf_copyframe(iFrame=-1) ndarray[source]#

Returns a NumPy array containing the captured image copied from the buffer.

Parameters:

iFrame (int, optional) – The frame index. Defaults to -1, which retrieves the latest captured image.

Returns:

img – The captured image buffer.

Return type:

np.ndarray

dcambuf_lockframe(iFrame=-1) ndarray[source]#

Returns a NumPy array pointing to the captured image buffer.

If the host software dcambuf_copyframe needs to copy the image data into its own memory, use dcambuf_copyframe() instead of this function.

Parameters:

iFrame (int, optional) – The frame index. Defaults to -1, which retrieves the latest captured image.

Returns:

img – The captured image buffer.

Return type:

np.ndarray

See also

HDCAM.dcambuf_copyframe

The function that copied the captured image buffer instead of pointing to it.

dcambuf_release(iKind=0)[source]#

Release the internal image buffers allocated by dcambuf_alloc().

dcamcap_firetrigger()[source]#

Fire a software trigger.

This is only effective if the software trigger mode.

dcamcap_start(mode=DCAMCAP_START.DCAMCAP_START_SEQUENCE)[source]#

start capturing images.

Before calling this function, a capturing buffer should be prepared.

Parameters:

mode (DCAMCAP_START, optional) – The capture mode. Defaults to DCAMCAP_START_SEQUENCE. With the DCAMCAP_START_SEQUENCE mode, capturing will be continuing until the dcamcap_stop() function is called. With the DCAMCAP_START_SNAP mode, capturing is terminated when the capturing buffer is filled or until the dcamcap_stop() function is called.

See also

HDCAM.dcamcap_stop

Stop capturing images.

HDCAM.dcambuf_alloc

Allocate internal image buffers for image acquisition.

dcamcap_status()[source]#
dcamcap_stop()[source]#

Stop capturing images.

See also

HDCAM.dcamcap_start

Start capturing images.

dcamcap_transferinfo() Tuple[int, int][source]#

Get the transfer information.

Returns:

  • nNewestFrameIndex (int) – The index of the newest frame of the transferred image.

  • nFrameCount (int) – The number of iamges has been transferred.

dcamdev_close()[source]#

Close the camera handle.

dcamdev_getstring(iString: DCAM_IDSTR) str[source]#

Get the string of the camera.

Parameters:

iString (DCAM_IDSTR) – The string to get.

dcamprop_getattr(iProp: DCAMPROPMODEVALUE)[source]#
dcamprop_getname(iProp: DCAMIDPROP) str[source]#

Get the name of the property.

Parameters:

iProp (DCAMIDPROP) – The property ID.

Returns:

The name of the property.

Return type:

str

dcamprop_getvalue(iProp: DCAMIDPROP) float[source]#

Get the value of the property.

Parameters:

iProp (DCAMIDPROP) – The property ID.

Returns:

The value of the property.

Return type:

float

dcamprop_ids(option: DCAMPROPOPTION = DCAMPROPOPTION.DCAMPROP_OPTION_SUPPORT) DCAMIDPROP[source]#

Generator for enumerating the property IDs.

Parameters:

option (DCAMPROPOPTION, optional) – Defaults to the properties supported by the device.

Yields:

iProp (DCAMIDPROP) – The property ID.

Examples

>>> with HDCAM() as hdcam:
>>>     for iProp in hdcam.dcamprop_ids():
>>>         print(hdcam.dcamprop_getname(iProp))
dcamprop_setgetvalue(iProp: DCAMIDPROP, fValue: float) float[source]#

Set the value of the property and get the accurate value if successful.

Parameters:

iProp (DCAMIDPROP) – The property ID.

Returns:

The value of the property.

Return type:

float

Raises:

DCAMError – If the device does not support a property. An error with code DCAMERR_NOTSUPPORT is raised. If a property does not have auto-rounding and the fValue is not a valid value, an error with code DCAMERR_INVALIDPARAM is raised.

dcamprop_setvalue(iProp: DCAMIDPROP, fValue)[source]#

Set the value of the property.

Parameters:

iProp (DCAMIDPROP) – The property ID.

Raises:

DCAMError – If the device does not support a property. An error with code DCAMERR_NOTSUPPORT is raised. If a property does not have auto-rounding and the fValue is not a valid value, an error with code DCAMERR_INVALIDPARAM is raised.

dcamwait_open() HDCAMWAIT[source]#

Open a wait handle for the camera.

See also

HDCAMWAIT.dcamwait_close

Close the wait handle.

property exposure_time: float#
property model: str#

The camera model.

property readout_speed: DCAMPROPMODEVALUE#
property subarray_mode: bool#

The subarray mode. True for on, False for off.

property subarray_pos: Tuple[int, int]#

The subarray position in (x, y)

property subarray_size: Tuple[int, int]#

The subarray size in (width, height)

class pyDCAM.dcamapi.HDCAMWAIT(hwait, supportevent)[source]#

Bases: object

Wait handle for the camera. It is used to block the program and wait for a specific event.

Instead of instantiating this class directly, use HDCAM.dcamwait_open() to open a wait handle.

See also

HDCAM.dcamwait_open

Open a wait handle for the camera.

dcamwait_abort()[source]#

Abort waiting for the event.

dcamwait_close()[source]#
dcamwait_start(eventmask=DCAMWAIT_EVENT.DCAMWAIT_CAPEVENT_FRAMEREADY, timeout=DCAMWAIT_TIMEOUT.DCAMWAIT_TIMEOUT_INFINITE)[source]#

Start waiting for a specific event.

Parameters:
  • eventmask (DCAMWAIT_EVENT, optional) – The event to wait for. Defaults to waiting for the next frame ready event.

  • timeout (int, optional) – The timeout in milliseconds. Defaults to no timeout.

pyDCAM.dcamapi.check_status(dcamerr)[source]#
pyDCAM.dcamapi.dcamapi_init()[source]#

Initialize the DCAM-API. It should be called before using any other DCAM-API functions.

pyDCAM.dcamapi.dcamapi_uninit()[source]#

Uninitialize the DCAM-API.

pyDCAM.dcamapi.failed(dcamerr)[source]#