この単純なコードは実行できません。私は2枚の画像の間のオプティカルフローを計算しようとしています。単純な高密度オプティカルフロープログラムcalcOpticalFlowFarneback()openCV 3.2 cpp
アサーションがimg1
や大きさの異なるimg2
によるものである添付画像
OpenCV Error: Assertion failed (prev0.size() == next0.size() && prev0.channels() == next0.channels() && prev0.channels() == 1 && pyrScale_ < 1) in cv::`anonymous-namespace'::FarnebackOpticalFlowImpl::calc, file C:\Users\krato\Desktop\OpenCV\opencv-master\modules\video\src\optflowgf.cpp, line 1114
#include <Windows.h>
#include "opencv2\highgui.hpp"
#include "opencv2\imgproc.hpp"
#include "opencv2\objdetect\objdetect.hpp"
#include "opencv2/video/tracking.hpp"
#include <vector>
#include <stdio.h>
#include <Windows.h>
#include <iostream>
using namespace std;
using namespace cv;
// Display the results of the matches
//
int main(int argc, char* argv[])
{
cv::Mat img1 = cv::imread(argv[1], cv::IMREAD_GRAYSCALE);
cv::Mat img2 = cv::imread(argv[2], cv::IMREAD_GRAYSCALE);
cv::Mat res;
cv::calcOpticalFlowFarneback(img1,img2,img1,.4,1,12,2,8,1.2, 0);
cv:imshow("cat", res);
cv::waitKey(0);
}