From 6a4d881a78f88f6f068d9fd179f054611add2ad7 Mon Sep 17 00:00:00 2001 From: Jason Newton Date: Sat, 8 Dec 2012 21:57:49 -0800 Subject: [PATCH] use vector instead of non-standard stack allocation. also correct program argument borkage --- samples/cpp/connected_components.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/samples/cpp/connected_components.cpp b/samples/cpp/connected_components.cpp index 781ffec..617752b 100644 --- a/samples/cpp/connected_components.cpp +++ b/samples/cpp/connected_components.cpp @@ -13,7 +13,7 @@ static void on_trackbar(int, void*) Mat bw = threshval < 128 ? (img < threshval) : (img > threshval); Mat labelImage(img.size(), CV_32S); int nLabels = connectedComponents(bw, labelImage, 8); - Vec3b colors[nLabels]; + std::vector colors(nLabels); colors[0] = Vec3b(0, 0, 0);//background for(int label = 1; label < nLabels; ++label){ colors[label] = Vec3b( (rand()&255), (rand()&255), (rand()&255) ); @@ -41,14 +41,14 @@ static void help() 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 ) { help(); CommandLineParser parser(argc, argv, keys); - string inputImage = parser.get(1); + string inputImage = parser.get("@image"); img = imread(inputImage.c_str(), 0); if(img.empty()) -- 2.7.4