You've already forked libopenshot
mirror of
https://github.com/OpenShot/libopenshot.git
synced 2026-03-02 08:53:52 -08:00
Apply suggestions from code review
Co-authored-by: Frank Dana <ferdnyc@gmail.com>
This commit is contained in:
committed by
GitHub
parent
1fa4e878ca
commit
73bf7390e9
@@ -943,7 +943,7 @@ std::shared_ptr<QImage> Frame::GetImage()
|
||||
// Convert Qimage to Mat
|
||||
cv::Mat Frame::Qimage2mat( std::shared_ptr<QImage>& qimage) {
|
||||
|
||||
cv::Mat mat = cv::Mat(qimage->height(), qimage->width(), CV_8UC4, (uchar*)qimage->bits(), qimage->bytesPerLine()).clone();
|
||||
cv::Mat mat = cv::Mat(qimage->height(), qimage->width(), CV_8UC4, (const uchar*)qimage->constbits(), qimage->bytesPerLine()).clone();
|
||||
cv::Mat mat2 = cv::Mat(mat.rows, mat.cols, CV_8UC3 );
|
||||
int from_to[] = { 0,0, 1,1, 2,2 };
|
||||
cv::mixChannels( &mat, 1, &mat2, 1, from_to, 3 );
|
||||
|
||||
@@ -124,7 +124,7 @@ namespace openshot
|
||||
int64_t max_audio_sample; ///< The max audio sample count added to this frame
|
||||
|
||||
#ifdef USE_OPENCV
|
||||
cv::Mat imagecv; ///< OpenCV image. It will be always on BGR format
|
||||
cv::Mat imagecv; ///< OpenCV image. It will always be in BGR format
|
||||
#endif
|
||||
|
||||
/// Constrain a color value from 0 to 255
|
||||
@@ -295,6 +295,8 @@ namespace openshot
|
||||
#ifdef USE_OPENCV
|
||||
/// Convert Qimage to Mat
|
||||
cv::Mat Qimage2mat( std::shared_ptr<QImage>& qimage);
|
||||
|
||||
/// Convert OpenCV Mat to QImage
|
||||
std::shared_ptr<QImage> Mat2Qimage(cv::Mat img);
|
||||
|
||||
/// Get pointer to OpenCV Mat image object
|
||||
|
||||
@@ -74,23 +74,24 @@ std::shared_ptr<Frame> ObjectDetection::GetFrame(std::shared_ptr<Frame> frame, i
|
||||
cv::Mat cv_image = frame->GetImageCV();
|
||||
std::cout<<"Frame number: "<<frame_number<<"\n\n";
|
||||
// Check if frame isn't NULL
|
||||
if(!cv_image.empty()){
|
||||
if(cv_image.empty()){
|
||||
return frame;
|
||||
}
|
||||
|
||||
// Check if track data exists for the requested frame
|
||||
if (detectionsData.find(frame_number) != detectionsData.end()) {
|
||||
float fw = cv_image.size().width;
|
||||
float fh = cv_image.size().height;
|
||||
// Check if track data exists for the requested frame
|
||||
if (detectionsData.find(frame_number) != detectionsData.end()) {
|
||||
float fw = cv_image.size().width;
|
||||
float fh = cv_image.size().height;
|
||||
|
||||
DetectionData detections = detectionsData[frame_number];
|
||||
for(int i = 0; i<detections.boxes.size(); i++){
|
||||
cv::Rect_<float> bb_nrml = detections.boxes.at(i);
|
||||
cv::Rect2d box((int)(bb_nrml.x*fw),
|
||||
(int)(bb_nrml.y*fh),
|
||||
(int)(bb_nrml.width*fw),
|
||||
(int)(bb_nrml.height*fh));
|
||||
drawPred(detections.classIds.at(i), detections.confidences.at(i),
|
||||
box, cv_image);
|
||||
}
|
||||
DetectionData detections = detectionsData[frame_number];
|
||||
for(int i = 0; i<detections.boxes.size(); i++){
|
||||
cv::Rect_<float> bb_nrml = detections.boxes.at(i);
|
||||
cv::Rect2d box((int)(bb_nrml.x*fw),
|
||||
(int)(bb_nrml.y*fh),
|
||||
(int)(bb_nrml.width*fw),
|
||||
(int)(bb_nrml.height*fh));
|
||||
drawPred(detections.classIds.at(i), detections.confidences.at(i),
|
||||
box, cv_image);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user