error: ‘CV_RGB2GRAY’ was not declared in this scope
types_c.h:
简单来说,该头文件内包含大量宏定义等预编译内容,测试时发现,
opencv4版本后需要专门进行包含操作:
#include <opencv2/imgproc/types_c.h>
opencv3则不需要,偶尔会在某些调用时报错,具体情况到时候补充。
截图部分文件内容:
#ifndef OPENCV_IMGPROC_TYPES_C_H
#define OPENCV_IMGPROC_TYPES_C_H
#include "opencv2/core/core_c.h"
#ifdef __cplusplus
extern "C" {
#endif
/** @addtogroup imgproc_c
@{
*/
/** Connected component structure */
typedef struct CvConnectedComp
{
double area; /**<area of the connected component */
CvScalar value; /**<average color of the connected component */
CvRect rect; /**<ROI of the component */
CvSeq* contour; /**<optional component boundary
(the contour might have child contours corresponding to the holes)*/
}
CvConnectedComp;
/** Image smooth methods */
enum SmoothMethod_c
{
/** linear convolution with \f$\texttt{size1}\times\texttt{size2}\f$ box kernel (all 1's). If
you want to smooth different pixels with different-size box kernels, you can use the integral
image that is computed using integral */
CV_BLUR_NO_SCALE =0,
/** linear convolution with \f$\texttt{size1}\times\texttt{size2}\f$ box kernel (all
1's) with subsequent scaling by \f$1/(\texttt{size1}\cdot\texttt{size2})\f$ */
CV_BLUR =1,
/** linear convolution with a \f$\texttt{size1}\times\texttt{size2}\f$ Gaussian kernel */
CV_GAUSSIAN =2,
/** median filter with a \f$\texttt{size1}\times\texttt{size1}\f$ square aperture */
CV_MEDIAN =3,
/** bilateral filter with a \f$\texttt{size1}\times\texttt{size1}\f$ square aperture, color
sigma= sigma1 and