Skip to content
Snippets Groups Projects
Commit d8d22b44 authored by RIBEIRO-LUSTOSA Leandro's avatar RIBEIRO-LUSTOSA Leandro
Browse files

added aruco markers detection (not sent to MATLAB yet!)

parent 91eeeb52
No related branches found
No related tags found
No related merge requests found
#include "opencv2/opencv.hpp"
#include "opencv2/aruco.hpp"
#include <iostream>
#include <stdlib.h>
......@@ -12,8 +13,6 @@
#define MATLAB_PORT 11112
#define MAXLINE 1024
using namespace cv;
int main(int argc, char** argv) {
int sockfd;
......@@ -34,17 +33,25 @@ int main(int argc, char** argv) {
cliaddr.sin_addr.s_addr = INADDR_ANY;
cliaddr.sin_port = htons(MATLAB_PORT);
Mat frame;
cv::Mat frame;
VideoCapture cap("udp://127.0.0.1:11111",CAP_FFMPEG);
cv::VideoCapture cap("udp://127.0.0.1:11111", cv::CAP_FFMPEG);
cap >> frame; // get a first frame!
std::vector<int> markerIds;
std::vector<std::vector<cv::Point2f>> markerCorners, rejectedCandidates;
cv::Ptr<cv::aruco::DetectorParameters> parameters = cv::aruco::DetectorParameters::create();
cv::Ptr<cv::aruco::Dictionary> dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_4X4_100);
for(;;) {
cap >> frame;
imshow("tello vision", frame);
cv::aruco::detectMarkers(frame, dictionary, markerCorners, markerIds, parameters, rejectedCandidates);
cv::aruco::drawDetectedMarkers(frame, markerCorners, markerIds);
cv::imshow("tello vision", frame);
sendto(sockfd, (const char *)hello, strlen(hello),
0, (const struct sockaddr *) &cliaddr,
......@@ -52,7 +59,7 @@ int main(int argc, char** argv) {
if ( frame.empty() ) break; // end of video stream
if( waitKey(10) == 27 ) break; // stop capturing by pressing ESC
if( cv::waitKey(10) == 27 ) break; // stop capturing by pressing ESC
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment