-4

Following code results in build success, but no window. Without "m = Scalar(255,0,0);", it creates black window. Why including scalar does not work?

#include <iostream>
#include <stdio.h>

#include <opencv2/opencv.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/core.hpp>
#include <opencv2/highgui.hpp>

using namespace cv;
using namespace std;

int main() {

    Mat m = Mat::zeros(200,200,CV_8UC3);
    m = Scalar(255,0,0);  //without this, it creates window. 

    imshow("m", m);
    waitKey();

}
Dami Kim
  • 9
  • 1
  • Possible duplicate of [How to set all pixels of an OpenCV Mat to a specific value?](http://stackoverflow.com/questions/20816955/how-to-set-all-pixels-of-an-opencv-mat-to-a-specific-value) – Jeru Luke Apr 28 '17 at 09:28
  • This question would be better deleted as it does not bring anything helpfull for the community (given the issue was to clean & build). Consider that. – Croolman Apr 28 '17 at 13:43

2 Answers2

0

It will not give you any compilation error as Mat and Scalar are basically array types of OpenCV.

This is a possible duplicate of How to set all pixels of an OpenCV Mat to a specific value?

Community
  • 1
  • 1
Deniz Beker
  • 1,984
  • 1
  • 18
  • 22
0

Your code have to work!

take a look at the doc:

C++: void imshow(const string& winname, InputArray mat)

and I can confirm you is working fine on my environment(opencv320, VisualStudio2017): you need to clean the project and build again.

enter image description here

ΦXocę 웃 Пepeúpa ツ
  • 47,427
  • 17
  • 69
  • 97