Baumer Industrial Camera How Baumer Industrial Camera combines NEOAPI SDK and OpenCV to convert camera images into AVI video format (C++)


Baumer industrial cameras

Baumer Industrial Cameras Baumer cameras are high-performance, high-quality industrial cameras that can be used in a variety of applications such as object detection, counting and recognition, motion analysis and image processing.

Baumer's 10GbE cameras have excellent image processing performance and can transmit high-resolution images in real time. In addition, the camera features fast data transfer, low power consumption, easy integration, and high scalability.
​Baumer
Industrial Camera NEOAPI SDK is the latest software development kit (SDK) for Baumer industrial cameras. It provides developers with a series of APIs and tools for communicating and controlling Baumer industrial cameras. The control method is extremely convenient, similar to Halcon's camera assistant control method.

When using industrial vision software to integrate industrial cameras, it is often necessary to integrate some functions in the industrial camera SDK into the image processing software to facilitate the advancement of the project; for example, convert the image data collected in the SDK into a suitable image format such as Bitmap, etc. or Opencv Mat image data format, and then perform image processing to start the image processing task;

Note: This article is based on Baumer's NEOAPI SDK and OpenCV using C# language to convert camera images into Mat video format.

Technical background of converting Baumer industrial camera images to OpenCV images

Converting industrial camera images to OpenCV images involves the collection, processing and storage of image data. Here’s the technical background:

  1. Image acquisition: Industrial cameras use image sensors to capture real-world optical information and convert it into digital image data. The data can be grayscale images (single channel) or color images (multiple channels).

  2. Data format: The image data of industrial cameras can be stored in different formats, such as RAW, RGB, YUV, etc. These formats reflect the arrangement of pixel values ​​and the representation of color information.

  3. OpenCV Library: OpenCV is an open source computer vision library widely used for processing image and video data. It provides a rich set of functions and tools for loading, processing and storing image data.

  4. Mat object: In OpenCV, image data is usually represented as a Mat object. The Mat object contains the pixel value of the image and related metadata, such as image size, number of channels, etc.

  5. Data conversion: Converting industrial camera image data to OpenCV Mat images usually involves parsing and converting data formats to ensure that the image data can be loaded and processed correctly. This may require conversion and processing that takes into account the number of channels, bit depth, color space, etc. of the image.

Therefore, converting industrial camera image data to OpenCV's Mat image requires understanding the format and characteristics of industrial camera image data, and using the functions and tools provided by OpenCV for appropriate data parsing and conversion.

Convert camera images to video format in NEOAPI SDK

After the camera is connected, the camera image can be converted into Mat image format and into video in the NEOAPI SDK. The C++ calling code is as follows:

#include <stdio.h>
#include <iostream>
#include <opencv2/highgui.hpp>
#include "neoapi/neoapi.hpp"

NeoAPI::Cam camera = NeoAPI::Cam();
camera.Connect();
camera.f().ExposureTime.Set(10000);

int type = CV_8U;
bool isColor = true;
if (camera.f().PixelFormat.GetEnumValueList().IsReadable("BGR8")) {
    
    
    camera.f().PixelFormat.SetString("BGR8");
    type = CV_8UC3;
    isColor = true;
} else if (camera.f().PixelFormat.GetEnumValueList().IsReadable("Mono8")) {
    
    
    camera.f().PixelFormat.SetString("Mono8");
    type = CV_8UC1;
    isColor = false;
} else {
    
    
    std::cout << "no supported pixel format";
    return 0;  // Camera does not support pixelformat
}
int width = static_cast<int>(camera.f().Width);
int height = static_cast<int>(camera.f().Height);

cv::VideoWriter video("outcpp.avi", cv::VideoWriter::fourcc('X', 'V', 'I', 'D'), 10,
    cv::Size(static_cast<int>(camera.f().Width), static_cast<int>(camera.f().Height)), isColor);

