Dear Sirs,
I am modifying the rpicam-apps, but there's runtime error always occurs.
I change
rpicam-apps/post_processing_stages/object_detect_draw_cv_stage.cpp for AI camera object detection display font & color.
Inside it, I know the default code, the Mat image is one channel.
So I change it to BGR 3 channels in order to display RED color.
Compile is successful, but in runtime, the system crash and shows:
Thank you.
B.R.
YU
I am modifying the rpicam-apps, but there's runtime error always occurs.
I change
rpicam-apps/post_processing_stages/object_detect_draw_cv_stage.cpp for AI camera object detection display font & color.
Inside it, I know the default code, the Mat image is one channel.
So I change it to BGR 3 channels in order to display RED color.
Code:
bool ObjectDetectDrawCvStage::Process(CompletedRequestPtr &completed_request){if (!stream_)return false;BufferWriteSync w(app_, completed_request->buffers[stream_]);libcamera::Span<uint8_t> buffer = w.Get()[0];uint32_t *ptr = (uint32_t *)buffer.data();StreamInfo info = app_->GetStreamInfo(stream_);std::vector<Detection> detections;completed_request->post_process_metadata.Get("object_detect.results", detections); //Mat image(info.height, info.width, CV_8U, ptr, info.stride); //<--- This is originMat image(info.height, info.width, CV_8UC3, ptr, info.stride); //<----I change to 3 channel to display in RED colorScalar colour = Scalar(0, 0, 255);int font = FONT_HERSHEY_SIMPLEX;for (auto &detection : detections){Rect r(detection.box.x, detection.box.y, detection.box.width, detection.box.height);rectangle(image, r, colour, line_thickness_);std::stringstream text_stream;text_stream << detection.name << " " << (int)(detection.confidence * 100) << "%";std::string text = text_stream.str();int baseline = 0;Size size = getTextSize(text, font, font_size_, 2, &baseline);Point text_origin(detection.box.x + 5, detection.box.y + size.height + 5);putText(image, text, text_origin, font, font_size_, colour, 8);}return false;}
Could someone give help on this?terminate called after throwing an instance of 'cv::Exception'
what(): OpenCV(4.6.0) ./modules/core/src/matrix.cpp:434: error: (-215:Assertion failed) _step >= minstep in function 'Mat'
Thank you.
B.R.
YU
Statistics: Posted by okeyla — Wed Jan 22, 2025 2:11 am