I've got a weird problem. Here's my code:
#include <iostream>
#include "opencv2/opencv.hpp"
#include <stdint.h>
using namespace cv;
int main()
{
Mat img = imread("testbild.jpg", CV_LOAD_IMAGE_UNCHANGED);
Mat imgGray = imread("testbild.jpg", CV_LOAD_IMAGE_GRAYSCALE);
if (img.empty())
{
std::cout << "Kein Bild gefunden!" << std::endl;
}
//This array isn't used for while but I will use it in the future
int intensity[imgGray.rows] [imgGray.cols];
int max;
for (int r = 0; r <= imgGray.rows; r++)
{
for (int c = 0; c <= imgGray.cols; c++)
{
if (max < (int)imgGray.at<uint8_t> (r,c))
{
max = (int)imgGray.at<uint8_t> (r,c);
}
}
}
std::cout << max << std::endl;
return 0;
}
The thing is, cout is not working. I don't know why. But whenever I comment out the line
int intensity[imgGray.rows] [imgGray.cols];
It works again.
I know that this line isn't used yet, but I'll use it later.
Why does this happen? I'm new to programming so please don't be mad, if it's a really simple answer. I also already used Google to find a solution, but all I got is to flush the output, and that doesn't work.
The console opens by the way, but all it says is "Press to close this window...".