const cv::String windowName = "Press [Esc] to quit.";
for (int count = 0; count < 200; ++count) {
    
    
    NeoAPI::Image image = camera.GetImage();
    cv::Mat img(cv::Size(width, height), type, image.GetImageData(), cv::Mat::AUTO_STEP);
    cv::namedWindow(windowName);
    cv::imshow(windowName, img);
    video.write(img);

    if (cv::waitKey(1) == 27) {
    
    
        break;
    }
}
video.release();
cv::destroyWindow(windowName);



Industrial cameras realize the advantages of converting camera images into video formats through OpenCV

Industrial cameras converting camera images into video formats through OpenCV has the following advantages:

  1. Convenient data processing: OpenCV provides a wealth of video processing functions, which can easily load, process and save video data. After converting to video format, video analysis, frame extraction, video synthesis and other operations can be performed.

  2. Real-time performance: The OpenCV library has excellent real-time image and video processing performance and can be used for real-time video stream processing. It is suitable for applications that require real-time monitoring and feedback, such as video surveillance, machine vision, etc.

  3. Cross-platform: OpenCV is a cross-platform computer vision library that can run on multiple operating systems, supports video data input and output in different formats, and is suitable for application scenarios on multiple platforms.

  4. Efficient algorithm implementation: OpenCV integrates many optimized video processing algorithms, and operations such as encoding, decoding, compression, and filtering of video data can be performed in an efficient manner.

  5. Convenient interfaces and tools: OpenCV provides a wealth of video processing interfaces and tools, including video capture, video encoding and decoding, video writing and other modules, making it easier to convert camera images into video formats.

  6. Development support: OpenCV has a large developer community and rich documentation resources, supporting the development and optimization of video processing applications based on OpenCV, which is beneficial to improving development efficiency and application performance.

In summary, industrial cameras use OpenCV to convert camera images into video formats with multiple advantages such as convenient data processing, real-time performance, cross-platform support, efficient algorithm implementation, convenient interfaces and development support, providing video processing and applications. Strong support and solutions.

Industrial cameras use OpenCV to convert camera images into video formats for industrial applications

Industrial cameras converting camera images to video formats through OpenCV has a wide range of applications in many industries, including but not limited to:

  1. Manufacturing: In manufacturing, industrial cameras convert images into video format through OpenCV for production process monitoring and quality inspection. Real-time video can help factories monitor the process on the production line and conduct defect detection and product quality analysis.

  2. Medical industry: Industrial cameras realize video format image conversion through OpenCV, which can be used for processing and analysis of medical imaging data, such as real-time collection and processing of medical images, video recording of surgical procedures, monitoring of medical equipment, etc.

  3. Intelligent transportation: In intelligent transportation systems, industrial cameras can convert real-time video data through OpenCV for applications such as vehicle monitoring, traffic flow analysis, traffic accident monitoring, etc., which helps to improve the intelligence level of traffic management.

  4. Agricultural field: Industrial cameras combined with OpenCV to realize video data conversion can be used for monitoring and analysis of agricultural production processes, including real-time observation of crop growth status, monitoring of irrigation systems, and identification and monitoring of pests and diseases.

  5. Security field: Industrial cameras convert images into video format through OpenCV and can be used in security monitoring systems, including monitoring of buildings, public places and transportation hubs, to achieve real-time visual monitoring and event recognition of the monitored area.

  6. Intelligent manufacturing: In the field of intelligent manufacturing, industrial cameras use OpenCV to implement video processing and apply it to fields such as machine vision navigation, intelligent robot operation, and product quality inspection to improve the automation and intelligence of the manufacturing production process.

In summary, industrial cameras using OpenCV to convert camera images into video formats have important applications in many industries such as manufacturing, medical care, transportation, agriculture, security, and smart manufacturing, providing real-time image data processing for these industries. and analytical solutions to help improve production efficiency and provide more intelligent solutions.

Guess you like

Origin blog.csdn.net/xianzuzhicai/article/details/135433649