2019-12-10 19:34:30 +01:00
|
|
|
|
|
|
|
// Test library configuration for opencv2.cfg
|
|
|
|
//
|
|
|
|
// Usage:
|
|
|
|
// $ cppcheck --check-library --library=cairo --enable=information --error-exitcode=1 --inline-suppr --suppress=missingIncludeSystem test/cfg/opencv2.cpp
|
|
|
|
// =>
|
|
|
|
// 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
|
|
|
|
}
|