Created
September 13, 2016 07:42
-
-
Save abankowski/2bfda4e3e0f475d1b831252217c69089 to your computer and use it in GitHub Desktop.
code for testing opencv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <opencv2/opencv.hpp> | |
#include <iostream> | |
using namespace cv; | |
using namespace std; | |
int main(int argc, char** argv ) | |
{ | |
cv::VideoCapture vcap; | |
if(!vcap.open("rtsp://admin:admin@192.168.101.123:80/0")) { | |
std::cout << "Error opening the video stream, sorry" << std::endl; | |
return -1; | |
} | |
double fps = vcap.get(CV_CAP_PROP_FPS); | |
std::cout << fps << std::endl; | |
std::cout << "Stream ok, waitkey" << std::endl; | |
Mat edges; | |
namedWindow("edges", 1); | |
if (vcap.isOpened()) { | |
std::cout << "VCap is open" << std::endl; | |
for (;;) { | |
Mat frame; | |
vcap >> frame; | |
if (frame.empty()) continue; | |
cvtColor(frame, edges, CV_BGR2GRAY); | |
GaussianBlur(edges, edges, Size(7,7), 1.5, 1.5); | |
Canny(edges, edges, 0, 30, 3); | |
imshow("edges", edges); | |
if(waitKey(30) >= 0) break; | |
} | |
} | |
waitKey(0); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment