Hi! Welcome to Enyo Technology|Customized manufacturer of industrial camera module
How to realize multi-camera synchronous acquisition solution with multi-camera industrial cameras
2024-08-01

Yunkey Technology sales engineers found that many customers need to support multiple image sensors at the same time.Each image sensor needs to take pictures in full synchronously, using the same parameters.So we develop a variety of multi-eye cameras. Each camera can set whether a sensor above works, and then synthesize the working sensor image into one image and output it to the computer.

The following is our one-stop four products.

2342.jpg


Some code

nowrap;">Write a simple code to introduce how this camera gets pictures and displays them using opencv.Use the code in "CKSDK 6 Steps to Obtain Cloud Key Industrial Camera Image" to slightly modify it.


#include <stdio.h>

#include <string>

#include <opencv2/opencv.hpp>

#include"CKCameraInterface.h"


void process_multi_sensors_ckcamera()

{

HANDLE hCamera;

intcameraNum;

//Step 1: Find all cameras

int ret = CameraEnumerateDevice(&cameraNum);

if (ret < 0 || cameraNum == 0)

return;

if (ret < 0 || cameraNum == 0)

return;

if (ret < 0 || cameraNum == 0)

return;

//Step 2: Turn on the first camera

ret = CameraInit(&hCamera, 0);

if (ret != CAMERA_STATUS_SUCCESS)

return;

ret;

ret;//Set the format of image output, this step is not necessary

CameraSetIspOutFormat(hCamera, CAMERA_MEDIA_TYPE_MONO8);


//Set which sensors do work, bit0 represents sensor0, bit1 represents sensor1, bit2 represents sensor2, bit3 represents sensor3

//CameraSetIntValue(hCamera, IMAGE_CHANNEL_MASK, 0x1);  //Only output sensor0

//CameraSetIntValue(hCamera, IMAGE_CHANNEL_MASK, 0x2);   //Only output sensor1

//CameraSetIntValue(hCamera, IMAGE_CHANNEL_MASK, 0x4);   //Only output sensor2

//CameraSetIntValue(hCamera, IMAGE_CHANNEL_MASK, 0x4);   //Only output sensor2

//CameraSetIntValue(hCamera, IMAGE_CHANNEL_MASK, 0x8);   //OnOnly output sensor3

CameraSetIntValue(hCamera, IMAGE_CHANNEL_MASK, 0xf);   //Set all sensor output images



cv::namedWindow("image");

//Step 3: The camera starts to collect pictures

CameraPlay(hCamera);

while (true)

{

stImageInfoimgInfo;

//Step 4: Obtain camera image data

unsigned char *pbuff = CameraGetImageBufferEx(hCamera, &imgInfo, 1000);

if (pbuff == nullptr)

continue;

continue;

continue;

if (pbuff == nullptr)

continue;


//Use opencv to display the image, which contains image data of 4 sensors

cv::Mat image(imgInfo.iHeight, imgInfo.iWidth, CV_8UC1, pbuff);

if (image.empty())

continue;


unsigned int width = imgInfo.iWidth;

unsigned int height = imgInfo.iHeight;

unsigned int height = imgInfo.iHeight;

unsigned int height = imgInfo.iHeight;

unsigned int subWidth = width / 4;

unsigned int subHeight = height / 4;


cv::Mat image1 = image(cv::Rect(0, 0, subWidth, subHeight));

cv::Mat image1 = image(cv::Rect(0, 0, subWidth, subHeight));

cv::Matimage2 = image(cv::Rect(subWidth, 0, subWidth, subHeight));

cv::Mat image3 = image(cv::Rect(subWidth * 2, 0, subWidth, subHeight));

cv::Mat image4 = image(cv::Rect(subWidth * 3, 0, subWidth, subHeight));

cv::Mat image4 = image(cv::Rect(subWidth * 3, 0, subWidth, subHeight));


cv::imshow("image", image);

cv::imshow("image1", image1);

cv::imshow("image2", image2);

cv::imshow("image3", image3);

cv::imshow("image4", image4);

int key = cv::waitKey(10);

if (key == 27)

break;

break;

}

}

if (key == 27)

break;

}

}

cv::destroyAllWindows();

//Step 5: End image acquisition for the camera

CameraPause(hCamera);

//Step 6: Turn off the camera

CameraUnInit(hCamera);

CameraUnInit(hCamera);

}


int main(int argc, char *argv[])

{

process_multi_sensors_ckcamera();

return0;

}


This code will output images of 4 image sensors at the same time.There is a window showing images of 4 image sensors, and the other 4 images showing images of each sensor individually.


For more industrial camera knowledge, please consult Yunji Technology 0755-23323753.Shenzhen Yunkey Technology is a professional industrial camera research and development manufacturer, focusing on industrial phasesR&D, production and sales of machines and their solutions.The products include USB2.0, USB3.0, GIGE Network Industrial Camera, which supports customized software and hardware development, and also provides thoughtful technical support services.

×

Home

Product

Service

Cases

News

Support

About