| 
 | 
 
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册  
 
x
 
#include <opencv2/opencv.hpp> 
#include <iostream> 
#include <math.h> 
 
using namespace cv; 
 
int main() { 
        Mat src, dst; 
        src = imread("C:/Users/Administrator/Desktop/3.jpg"); 
        if (!src.data) { 
                printf("没有图片!"); 
                return -1; 
        } 
        namedWindow("input image", CV_WINDOW_AUTOSIZE); 
        imshow("input image", src); 
        /* 
        int cols = (src.cols - 1)*src.channels(); 
        int offsetx = src.channels(); 
        int rows = src.rows; 
        dst = Mat::zeros(src.size(), src.type()); 
        for (int row = 1; row < rows; row++) { 
                const uchar* previous = src.ptr<uchar>(row - 1); 
                const uchar* current = src.ptr<uchar>(row); 
                const uchar* next = src.ptr<uchar>(row + 1); 
                uchar*output = dst.ptr<uchar>(row); 
                for (int col = 1; col < offsetx; col++) { 
                        output[col] = saturate_cast<uchar>(5 * current[col] - (current[col - offsetx] + current[col + offsetx] + previous[col] + next[col])); 
 
                } 
        } 
        */ 
        Mat kernel = (Mat_<char>(3, 3) << 0, -1, 0, -1, 5, 0, -1, 0); 
        filter2D(src, dst, src.depth(), kernel); 
        namedWindow("change image output", CV_WINDOW_AUTOSIZE); 
        imshow("change image output", dst); 
        waitKey(0); 
        return 0; 
} 
 
 
错误提示:OpenCV(3.4.2) Error: Assertion failed (this->it == ((const Mat_<_Tp>*)this->it.m)->end()) in cv::MatCommaInitializer_<ch 
ar>::operator class cv::Mat_<char>, file g:\chengxu\opencv\opencv\build\include\opencv2\core\mat.inl.hpp, line 3299 
OpenCV: terminate handler is called! The last OpenCV error is: 
OpenCV(3.4.2) Error: Assertion failed (this->it == ((const Mat_<_Tp>*)this->it.m)->end()) in cv::MatCommaInitializer_<ch 
ar>::operator class cv::Mat_<char>, file g:\chengxu\opencv\opencv\build\include\opencv2\core\mat.inl.hpp, line 3299 
 
 
 
菜鸡一个,求大佬解答 |   
 
 
 
 |