9 #include <cv_bridge/cv_bridge.h>
12 #include <opencv2/highgui/highgui.hpp>
13 #include <opencv2/imgproc/imgproc.hpp>
14 #include <opencv2/core/core.hpp>
19 using namespace AVT::VmbAPI;
36 log(
"[CAMERA] [ALVIUM] Frame received!");
38 VmbUint32_t nImageSize = 0;
39 if(VmbErrorSuccess != imgFrame->GetImageSize( nImageSize )) {
44 VmbUint32_t nWidth = 0;
45 if(VmbErrorSuccess != imgFrame->GetWidth( nWidth )) {
50 VmbUint32_t nHeight = 0;
51 if(VmbErrorSuccess != imgFrame->GetHeight( nHeight )) {
58 unsigned char* imagePtr;
59 if(VmbErrorSuccess != imgFrame->GetImage( imagePtr )) {
67 auto outImgSize = cv::Size(512, 256);
69 if(
static_cast<float>(nHeight)/
static_cast<float>(nWidth) !=
static_cast<float>(outImgSize.height)/
static_cast<float>(outImgSize.width)) {
70 log_warning(
"[CAMERA] [ALVIUM] Camera Image Ratio NOT equal to desired Image Ration");
73 cv::Mat img(nHeight, nWidth, CV_8UC3, imagePtr);
74 cv::Mat imgResize(outImgSize, CV_8UC3);
75 cv::resize(img, imgResize, outImgSize);
83 std::shared_ptr<sensor_msgs::msg::Image> msgImgSPtr = std::make_shared<sensor_msgs::msg::Image>();
84 std_msgs::msg::Header header;
85 header.frame_id =
"cam";
86 header.stamp = timestampCameraImage;
88 m_bridgeImg = cv_bridge::CvImage(header, sensor_msgs::image_encodings::RGB8, imgResize);
105 if(ret ==
nullptr && blocking) {
120 log_warning(
"[CAMERA] [ALVIUM] Vimba System failed to startup!");
131 m_camera->StopContinuousImageAcquisition();
142 log_warning(
"[CAMERA] [ALVIUM] Frame Observer not initialized!");
149 AVT::VmbAPI::CameraPtrVector cameraPtrVec;
151 if ( VmbErrorSuccess !=
m_vimbaSystem.GetCameras( cameraPtrVec )){
152 log_warning(
"[CAMERA] [ALVIUM] Failed to get cameras!");
156 if(cameraPtrVec.size() < 1) {
161 std::string cameraIdString;
162 if(VmbErrorSuccess != cameraPtrVec[0]->GetID(cameraIdString)) {
163 log_warning(
"[CAMERA] [ALVIUM] Failed to get the camera ID string.");
168 if(VmbErrorSuccess !=
m_vimbaSystem.OpenCameraByID(cameraIdString.c_str(), VmbAccessModeFull,
m_camera)) {
169 log_warning(
"[CAMERA] [ALVIUM] Failed to open the camera.");
174 if(VmbErrorSuccess !=
m_camera->LoadCameraSettings(
"AlviumCameraVimbaSettings.xml")) {
175 log_warning(
"[CAMERA] [ALVIUM] Failed to load camera settings.");
202 log_warning(
"[CAMERA] [ALVIUM] Failed to set start continuous image acquision.");