Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "opencv2/opencv.hpp"
- using namespace std;
- using namespace cv;
- // >>>>> Color to be tracked
- #define MIN_H_BLUE 200
- #define MAX_H_BLUE 300
- // <<<<< Color to be tracked int main() { // Camera frame cv::Mat frame; // >>>> Kalman Filter
- int main()
- {
- // Camera frame
- cv::Mat frame;
- // >>>> Kalman Filter
- int stateSize = 6;
- int measSize = 4;
- int contrSize = 0;
- unsigned int type = CV_32F;
- cv::KalmanFilter kf(stateSize, measSize, contrSize, type); //c32f om filter nauwkeurig te houden
- cv::Mat state(stateSize, 1, type); // [x,y,v_x,v_y,w,h]
- cv::Mat meas(measSize, 1, type); // [z_x,z_y,z_w,z_h]
- cv::setIdentity(kf.transitionMatrix);
- kf.measurementMatrix = cv::Mat::zeros(measSize, stateSize, type);
- kf.measurementMatrix.at<float>(0) = 1.0f;
- kf.measurementMatrix.at<float>(7) = 1.0f;
- kf.measurementMatrix.at<float>(16) = 1.0f;
- kf.measurementMatrix.at<float>(23) = 1.0f;
- //cv::setIdentity(kf.processNoiseCov, cv::Scalar(1e-2));
- kf.processNoiseCov.at<float>(0) = 1e-2;
- kf.processNoiseCov.at<float>(7) = 1e-2;
- kf.processNoiseCov.at<float>(14) = 5.0f;
- kf.processNoiseCov.at<float>(21) = 5.0f;
- kf.processNoiseCov.at<float>(28) = 1e-2;
- kf.processNoiseCov.at<float>(35) = 1e-2;
- // Measures Noise Covariance Matrix R
- cv::setIdentity(kf.measurementNoiseCov, cv::Scalar(1e-1));
- // <<<< Kalman Filter
- // Camera Index
- int idx = 0;
- // Camera Capture
- VideoCapture test("/home/john/car.mpeg");
- // >>>>> Camera Settings
- if (!test.isOpened())
- {
- cout << "file not opened"<<endl;
- waitKey(0);
- return EXIT_FAILURE;
- }
- else
- {
- cout<<"video successfully opened"<<endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement