Skip to content

Commit

Permalink
Fix segfault when printings statistics. The following segfault was de…
Browse files Browse the repository at this point in the history
…tected on Apple M1 Pro, while there is no segfault on CI! There was an out of range memory access to computation_times vector.

% ./tutorial-compare-auto-gamma --input Sample_low_brightness.png --output Results/cube
Input: Sample_low_brightness.png
Process on half image resolution? 0
Gaussian kernel size: 3
Gaussian standard deviation: 1
Aperture size: 3
Canny filtering type: 0
RGB colorspace? 0
Output result folder: Results/cube
Computation time (gamma_log): 2.30396 ms
Computation time (gamma_nonlinear): 1.27197 ms
Computation time (gamma_cdf): 2.1228 ms
Computation time (gamma_classification): 2.62817 ms
Computation time (gamma_spatial_variant): 19.5791 ms
Write result to: Results/cube/Sample_low_brightness.jpeg

Stats:
Nb images: 1
gamma_log: mean=2.1228 ms ; median=2.1228 ms
gamma_nonlinear: mean=2.62817 ms ; median=2.62817 ms
gamma_cdf: mean=19.5791 ms ; median=19.5791 ms
libc++abi: terminating due to uncaught exception of type vpException: Empty vector !
  • Loading branch information
fspindle committed Nov 4, 2024
1 parent ebca3c5 commit db58506
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tutorial/imgproc/brightness/tutorial-compare-auto-gamma.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ void computeMeanMaxStdev(const vpImage<T> &I, float &mean, float &max, float &st
}

void computeCanny(const vpImage<unsigned char> &I, vpCannyEdgeDetection &cannyDetector, int gaussianKernelSize,
float gaussianStdev, int apertureSize, vpImageFilter::vpCannyFilteringAndGradientType filteringType,
vpImage<unsigned char> &dIxy_uchar, vpImage<unsigned char> &I_canny_visp)
float gaussianStdev, int apertureSize, vpImageFilter::vpCannyFilteringAndGradientType filteringType,
vpImage<unsigned char> &dIxy_uchar, vpImage<unsigned char> &I_canny_visp)
{
vpImage<float> dIx, dIy, dIxy(I.getHeight(), I.getWidth());
vpImageFilter::computePartialDerivatives(I, dIx, dIy, true, true, true, gaussianKernelSize, gaussianStdev,
Expand Down Expand Up @@ -304,8 +304,8 @@ int main(int argc, const char **argv)
continue;
}
std::cout << VISP_NAMESPACE_NAME::vpGammaMethodToString(gamma_method) << ": mean="
<< vpMath::getMean(computation_times[gamma_idx+1]) << " ms ; median="
<< vpMath::getMedian(computation_times[gamma_idx+1]) << " ms" << std::endl;
<< vpMath::getMean(computation_times[gamma_idx-1]) << " ms ; median="
<< vpMath::getMedian(computation_times[gamma_idx-1]) << " ms" << std::endl;
}

return EXIT_SUCCESS;
Expand Down

0 comments on commit db58506

Please sign in to comment.