Hot answers tagged

13

Here are some suggestions for improving the code. Use all required #includes The code uses vector but doesn't include the corresponding header. The code should have #include <vector> Use <cmath> instead of <math.h> The difference between the two forms is that the former defines things within the std:: namespace versus into the global ...


8

In terms of making more robust, a fairly obvious improvement would be to ensure that argv[1] exists before using it (that's what argc is for). If there's no argument, or the file can't be read, emit a useful error message to std::cerr and return EXIT_FAILURE - negative return values from main() can vary by platform. Why do we declare CannyThreshold with ...


7

In addition to what was mentioned in the review by @nivag. With the exception of the use of std::vector the code looks a lot more like C than any version of C++. Proper Include Headers The code under review does not require stdio.h. Please note that in C++ C programming include files can be included by inserting 'c' before the header name and removing ...


6

There are a number of things I would change here: gradient_mag is unused in HoughTransformCircles and should be removed. Mat will presumably normally be a relatively large array so relatively expensive to copy, additionally you don't modify image or gradient_dir in the code. These can both be passed in as const Mat &. You should make variables that ...


4

I have a few different comments. Firstly, for 2D arrays like in your example, you can simply do conv2(binaryImage,structuringElement,'same'), it's equivalent to imdilate (and about 4 times faster). That might not be acceptable for your case if you are supposed to write the code yourself though. Next, and importantly, your code has a logic error. If your ...


Only top voted, non community-wiki answers of a minimum length are eligible