2019-12-10 19:34:30 +01:00
|
|
|
|
|
|
|
// Test library configuration for opencv2.cfg
|
|
|
|
//
|
|
|
|
// Usage:
|
2023-03-09 20:04:20 +01:00
|
|
|
// $ cppcheck --check-library --library=opencv2 --enable=style,information --inconclusive --error-exitcode=1 --disable=missingInclude --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>
|
|
|
|
|
|
|
|
|
2023-08-05 18:48:43 +02:00
|
|
|
void validCode(const char* argStr)
|
2019-12-10 19:34:30 +01:00
|
|
|
{
|
|
|
|
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
|
|
|
|
}
|