void produceFrames()

in camera_pkg/src/camera_node.cpp [139:172]


        void produceFrames() {
            while (produceFrames_) {
                deepracer_interfaces_pkg::msg::CameraMsg msg;
                for (auto& cap :  videoCaptureList_) {
                    if (!cap.isOpened()) {
                        continue;
                    }
                    cv::Mat frame;
                    cap >> frame;
                    if (frame.empty()) {
                        RCLCPP_ERROR(this->get_logger(), "No frame returned. Check if camera is plugged in correctly.");
                        continue;
                    }
                    try {
                        if(resizeImages_) {
                            cv::resize(frame, frame, cv::Size(DEFAULT_IMAGE_WIDTH, DEFAULT_IMAGE_HEIGHT));
                        }
                        msg.images.push_back(*(cv_bridge::CvImage(std_msgs::msg::Header(), "bgr8", frame).toImageMsg().get()));
                    }
                    catch (cv_bridge::Exception& e) {
                        RCLCPP_ERROR(this->get_logger(), "cv_bridge exception: %s", e.what());
                        produceFrames_ = false;
                        return;
                    }
                }
                try {
                    displayPub_->publish(msg.images.front());
                    videoPub_->publish(msg);
                }
                    catch (const std::exception &ex) {
                    RCLCPP_ERROR(this->get_logger(), "Publishing camera images to topics failed %s", ex.what());
                }
            }
        }