QT + OPENCV Label Pixmap
-
wrote on 24 Feb 2020, 09:03 last edited by
Hello all again. I have a webcamera which gives in input and i used OpenCV to draw the frames and show in one label (Did the conversions and etc). I want to filter Blue colors from the webcam and display in another Label. However, pixmap overrides whenever i try to move. I use it in a slot to update every QTimer Count.
Heres the code.onlinecam >> onlineframes; currframes = QString::number(currframe); cv::cvtColor(onlineframes, hsv, cv::COLOR_BGR2HSV); cv::inRange(hsv, cv::Scalar(110,50,50), cv::Scalar(130, 255, 255), mask); cv::bitwise_and(onlineframes, onlineframes ,res, mask); cv::cvtColor(res, blue_image, cv::COLOR_BGR2RGB); //ui->textEdit->append("Current Frame: " + currframes); cv::cvtColor(onlineframes, onlineframes, cv::COLOR_BGR2RGB); // cv::resize(onlineframes,onlineframes,cv::Size(vheight,vwidth), 0, 0, cv::INTER_AREA); QImage imdisplay((uchar*)onlineframes.data, onlineframes.cols, onlineframes.rows, QImage::Format_RGB888); QImage filtered_image((uchar*)blue_image.data, blue_image.cols, blue_image.rows, QImage::Format_RGB888); ui->binary_display->setPixmap(QPixmap::fromImage(filtered_image)); ui->image_display->setPixmap(QPixmap::fromImage(imdisplay));
The resulting video looks like this.
I stopped the video cam because I don't want to show my picture. and I have a blue pen and waved around the camera. However, the resulting filtered image just overrides the previous pixmap that is set. Any Idea how to solve it?
-
wrote on 26 Feb 2020, 05:58 last edited by
-
wrote on 24 Feb 2020, 10:17 last edited by
Sorry but it is not clear, maybe my english is not so fluent.
Do you want to merge more images in one? -
Hello all again. I have a webcamera which gives in input and i used OpenCV to draw the frames and show in one label (Did the conversions and etc). I want to filter Blue colors from the webcam and display in another Label. However, pixmap overrides whenever i try to move. I use it in a slot to update every QTimer Count.
Heres the code.onlinecam >> onlineframes; currframes = QString::number(currframe); cv::cvtColor(onlineframes, hsv, cv::COLOR_BGR2HSV); cv::inRange(hsv, cv::Scalar(110,50,50), cv::Scalar(130, 255, 255), mask); cv::bitwise_and(onlineframes, onlineframes ,res, mask); cv::cvtColor(res, blue_image, cv::COLOR_BGR2RGB); //ui->textEdit->append("Current Frame: " + currframes); cv::cvtColor(onlineframes, onlineframes, cv::COLOR_BGR2RGB); // cv::resize(onlineframes,onlineframes,cv::Size(vheight,vwidth), 0, 0, cv::INTER_AREA); QImage imdisplay((uchar*)onlineframes.data, onlineframes.cols, onlineframes.rows, QImage::Format_RGB888); QImage filtered_image((uchar*)blue_image.data, blue_image.cols, blue_image.rows, QImage::Format_RGB888); ui->binary_display->setPixmap(QPixmap::fromImage(filtered_image)); ui->image_display->setPixmap(QPixmap::fromImage(imdisplay));
The resulting video looks like this.
I stopped the video cam because I don't want to show my picture. and I have a blue pen and waved around the camera. However, the resulting filtered image just overrides the previous pixmap that is set. Any Idea how to solve it?
wrote on 24 Feb 2020, 14:00 last edited by Pl45m4So the problem is, that you get the blue parts from your previous frame in your current and next frame?!
Try to clear yourcv::Mat onlineframes
before setting new data to pixmap.// This might work or else try to fill with zeros if it doesnt work onlineframes.release(); // then populate cv::Mat with current frame data onlinecam >> onlineframes; currframes = QString::number(currframe); cv::cvtColor(onlineframes, hsv, cv::COLOR_BGR2HSV); cv::inRange(hsv, cv::Scalar(110,50,50), cv::Scalar(130, 255, 255), mask); cv::bitwise_and(onlineframes, onlineframes ,res, mask); cv::cvtColor(res, blue_image, cv::COLOR_BGR2RGB); //ui->textEdit->append("Current Frame: " + currframes); cv::cvtColor(onlineframes, onlineframes, cv::COLOR_BGR2RGB); // cv::resize(onlineframes,onlineframes,cv::Size(vheight,vwidth), 0, 0, cv::INTER_AREA); QImage imdisplay((uchar*)onlineframes.data, onlineframes.cols, onlineframes.rows, QImage::Format_RGB888); QImage filtered_image((uchar*)blue_image.data, blue_image.cols, blue_image.rows, QImage::Format_RGB888); ui->binary_display->setPixmap(QPixmap::fromImage(filtered_image));
-
So the problem is, that you get the blue parts from your previous frame in your current and next frame?!
Try to clear yourcv::Mat onlineframes
before setting new data to pixmap.// This might work or else try to fill with zeros if it doesnt work onlineframes.release(); // then populate cv::Mat with current frame data onlinecam >> onlineframes; currframes = QString::number(currframe); cv::cvtColor(onlineframes, hsv, cv::COLOR_BGR2HSV); cv::inRange(hsv, cv::Scalar(110,50,50), cv::Scalar(130, 255, 255), mask); cv::bitwise_and(onlineframes, onlineframes ,res, mask); cv::cvtColor(res, blue_image, cv::COLOR_BGR2RGB); //ui->textEdit->append("Current Frame: " + currframes); cv::cvtColor(onlineframes, onlineframes, cv::COLOR_BGR2RGB); // cv::resize(onlineframes,onlineframes,cv::Size(vheight,vwidth), 0, 0, cv::INTER_AREA); QImage imdisplay((uchar*)onlineframes.data, onlineframes.cols, onlineframes.rows, QImage::Format_RGB888); QImage filtered_image((uchar*)blue_image.data, blue_image.cols, blue_image.rows, QImage::Format_RGB888); ui->binary_display->setPixmap(QPixmap::fromImage(filtered_image));
wrote on 26 Feb 2020, 03:16 last edited by@Pl45m4 Hello, Yes i get the problem of the previous frame existing in my current frame. Maybe filling it with zeros will do the trick I am still trying to figure it out
-
Sorry but it is not clear, maybe my english is not so fluent.
Do you want to merge more images in one?wrote on 26 Feb 2020, 03:17 last edited by@mrdebug No no. I have the problem of my previous frames exisiting in my current frame.
Hence, I got these movement frames -
wrote on 26 Feb 2020, 05:58 last edited by
1/6