Camera Capture
Introduction
These functions are responsible for capturing images from a camera.
VxDiscoverCameraDevice
Function:
- C++
- Python
- C#
- C
int VxDiscoverCameraDevices(std::vector<std::string>& devList)
def VxDiscoverCameraDevices()
int VxDiscoverCameraDevices(StringVector devList)
int vx_discover_camera_devices(const char*** devList)
Function Description:
- This Function retrieves a list of available camera devices and stores the device names in a vector of wide strings.
- C# : The caller must create a
StringVector
instance before calling this function. - C : The device list need to release by
vx_release_device_list
function.
Parameter Description:
- devList : A vector of wide strings to store the retrieved devices.
- Return:
- The number of camera devices detected
Example:
- C++
- Python
- C#
- C
// declare the vector to save the list of devices
std::vector<std::string> dev_list;
// discover the devices
int deviceCount = VxDiscoverCameraDevices(dev_list);
std::cout << "Found " << deviceCount << " camera(s):" << std::endl;
// print dev_list
for (size_t i = 0; i < devList.size(); i++) {
std::cout << "[" << i << "] " << devList[i] << std::endl;
}
# discover the devices
result, camera_list = pyvinzionsdk.VxDiscoverCameraDevices()
print("Return code:", result)
print("Discovered cameras:", camera_list)
# print camera_list
for camera in camera_list:
print(camera)
// discover the devices
StringVector devList = new StringVector();
int cam_num = CSVizionSDK.VxDiscoverCameraDevices(devList);
Console.WriteLine($"Devices: {cam_num}");
// print devList
for (int i = 0; i < devList.Count; i++)
{
Console.WriteLine($"[{i}] {devList[i]}");
}
// declare the vector to save the list of devices
const char**dev_list = NULL;
// discover the devices
int dev_num = vx_discover_camera_devices(&dev_list);
printf("Found %d camera(s):\n", dev_num);
// print dev_list
int i = 0;
while (dev_list[i] != NULL) {
printf("[%d] %s\n", i, dev_list[i]);
i++;
}
vx_release_device_list
This function is only supported in C.
Function:
void vx_release_device_list(const char** devList)
Function Description:
- This function release device list retrieved from vx_discover_camera_devices().
Parameter Description:
- devList : A vector of wide strings to store the retrieved devices.
Example:
vx_release_device_list(dev_list);
VxInitialCameraDevice
Function:
- C++
- Python
- C#
- C
std::shared_ptr<VxCamera> VxInitialCameraDevice(int devIdx)
def VxInitialCameraDevice(devIdx)
VxCamera VxInitialCameraDevice(int devIdx)
vx_camera vx_initial_camera_device(int devIdx)
Function Description:
- This function initializes a VxCamera instance by selecting an index from the device list retrieved from VxDiscoverCameraDevice().
- It returns a shared pointer to the created VxCamera object, enabling shared ownership and automatic memory management.
- C# : The returned VxCamera object can be used directly in C# without manually managing memory.
- C : The returned vx_camera object need to release by
vx_release_camera
function.
Parameter Description:
- devIdx : An integer specifying the index of the device to be opened in the device list.
- return a shared pointer to the initialized device, return nullptr = FAIL
Example:
- C++
- Python
- C#
- C
// initial the camera of index 0
std::shared_ptr<VxCamera> vxcam = VxInitialCameraDevice(0);
# initial the camera of index 0
vxcam = pyvizionsdk.VxInitialCameraDevice(0)
// initial the camera of index 0
VxCamera vxcam = CSVizionSDK.VxInitialCameraDevice(0);
// initial the camera of index 0
vx_camera cam = vx_initial_camera_device(0);
vx_release_camera
This function is only supported in C.
Function:
void vx_release_camera(vx_camera vxcam)
Function Description:
- This function release camera retrieved from vx_initial_camera_device().
Parameter Description:
- vxcam : A vx_camera object, enabling shared device ownership.
Example:
vx_release_camera(vxcam);
VxOpen
Function:
- C++
- Python
- C#
- C
int VxOpen(std::shared_ptr<VxCamera> vxcam)
def VxOpen(vxcam)
int VxOpen(VxCamera vxcam)
int vx_open(vx_camera vxcam)
Function Description:
- This function is used to open a device obtained by calling VxInitialCameraDevice().
Parameter Description:
- vxcam : A pointer shared ownership of a camera obtained from VxInitialCameraDevice().
- return 0 = PASS, return -1 = FAIL.
Example:
- C++
- Python
- C#
- C
// open the camera
VxOpen(vxcam)
# open camera
pyvizionsdk.VxOpen(vxcam)
// open camera
CSVizionSDK.VxOpen(vxcam)
// open camera
vx_open(vxcam)
VxClose
Function:
- C++
- Python
- C#
- C
int VxClose(std::shared_ptr<VxCamera> vxcam)
def VxClose(vxcam)
int VxClose(VxCamera vxcam)
int vx_close(vx_camera vxcam)
Function Description:
- This function is used to close a device obtained by calling VxInitialCameraDevice().
Parameter Description:
- vxcam : A pointer shared ownership of a camera obtained from VxInitialCameraDevice().
- return 0 = PASS, return -1 = FAIL.
Example:
- C++
- Python
- C#
- C
// close the camera
VxClose(vxcam);
# close the camera
pyvizionsdk.VxClose(vxcam)
// close the camera
CSVizionSDK.VxClose(vxcam)
// close the camera
vx_close(vxcam);
VxIsVizionCamera
Function:
- C++
- Python
- C#
- C
int VxIsVizionCamera(std::shared_ptr<VxCamera> vxcam)
def VxIsVizionCamera(vxcam)
int VxIsVizionCamera(VxCamera vxcam)
int vx_is_vizion_camera(vx_camera vxcam)
Function Description:
- Verify whether the VxCamera device is TechNexion UVC or MIPI product or not.
Parameter Description:
- vxcam : A pointer shared ownership of a camera obtained from VxInitialCameraDevice().
- return 0 = PASS, return -1 = FAIL.
Example:
- C++
- Python
- C#
- C
// check the type of camera
int ret = VxIsVizionCamera(vxcam);
# check the type of camera
result = pyvizionsdk.VxIsVizionCamera(vxcam)
// check the type of camera
int ret = CSVizionSDK.VxIsVizionCamera(vxcam)
// check the type of camera
int ret = vx_is_vizion_camera(vxcam);
VxGetDeviceName
Function:
- C++
- Python
- C#
- C
int VxGetDeviceName(std::shared_ptr<VxCamera> vxcam, std::string& deviceName)
def VxGetDeviceName(vxcam)
int VxGetDeviceName(VxCamera vxcam, ref string deviceName)
int vx_get_device_name(vx_camera vxcam, const char** deviceName)
Function Description:
- This function is used to obtain the device name.
Parameter Description:
- vxcam : A pointer shared ownership of a camera obtained from VxInitialCameraDevice().
- deviceName : A reference of string variable to store the device name.
- Return:
- return 0 = PASS, return -1 = FAIL.
- Python : tuple(return_code, deviceName)
return_code : return 0 = PASS, return -1 = FAIL
Example:
- C++
- Python
- C#
- C
std::string deviceName;
// get the device name of camera
VxGetDeviceName(vxcam, deviceName);
# get the device name of camera
result, name = pyvizionsdk.VxGetDeviceName(vxcam)
// get the device name of camera
string deviceName = "";
CSVizionSDK.VxGetDeviceName(vxcam, ref deviceName);
const char* deviceName;
// get the device name of camera
vx_get_device_name(vxcam, &deviceName);
VxGetDeviceInterfaceType
Function:
- C++
- Python
- C#
- C
int VxGetDeviceInterfaceType(std::shared_ptr<VxCamera> vxcam, VX_CAMERA_INTERFACE_TYPE& type);
def VxGetDeviceInterfaceType(vxcam)
int VxGetDeviceInterfaceType(VxCamera vxcam, out VX_CAMERA_INTERFACE_TYPE type)
int vx_get_device_interface_type(vx_camera vxcam, vx_camera_interface_type* type)
Function Description:
- This function is used to obtain the type of device interface.
- The device interface type is set as VX_CAMERA_INTERFACE_TYPE format.
Parameter Description:
-
vxcam : A pointer shared ownership of a camera obtained from VxInitialCameraDevice().
-
type : A VX_CAMERA_INTERFACE_TYPE format variable, which is used to store the interface type.
-
Return:
- return 0 = PASS, return -1 = FAIL
- Python : tuple(return_code, type)
return_code : return 0 = PASS, return -1 = FAIL
-
VX_CAMERA_INTERFACE_TYPE format:
- C++
- Python
- C#
- C
enum class VX_CAMERA_INTERFACE_TYPE {
INTERFACE_USB = 0,
INTERFACE_MIPI_CSI2,
INTERFACE_ETHERNET,
}class VX_CAMERA_INTERFACE_TYPE(Enum):
INTERFACE_USB = 0
INTERFACE_MIPI_CSI2 = 1
INTERFACE_ETHERNET = 2public enum VX_CAMERA_INTERFACE_TYPE{
INTERFACE_USB,
INTERFACE_MIPI_CSI2,
INTERFACE_ETHERNET,
}typedef enum vx_camera_interface_type {
INTERFACE_USB = 0,
INTERFACE_MIPI_CSI2 = 1,
INTERFACE_ETHERNET = 2,
} vx_camera_interface_type;
Example:
- C++
- Python
- C#
- C
VX_CAMERA_INTERFACE_TYPE type;
// get the device interface type of camera
VxGetDeviceInterfaceType(vxcam, type);
result, tyname = pyvizionsdk.VxGetDeviceInterfaceType(vxcam)
VX_CAMERA_INTERFACE_TYPE type;
// get the device interface type of camera
CSVizionSDK.VxGetDeviceInterfaceType(vxcam, out type);
vx_camera_interface_type type;
// get the device interface type of camera
vx_get_device_interface_type(vxcam, &type);
VxGetHardwareID
Function:
- C++
- Python
- C#
- C
int VxGetHardwareID(std::shared_ptr<VxCamera> vxcam, std::string& hwId)
def VxGetHardwareID(vxcam)
int VxGetHardwareID(VxCamera vxcam, ref string hwId)
int vx_get_hardware_id(vx_camera vxcam, const char** hwId)
Function Description:
- This function is used to obtain the hardware ID of the device.
Parameter Description:
- vxcam : A pointer shared ownership of a camera obtained from VxInitialCameraDevice().
- hwId : A reference of string variable to store the hardware ID.
- Return:
- return 0 = PASS, return -1 = FAIL
- Python : tuple(return_code, hwId)
return_code : return 0 = PASS, return -1 = FAIL
Example:
- C++
- Python
- C#
- C
std::string hwId;
// get the hardware ID of camera
VxGetHardwareID(vxcam, hwId);
# get the hardware ID of camera
result, hwId = pyvizionsdk.VxGetHardwareID(vxcam)
string hwId = "";
// get the hardware ID of camera
CSVizionSDK.VxGetHardwareID(vxcam, ref hwId);
const char* hwId;
// get the hardware ID of camera
vx_get_hardware_id(vxcam, &hwId);
VxGetUSBDeviceSpeed
Function:
- C++
- Python
- C#
- C
int VxGetUSBDeviceSpeed(std::shared_ptr<VxCamera> vxcam, VX_USB_DEVICE_SPEED& speed)
def VxGetUSBDeviceSpeed(vxcam)
int VxGetUSBDeviceSpeed(VxCamera vxcam, out VX_USB_DEVICE_SPEED speed)
int vx_get_usb_device_speed(vx_camera vxcam, vx_usb_device_speed* speed)
Function Description:
- This function is used to obtain the speed of the USB device.
- The speed is set as VX_USB_DEVICE_SPEED format.
Parameter Description:
-
vxcam : A pointer shared ownership of a camera obtained from VxInitialCameraDevice().
-
speed : A reference of VX_USB_DEVICE_SPEED format variable to store the speed.
-
Return:
- return 0 = PASS, return -1 = FAIL
- Python : tuple(return_code, speed)
return_code : return 0 = PASS, return -1 = FAIL
-
VX_USB_DEVICE_SPEED format:
- C++
- Python
- C#
- C
enum class VX_USB_DEVICE_SPEED {
USB_DEVICE_SPEED_LOW,
USB_DEVICE_SPEED_FULL,
USB_DEVICE_SPEED_HIGH,
USB_DEVICE_SPEED_SUPER,
USB_DEVICE_SPEED_SUPER_PLUS,
USB_DEVICE_SPEED_UNKNOWN
}class VX_USB_DEVICE_SPEED(Enum):
USB_DEVICE_SPEED_LOW = 0
USB_DEVICE_SPEED_FULL = 1
USB_DEVICE_SPEED_HIGH = 2
USB_DEVICE_SPEED_SUPER = 3
USB_DEVICE_SPEED_SUPER_PLUS = 4
USB_DEVICE_SPEED_UNKNOWN = 5public enum VX_USB_DEVICE_SPEED {
USB_DEVICE_SPEED_LOW,
USB_DEVICE_SPEED_FULL,
USB_DEVICE_SPEED_HIGH,
USB_DEVICE_SPEED_SUPER,
USB_DEVICE_SPEED_SUPER_PLUS,
USB_DEVICE_SPEED_UNKNOWN
}typedef enum vx_usb_device_speed {
USB_DEVICE_SPEED_LOW = 0,
USB_DEVICE_SPEED_FULL = 1,
USB_DEVICE_SPEED_HIGH = 2,
USB_DEVICE_SPEED_SUPER = 3,
USB_DEVICE_SPEED_SUPER_PLUS = 4,
USB_DEVICE_SPEED_UNKNOWN = 5,
} vx_usb_device_speed;
Example:
- C++
- Python
- C#
- C
VX_USB_DEVICE_SPEED speed;
// get the hardware ID of camera
VxGetUSBDeviceSpeed(vxcam, speed);
result, speed = pyvizionsdk.VxGetUSBDeviceSpeed(vxcam)
VX_USB_DEVICE_SPEED speed;
// get the hardware ID of camera
CSVizionSDK.VxGetUSBDeviceSpeed(vxcam, out speed);
vx_usb_device_speed speed;
// get the hardware ID of camera
vx_get_usb_device_speed(vxcam, &speed);
VxGetFormatList
Function:
- C++
- Python
- C#
- C
int VxGetFormatList(std::shared_ptr<VxCamera> vxcam, std::vector<VxFormat>& fmtList)
def VxGetFormatList(vxcam)
int VxGetFormatList(VxCamera vxcam, VxFormatVector fmtList)
int vx_get_format_list(vx_camera vxcam, const vx_format** fmtList)
Function Description:
-
This function is used to obtain the list of formats from the VxCamera device.
info- C++ : The caller must create a vector of VxFormat structures before calling this function.
- C# : The caller must create a
VxFormatVector
instance before calling this function. - C : The format list need to release by
vx_release_format_list
function.
Parameter Description:
-
vxcam : A pointer shared ownership of a camera obtained from VxInitialCameraDevice().
-
fmtList : A vector of VxFormat structures. The function will populate this vector with the available formats.
-
Return:
- return 0 = PASS, return -1 = FAIL
- Python : tuple(return_code, fmtList)
return_code : return 0 = PASS, return -1 = FAIL
-
VxFormat structures:
- C++
- Python
- C#
- C
struct VxFormat {
uint8_t mediatypeIdx;
uint16_t width;
uint16_t height;
uint16_t framerate;
VX_IMAGE_FORMAT format;
}
class VxFormat:
def __init__(self, width, height, framerate, format):
self.width = width
self.height = height
self.framerate = framerate
self.format = format
public struct VxFormat {
public byte mediatypeIdx;
public ushort width;
public ushort height;
public ushort framerate;
public VX_IMAGE_FORMAT format;
}
typedef struct vx_format {
uint8_t mediatypeIdx;
uint16_t width;
uint16_t height;
uint16_t framerate;
vx_image_format format;
} vx_format;
- VX_IMAGE_FORMAT format:
- C++
- Python
- C#
- C
enum class VX_IMAGE_FORMAT {
NONE = 0,
YUY2,
UYVY,
NV12,
MJPG,
BGRA,
BGRX,
BGR,
RGB16,
RGB,
}
class VX_IMAGE_FORMAT(Enum):
VX_IMAGE_FORMAT_NONE = 0
VX_IMAGE_FORMAT_YUY2 = 1
VX_IMAGE_FORMAT_UYVY = 2
VX_IMAGE_FORMAT_NV12 = 3
VX_IMAGE_FORMAT_BGRA = 4
VX_IMAGE_FORMAT_BGRX = 5
VX_IMAGE_FORMAT_BGR = 6
VX_IMAGE_FORMAT_RGB16 = 7
VX_IMAGE_FORMAT_RGB = 8
public enum VX_IMAGE_FORMAT {
NONE,
YUY2,
UYVY,
NV12,
MJPG,
BGRA,
BGRX,
BGR,
RGB16,
RGB,
}
typedef enum vx_image_format {
NONE = 0,
YUY2 = 1,
UYVY = 2,
NV12 = 3,
MJPG = 4,
BGRA = 5,
BGRX = 6,
BGR = 7,
RGB16 = 8,
RGB = 9,
} vx_image_format;
Example:
- C++
- Python
- C#
- C
std::vector<VxFormat> fmt_list;
// get the list of formats from the camera
VxGetFormatList(vxcam, fmt_list);
# get the list of format
result, format_list = pyvizionsdk.VxGetFormatList(vxcam)
VxFormatVector fmtList = new VxFormatVector();
// get the list of formats from the camera
CSVizionSDK.VxGetFormatList(vxcam, fmtList);
const vx_format* fmt_list = NULL;
// get the list of formats from the camera
vx_get_format_list(cam, &fmt_list);
vx_release_format_list
This function is only supported in C.
Function:
void vx_release_format_list(const vx_format* format_list)
Function Description:
- This function release format list retrieved from vx_get_format_list().
Parameter Description:
- format_list : A vx_format type format list.
Example:
const vx_format* fmt_list = NULL;
vx_get_format_list(vxcam, &fmt_list);
vx_release_format_list(fmt_list);
VxSetFormat
Function:
- C++
- Python
- C#
- C
int VxSetFormat(std::shared_ptr<VxCamera> vxcam, VxFormat fmt)
def VxSetFormat(vxcam, fmt)
int VxSetFormat(VxCamera vxcam, VxFormat fmt)
int vx_set_format(vx_camera vxcam, vx_format fmt)
Function Description:
- This function is used to set the specified format to the VxCamera device.
Parameter Description:
- vxcam : A pointer shared ownership of a camera obtained from VxInitialCameraDevice().
- fmt : A VxFormat format to be set. The format must be obtained from the VxGetFormatList().
- return 0 = PASS, return -1 = FAIL.
Example:
- C++
- Python
- C#
- C
// get format list
std::vector<VxFormat> fmt_list;
VxGetFormatList(vxcam, fmt_list);
// set the format
VxSetFormat(vxcam, fmt_list[0]);
# get format
result, format_list = pyvizionsdk.VxGetFormatList(vxcam)
# set format
result = pyvizionsdk.VxSetFormat(vxcam, format_list[0])
// get format list
VxFormatVector fmtList = new VxFormatVector();
CSVizionSDK.VxGetFormatList(vxcam, fmtList);
// set the format
CSVizionSDK.VxSetFormat(vxcam, fmtList[0]);
// get format list
const vx_format* fmt_list = NULL;
vx_get_format_list(cam, &fmt_list);
// set the format
vx_set_format(cam, fmt_list[0]);
VxStartStreaming
Function:
- C++
- Python
- C#
- C
int VxStartStreaming(std::shared_ptr<VxCamera> vxcam)
def VxStartStreaming(vxcam)
int VxStartStreaming(VxCamera vxcam)
int vx_start_streaming(vx_camera vxcam)
Function Description:
- This function is for starting streaming on the device.
Parameter Description:
- vxcam : A pointer shared ownership of a camera obtained from VxInitialCameraDevice().
- return 0 = PASS, return -1 = FAIL.
Example:
- C++
- Python
- C#
- C
// start streaming the camera
VxStartStreaming(vxcam);
# start streaming the camera
pyvizionsdk.VxStartStreaming(vxcam)
// start streaming the camera
CSVizionSDK.VxStartStreaming(vxcam);
// start streaming the camera
vx_start_streaming(vxcam);
VxStopStreaming
Function:
- C++
- Python
- C#
- C
int VxStopStreaming(std::shared_ptr<VxCamera> vxcam)
def VxStopStreaming(vxcam)
int VxStopStreaming(VxCamera vxcam)
int vx_stop_streaming(vx_camera vxcam)
Function Description:
- This function is for stopping streaming on the VxCamera device.
Parameter Description:
- vxcam : A pointer shared ownership of a camera obtained from VxInitialCameraDevice().
- return 0 = PASS, return -1 = FAIL.
Example:
- C++
- Python
- C#
- C
// stop streaming the camera
VxStopStreaming(vxcam);
# stop streaming the camera
pyvizionsdk.VxStopStreaming(vxcam)
// stop streaming the camera
CSVizionSDK.VxStopStreaming(vxcam);
// stop streaming the camera
vx_stop_streaming(vxcam);
VxGetImage
Function:
- C++
- Python
- C#
- C
VX_CAPTURE_RESULT VxGetImage(std::shared_ptr<VxCamera> vxcam,
uint8_t* data,
int* dataSize,
uint16_t timeout)
def VxGetImage(vxcam, timeout, fmt)
VX_CAPTURE_RESULT VxGetImage(VxCamera vxcam,
byte[] data,
out int dataSize,
ushort timeout)
vx_capture_result vx_get_image(vx_camera vxcam,
uint8_t* data,
int* dataSize,
uint16_t timeout)
Function Description:
- This function is used to capture the image from the VxCamera device.
For developers seeking to handle raw data, the vizionsdk-opencv repository provides examples such as saveImg and displayImg, which demonstrate the integration of OpenCV with UYVY and MJPG formats.
Parameter Description:
- vxcam : A pointer shared ownership of a camera obtained from VxInitialCameraDevice().
- data : A pointer to the buffer that stores the raw image data.
- dataSize : A pointer to an integer that stores the size of the raw image data.
- timeout : The timeout value in milliseconds.
- fmt : A VxFormat format to be set.
Return Values:
-
Return Code:
- VX_SUCCESS = 0
- VX_TIMEOUT = -1
- VX_CAM_OCCUPIED = -2
- VX_OTHER_ERROR = -3
- VX_BUFFER_CORRUPTED = -4
-
Python:
- tuple(return_code, img)
return_code : return value same as C++
img is stored in a numpy array
- tuple(return_code, img)
Example:
- C++
- Python
- C#
- C
// get format list
std::vector<VxFormat> fmt_list;
VxGetFormatList(cam, fmt_list);
// get mjpg format
VxFormat mjpg_fmt;
for (auto fmt : fmt_list) {
// find MJPG format
if (fmt.format == VX_IMAGE_FORMAT::MJPG) {
mjpg_fmt = fmt;
}
}
// set the MJPG format
VxSetFormat(cam, mjpg_fmt);
// start streaming
VxStartStreaming(cam);
// get the MJPG format image
uint8_t* raw_data = new uint8_t[3840 * 2160 * 2];
int raw_size = 0;
VxGetImage(cam, raw_data, &raw_size, 2500);
# get format
result, format_list = pyvizionsdk.VxGetFormatList(camera)
mjpg_format = None
for format in format_list:
# get mjpg format
if format.format == VX_IMAGE_FORMAT.VX_IMAGE_FORMAT_MJPG:
mjpg_format = format
# set format
result = pyvizionsdk.VxSetFormat(camera, mjpg_format)
# start streaming
result = pyvizionsdk.VxStartStreaming(camera)
# get the MJPG format image
result, image = pyvizionsdk.VxGetImage(camera, 2500, mjpg_format)
// get format list
VxFormatVector fmtList = new VxFormatVector();
CSVizionSDK.VxGetFormatList(vxcam, fmtList);
// get mjpg format
VxFormat mjpgFormat = new VxFormat();
foreach (VxFormat fmt in fmtList)
{
if (fmt.format == VX_IMAGE_FORMAT.MJPG)
{
mjpgFormat = fmt;
}
}
// set the MJPG format
CSVizionSDK.VxSetFormat(cam, mjpgFormat);
// start streaming
CSVizionSDK.VxStartStreaming(cam);
// get the MJPG format image
int dataSize;
byte[] buffer = new byte[mjpgFormat.width * mjpgFormat.height * 2];
VX_CAPTURE_RESULT result = CSVizionSDK.VxGetImage(cam, buffer, out dataSize, 2500);
// get format list
const vx_format* fmt_list = NULL;
vx_get_format_list(cam, &fmt_list);
// get mjpg format
vx_format mjpgFormat;
i = 0;
while (fmt_list[i].width != 0 && fmt_list[i].height != 0) {
if (fmt_list[i].format == MJPG) {
mjpgFormat = fmt_list[i];
break;
}
i++;
}
// set the MJPG format
vx_set_format(cam, mjpgFormat);
// start streaming
vx_start_streaming(cam);
// get the MJPG format image
int max_size = 3840 * 2160 * 2;
uint8_t *raw_data = (uint8_t *)malloc(max_size);
int raw_size = 0;
vx_capture_result cap = vx_get_image(cam, raw_data, &raw_size, 2500);
// clean up
free(raw_data);
raw_data = NULL;
VxGetImageFd
This function is only supported in C++/C and works only when the image buffer is allocated using a DMA buffer.
Function:
- C++
- C
VX_CAPTURE_RESULT VxGetImageFd(std::shared_ptr<VxCamera> vxcam,
int* dmaBufferFd,
uint16_t timeout)
vx_capture_result vx_get_imagefd(vx_camera vxcam,
int* dmaBufferFd,
uint16_t timeout)
Function Description:
- This function is used to capture the image from the device and store it in a DMA buffer.
Parameter Description:
- vxcam : A pointer shared ownership of a camera obtained from VxInitialCameraDevice().
- dmaBufferFd : A pointer to DMA buffer file descriptor that stores the raw image data.
- timeout : The timeout value in milliseconds.
Return Values:
- VX_SUCCESS = 0
- VX_TIMEOUT = -1
- VX_CAM_OCCUPIED = -2
- VX_OTHER_ERROR = -3
- VX_BUFFER_CORRUPTED = -4
Example:
- C++
- C
int dmaBufferFd;
uint16_t timeout;
// get the image to DMA buffer
VxGetImageFd(vxcam, dmaBufferFd, timeout);
int dmaBufferFd;
uint16_t timeout;
// get the image to DMA buffer
vx_get_imagefd(vxcam, &dmaBufferFd, timeout);
VxReleaseImageFd
This function is only supported in C++/C and works only when the image buffer is allocated using a DMA buffer.
Function:
- C++
- C
int VxReleaseImageFd(std::shared_ptr<VxCamera> vxcam, int dmaBufferFd)
int vx_release_image_fd(vx_camera vxcam, int dmaBufferFd)
Function Description:
- This function is used to release the image stored in a DMA buffer.
Parameter Description:
- vxcam : A pointer shared ownership of a camera obtained from VxInitialCameraDevice().
- dmaBufferFd : A DMA buffer file descriptor that stores the raw image data.
- return 0 = PASS, return -1 = FAIL.
Example:
- C++
- C
int dmaBufferFd;
// release the image from the DMA buffer
VxReleaseImageFd(vxcam, dmaBufferFd);
int dmaBufferFd;
vx_release_image_fd(vxcam, dmaBufferFd);