opencv2.cfg: Add initial OpenCV 2.x API Library Configuration (#2439)

This commit is contained in:
Sebastian 2019-12-10 19:34:30 +01:00 committed by GitHub
parent 40aefa1ba4
commit de4d44ae2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 141 additions and 1 deletions

View File

@ -20,7 +20,7 @@ env:
before_install:
# install needed deps
- travis_retry sudo apt-get update -qq
- travis_retry sudo apt-get install -qq python3-pip qt5-default qt5-qmake qtbase5-dev qtcreator libxml2-utils libpcre3 gdb unzip wx-common xmlstarlet python3-dev liblua5.3-dev libcurl3 libcairo2-dev libsigc++-2.0-dev tidy
- travis_retry sudo apt-get install -qq python3-pip qt5-default qt5-qmake qtbase5-dev qtcreator libxml2-utils libpcre3 gdb unzip wx-common xmlstarlet python3-dev liblua5.3-dev libcurl3 libcairo2-dev libsigc++-2.0-dev tidy libopencv-dev
# Python 2 modules
- travis_retry python2 -m pip install --user pytest==4.6.4
- travis_retry python2 -m pip install --user pylint

77
cfg/opencv2.cfg Normal file
View File

@ -0,0 +1,77 @@
<?xml version="1.0"?>
<def format="2">
<!-- OpenCV (Open Source Computer Vision Library) Library Configuration http://opencv.org) -->
<!-- This configuration is for the OpenCV 2.x API (The C++ API, not the older C API) -->
<!-- The OpenCV library is typically included by '#include <opencv2/*>' or -->
<!-- '#include "opencv2/*"'. -->
<!-- ########## OpenCV Types ########## -->
<!-- ########## OpenCV Macros / Defines ########## -->
<define name="CV_PI" value="3.1415926535897932384626433832795"/>
<define name="CV_2PI" value="6.283185307179586476925286766559"/>
<define name="CV_LOG2" value="0.69314718055994530941723212145818"/>
<define name="CV_MAT_CN_MASK" value="((CV_CN_MAX - 1) &lt;&lt; CV_CN_SHIFT)"/>
<define name="CV_MAT_CN(flags)" value="((((flags) &amp; CV_MAT_CN_MASK) &gt;&gt; CV_CN_SHIFT) + 1)"/>
<define name="CV_MAT_TYPE_MASK" value="(CV_DEPTH_MAX*CV_CN_MAX - 1)"/>
<define name="CV_MAT_TYPE(flags)" value="((flags) &amp; CV_MAT_TYPE_MASK)"/>
<define name="CV_MAT_CONT_FLAG_SHIFT" value="14"/>
<define name="CV_MAT_CONT_FLAG" value="(1 &lt;&lt; CV_MAT_CONT_FLAG_SHIFT)"/>
<define name="CV_IS_MAT_CONT(flags)" value="((flags) &amp; CV_MAT_CONT_FLAG)"/>
<define name="CV_IS_CONT_MAT" value="CV_IS_MAT_CONT"/>
<define name="CV_SUBMAT_FLAG_SHIFT" value="15"/>
<define name="CV_SUBMAT_FLAG" value="(1 &lt;&lt; CV_SUBMAT_FLAG_SHIFT)"/>
<define name="CV_IS_SUBMAT(flags)" value="((flags) &amp; CV_MAT_SUBMAT_FLAG)"/>
<define name="MIN(a,b)" value="((a) &gt; (b) ? (b) : (a))"/>
<define name="MAX(a,b)" value="((a) &lt; (b) ? (b) : (a))"/>
<!-- ########## OpenCV containers ########## -->
<!-- OpenCV containers that are similar to std containers -->
<container id="cvString" startPattern="cv :: String" inherits="stdString"/>
<!-- ########## OpenCV Allocation / Deallocation ########## -->
<!-- ########## OpenCV Functions ########## -->
<!-- Mat cv::imread ( const String & filename, int flags = IMREAD_COLOR ) -->
<function name="cv::imread">
<noreturn>false</noreturn>
<returnValue type="cv::Mat"/>
<use-retval/>
<arg nr="1" direction="in">
<not-uninit/>
</arg>
<arg nr="2" direction="in" default="cv::IMREAD_COLOR">
<not-uninit/>
<not-bool/>
</arg>
</function>
<!-- void cv::imshow ( const String & winname, InputArray mat ) -->
<!-- void cv::imshow ( const String & winname, const ogl::Texture2D & tex ) -->
<function name="cv::imshow">
<noreturn>false</noreturn>
<returnValue type="void"/>
<arg nr="1" direction="in">
<not-uninit/>
</arg>
<arg nr="2" direction="in">
<not-uninit/>
<not-bool/>
</arg>
</function>
<!-- void cv::namedWindow ( const String & winname, int flags = WINDOW_AUTOSIZE ) -->
<function name="cv::namedWindow">
<noreturn>false</noreturn>
<returnValue type="void"/>
<arg nr="1" direction="in">
<not-uninit/>
</arg>
<arg nr="2" direction="in" default="cv::WINDOW_AUTOSIZE">
<not-uninit/>
<not-bool/>
</arg>
</function>
<!-- int cv::waitKey ( int delay = 0 ) -->
<function name="cv::waitKey">
<noreturn>false</noreturn>
<returnValue type="int"/>
<arg nr="1" direction="in" default="0">
<not-uninit/>
<not-bool/>
</arg>
</function>
</def>

35
test/cfg/opencv2.cpp Normal file
View File

@ -0,0 +1,35 @@
// 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;
}
void ignoredReturnValue()
{
// cppcheck-suppress ignoredReturnValue
cv::imread("42.png");
}

View File

@ -365,6 +365,33 @@ else
fi
${CPPCHECK} ${CPPCHECK_OPT} --library=openssl ${DIR}openssl.c
# opencv2.cpp
set +e
pkg-config --version
PKGCONFIG_RETURNCODE=$?
set -e
if [ $PKGCONFIG_RETURNCODE -ne 0 ]; then
echo "pkg-config needed to retrieve OpenCV configuration is not available, skipping syntax check."
else
set +e
OPENCVCONFIG=$(pkg-config --cflags opencv)
OPENCVCONFIG_RETURNCODE=$?
set -e
if [ $OPENCVCONFIG_RETURNCODE -eq 0 ]; then
set +e
echo -e "#include <opencv2/opencv.hpp>\n" | ${CXX} ${CXX_OPT} ${OPENCVCONFIG} -x c++ -
OPENCVCONFIG_RETURNCODE=$?
set -e
if [ $OPENCVCONFIG_RETURNCODE -ne 0 ]; then
echo "OpenCV not completely present or not working, skipping syntax check with ${CXX}."
else
echo "OpenCV found and working, checking syntax with ${CXX} now."
${CXX} ${CXX_OPT} ${OPENCVCONFIG} ${DIR}opencv2.cpp
fi
fi
fi
${CPPCHECK} ${CPPCHECK_OPT} --library=opencv2 ${DIR}opencv2.cpp
# Check the syntax of the defines in the configuration files
set +e
xmlstarlet --version

View File

@ -460,6 +460,7 @@ def get_libraries():
'microsoft_sal': ['<sal.h>'],
'motif': ['<X11/', '<Xm/'],
'nspr': ['<prtypes.h>', '"prtypes.h"'],
# 'opencv2': ['<opencv2/', '"opencv2/'], <= enable after release of version 1.90
'opengl': ['<GL/gl.h>', '<GL/glu.h>', '<GL/glut.h>'],
'openmp': ['<omp.h>'],
# 'openssl': ['<openssl/'], <= enable after release of version 1.90