2019-12-10 19:34:30 +01:00
|
|
|
|
|
|
|
// Test library configuration for opencv2.cfg
|
|
|
|
//
|
|
|
|
// Usage:
|
2023-01-26 22:28:04 +01:00
|
|
|
// $ cppcheck --check-library --library=opencv2 --enable=style --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/opencv2.cpp
|
2019-12-10 19:34:30 +01:00
|
|
|
// =>
|
|
|
|
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
|
|
|
|
//
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include <opencv2/opencv.hpp>
|
|
|
|
|
|
|
|
|
|
|
|
void validCode(char* argStr)
|
|
|
|
{
|
|
|
|
cv::Mat image;
|
|
|
|
image = cv::imread(argStr, cv::IMREAD_COLOR);
|
|
|
|
if (!image.data) {
|
|
|
|
printf("No image data \n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
cv::namedWindow("Display Image", cv::WINDOW_AUTOSIZE);
|
|
|
|
cv::imshow("Display Image", image);
|
|
|
|
cv::waitKey(0);
|
|
|
|
|
|
|
|
cv::String cvStr("Hello");
|
|
|
|
cvStr += " World";
|
|
|
|
std::cout << cvStr;
|
2020-05-30 17:41:44 +02:00
|
|
|
|
2022-02-10 20:48:51 +01:00
|
|
|
char * pBuf = (char *)cv::fastMalloc(20); // cppcheck-suppress cstyleCast
|
2020-05-30 17:41:44 +02:00
|
|
|
cv::fastFree(pBuf);
|
2019-12-10 19:34:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void ignoredReturnValue()
|
|
|
|
{
|
|
|
|
// cppcheck-suppress ignoredReturnValue
|
|
|
|
cv::imread("42.png");
|
|
|
|
}
|
2020-05-30 17:41:44 +02:00
|
|
|
|
|
|
|
void memleak()
|
|
|
|
{
|
2022-02-10 20:48:51 +01:00
|
|
|
char * pBuf = (char *)cv::fastMalloc(1000); // cppcheck-suppress cstyleCast
|
2020-05-30 17:41:44 +02:00
|
|
|
std::cout << pBuf;
|
|
|
|
// cppcheck-suppress memleak
|
|
|
|
}
|