#include <stdio.h>
#include <vector>
#include <opencv2/opencv.hpp>
// Used for library linking
#ifdef _DEBUG
#pragma comment( lib, "opencv_core249d.lib" )
#pragma comment( lib, "opencv_highgui249d.lib" )
#pragma comment( lib, "opencv_imgproc249d.lib" )
#pragma comment( lib, "opencv_video249d.lib" )
#else
#pragma comment( lib, "opencv_core249.lib" )
#pragma comment( lib, "opencv_highgui249.lib" )
#pragma comment( lib, "opencv_imgproc249.lib" )
#pragma comment( lib, "opencv_video249.lib" )
#endif
// Using namespace
using namespace cv;
using namespace std;
class Histogram
{
...
};
class HistogramOfRed : public Histogram
{
private:
const int MaximumValueOfChannel = 256;
Mat GetImage(Mat &image)
{
vector<Mat> RGBImage;
split(image, RGBImage);
return RGBImage[2].clone();
}
public:
HistogramOfRed(int bin, Mat image) : Histogram(MaximumValueOfChannel, bin, GetImage(image){};
};
int main( int argc, char* argv[] )
{
Mat image = imread( "test.jpg" );
if ( image.empty() )
{
// Image is empty - image load error
printf( "Image load error. Check directory.\n" );
return 0;
}
imshow("original image", image);
waitKey();
HistogramOfRed histogramOfRed(256, image);
return 0;
}
when I call HistogramOfRed histogramOfRed(256, image)
error occurred.
below is callstack
.exe!std::allocator<cv::Mat>::deallocate(cv::Mat * _Ptr, unsigned int __formal)
.exe!std::_Wrap_alloc<std::allocator<cv::Mat> >::deallocate(cv::Mat * _Ptr, unsigned int _Count)
.exe!std::vector<cv::Mat,std::allocator<cv::Mat> >::_Tidy()
.exe!std::vector<cv::Mat,std::allocator<cv::Mat> >::~vector<cv::Mat,std::allocator<cv::Mat> >()
.exe!HistogramOfRed::GetImage(cv::Mat image)
.exe!HistogramOfRed::HistogramOfRed(int bin, cv::Mat image)
.exe!main(int argc, char * * argv)
不知道这是不是真正的错误,或者您只是在这里错误地复制了它,但是在HistogramOfRed(...)构造函数中缺少正确的括号
HistogramOfRed(int bin, Mat image) : Histogram(MaximumValueOfChannel, bin, GetImage(image) ) {};
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.