Good evening,
I used to develop on Windows 7 using Visual Studio 2015 for few weeks, and now I've decided to upgrade from Windows 7 to Windows 10. I also installed Ubuntu 14.04 on my laptop.
Since I upgraded my OS, whether I develop on WIndows 10 or Ubuntu 14.04, there are these :
I don't even know what is going on, this never happened when I used to dev on Windows 7 but since I got W10 and Ubuntu it appears.
Basically, I read a frame from my camera and apply some image processing on it (converting colors, bounding color ranges, applying a blur) and displaying it in a window, that's all. NB: the original frame (the read one) is good, without any "inception" things.
I'm using opencv-3.1.0, W10 (Visual Studop Studio 2015) and Ubuntu 14.04 (good ol' emacs). I don't really know if this bug is linked with my OS, still I couldn't find any help or any similar cases on internet.
Do you guys know what is going on ? Is it just a visual bug from the window or the frame being awkward ?
Thank you for your help and your time. Have a good day !
EDIT: I forgot to show the code, my bad.
The main loop :
void doTheBest() {
PerspectiveRegion region;
cv::Mat originalFrame, croppedFrame, processedFrame;
int width, height;
if (!this->isStreamOpened())
throw (CustomException("Could not retrieve stream from capture properly."));
this->stream_.about();
cv::namedWindow("Original");
cv::namedWindow("Image Processing");
cv::namedWindow("Contours");
width = (int) this->getStream().getCapture().get(cv::CAP_PROP_FRAME_WIDTH);
height = (int) this->getStream().getCapture().get(cv::CAP_PROP_FRAME_HEIGHT);
initializeROI(width, height, region);
originalFrame = cv::Mat(height, width, CV_8UC3);
croppedFrame = cv::Mat(height, width, CV_8UC3);
processedFrame.create(height, width, CV_8UC1);
while (cv::waitKey(1) % 256 != 27) {
this->getStream().readFrame(originalFrame);
if (originalFrame.empty()) break;
originalFrame.copyTo(croppedFrame, region.getMask());
doImageProcessing(croppedFrame, processedFrame);
doContours(processedFrame, this->contours_);
cv::imshow("Original", originalFrame);
cv::imshow("Image Processing", processedFrame);
}
cv::destroyAllWindows();
}
This is the function for the image processing :
void doImageProcessing(cv::Mat &inputFrame, cv::Mat &outputFrame) {
cv::Mat converted;
cv::Mat greenThresh, blueThresh, beigeThresh;
cv::Mat threshResult;
converted.create(inputFrame.size(), CV_32F);
cv::cvtColor(inputFrame, converted, cv::COLOR_BGR2HLS);
cv::inRange(converted, GREEN, WHITE, greenThresh);
cv::inRange(converted, BLUE, WHITE, blueThresh);
cv::inRange(converted, BEIGE, WHITE, beigeThresh);
cv::add(greenThresh, blueThresh, threshResult);
cv::add(beigeThresh, threshResult, outputFrame);
cv::morphologyEx(outputFrame, outputFrame, cv::MORPH_OPEN, STRUCTURING_ELEMENT);
cv::medianBlur(outputFrame, outputFrame, 5);
}
And this is the function for the contours :
void doContours(const cv::Mat &frame, Contours &contours) {
cv::Mat contoursFrame, drawContoursFrame;
Contours contours;
frame.convertTo(contoursFrame, CV_8UC3);
drawContoursFrame = cv::Mat(frame.size(), CV_8UC3);
cv::findContours(contoursFrame, contours, cv::RETR_EXTERNAL, cv::CHAIN_APPROX_SIMPLE);
cv::drawContours(drawContoursFrame, contours, -1, cv::Scalar(0, 255, 0));
cv::imshow("Contours", drawContoursFrame);
}