Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/135.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ OpenCV.norm中的断言错误_C++_Opencv_Runtime Error_Hamming Distance - Fatal编程技术网

C++ OpenCV.norm中的断言错误

C++ OpenCV.norm中的断言错误,c++,opencv,runtime-error,hamming-distance,C++,Opencv,Runtime Error,Hamming Distance,我在用汉明距离来寻找视频中两幅图像的差异。这是我的密码: #include <iostream> #include "opencv2/opencv.hpp" using namespace cv; int main(int argc, char** argv) { char const* filename = ("video.mp4"); VideoCapture video(filename); Mat frame, temp; for(unsig

我在用汉明距离来寻找视频中两幅图像的差异。这是我的密码:

#include <iostream>
#include "opencv2/opencv.hpp"
using namespace cv; 
int main(int argc, char** argv)
{
    char const* filename = ("video.mp4");
    VideoCapture video(filename);
    Mat frame, temp;
    for(unsigned int i = 0; i<100; i++)
    {
        video >> frame;
        if (i > 0)
        {
            double dist = norm(frame, temp, NORM_HAMMING);
            cout<<"Dist= "<< dist <<endl;
        }
        temp = frame;
    }
    return 0; 
 }
该计划属于

**OpenCV Error**: Assertion failed (normType == NORM_INF || normType == NORM_L1 || normType == NORM_L2 || normType == NORM_L2SQR || ((normType == NORM_HAMMING || normType == NORM_HAMMING2) && src1.type() == CV_8U))in norm, in file /home/andrio/.local/share/Trash/files/build/OpenCV/modules/core/src/stat.cpp, line 3123 terminate called after throwing an instance of 'cv::Exception' what():  /home/andre/.local/share/Trash/files/build/OpenCV/modules/core/src/stat.cpp:3123: error: (-215) normType == NORM_INF || normType == NORM_L1 || normType == NORM_L2 || normType == NORM_L2SQR || ((normType == NORM_HAMMING || normType == NORM_HAMMING2) && src1.type() == CV_8U) in function norm
UPD:此代码正在工作:

double dist = norm(frame, temp, NORM_L2);

你需要把图像变成灰色

cvtColor(frame, frame, CV_BGR2GRAY);

那么,调用该函数时,
矩阵是什么数据类型?是否确实加载了任何图像?在将其作为参数传递给其他函数之前,不需要进行任何验证。frame.type()和temp.type()输出为16。这里没有说明数组类型中应该包含什么。
cvtColor(frame, frame, CV_BGR2GRAY);