티스토리 뷰

728x90

출처

소스

#include "opencv2/opencv.hpp"
#include <iostream>

using namespace cv;
using namespace std;

int main(void)
{

	VideoCapture cap("Zootopia.mp4");

	if (!cap.isOpened()) {
		cerr << "Camera open failed" << endl;
		return -1;
	}

	Mat frame, gray, blurred, edge;
	while (true) {
		//cap >> frame;
		cap.read(frame);

		if (frame.empty()) {
			break;
		}

		TickMeter tm;
		tm.start();

		cvtColor(frame, gray, COLOR_BGR2GRAY);
		bilateralFilter(gray, blurred, -1, 10, 5);
		Canny(blurred, edge, 50, 150);

		tm.stop();

		cout << tm.getTimeMilli() << "[ms]" << endl;
		
		imshow("frame", frame);
		imshow("blurred", blurred);
		imshow("edge", edge);
		
		if (waitKey(1) == 27) {
			break;
		}
	}

	return 0;
}

컴파일

$ g++ main.cpp -o main -std=c++11 `pkg-config --cflags --libs opencv4`

실행 (라즈베리파이3와 BPI-M2 ZERO의 실행 시간 비교)

pi@raspberrypi:~$ ./main          pi@bananapim2zero:~$ ./main
585.437[ms]                       1293.62[ms]                
514.686[ms]                       1309.49[ms]                
538.228[ms]                       1381.6[ms]                 
585.28[ms]                        1309.11[ms]                
525.669[ms]                       1298.43[ms]                
558.1[ms]                         1293.33[ms]                
501.31[ms]                        1291.57[ms]                
536.957[ms]                       1279.03[ms]                
546.125[ms]                       1279.27[ms]                
526.227[ms]                       1281.57[ms]                
592.775[ms]                       1319.66[ms]                
516.922[ms]                       1319.21[ms]                        
558.278[ms]                       1282.12[ms]                        
506.094[ms]                       1297.3[ms]                         
563.045[ms]                       1355.33[ms]                        
511.093[ms]                       1304.24[ms]                        
514.54[ms]                        1372.44[ms]                        
575.578[ms]                       1288.68[ms]                        
510.783[ms]                       1428.6[ms]                         
593.594[ms]                       1310.98[ms]                        
508.261[ms]                       1432.22[ms]                        
547.456[ms]                       1339.41[ms]                        
521.765[ms]                       1382.8[ms]                         
521.937[ms]                       1312.22[ms]                        
539.471[ms]                       1348.32[ms]                        
511.757[ms]                       1387.43[ms]                        
585.117[ms]                       1357.19[ms]  

실행 영상

댓글
300x250
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2024/03   »
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31
글 보관함