Commit 6a4d881a authored by Jason Newton's avatar Jason Newton

use vector instead of non-standard stack allocation. also correct program argument borkage

parent 00bdca76
...@@ -13,7 +13,7 @@ static void on_trackbar(int, void*) ...@@ -13,7 +13,7 @@ static void on_trackbar(int, void*)
Mat bw = threshval < 128 ? (img < threshval) : (img > threshval); Mat bw = threshval < 128 ? (img < threshval) : (img > threshval);
Mat labelImage(img.size(), CV_32S); Mat labelImage(img.size(), CV_32S);
int nLabels = connectedComponents(bw, labelImage, 8); int nLabels = connectedComponents(bw, labelImage, 8);
Vec3b colors[nLabels]; std::vector<Vec3b> colors(nLabels);
colors[0] = Vec3b(0, 0, 0);//background colors[0] = Vec3b(0, 0, 0);//background
for(int label = 1; label < nLabels; ++label){ for(int label = 1; label < nLabels; ++label){
colors[label] = Vec3b( (rand()&255), (rand()&255), (rand()&255) ); colors[label] = Vec3b( (rand()&255), (rand()&255), (rand()&255) );
...@@ -41,14 +41,14 @@ static void help() ...@@ -41,14 +41,14 @@ static void help()
const char* keys = const char* keys =
{ {
"{@image |stuff.jpg|image for converting to a grayscale}" "{@image|stuff.jpg|image for converting to a grayscale}"
}; };
int main( int argc, const char** argv ) int main( int argc, const char** argv )
{ {
help(); help();
CommandLineParser parser(argc, argv, keys); CommandLineParser parser(argc, argv, keys);
string inputImage = parser.get<string>(1); string inputImage = parser.get<string>("@image");
img = imread(inputImage.c_str(), 0); img = imread(inputImage.c_str(), 0);
if(img.empty()) if(img.empty())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment