2017-09-13 103 views
1

我正在檢測工業自動化技術C2相機上的ARUCO標記,這些相機旨在檢測三角測量掃描儀中的激光條紋,但它們也可以捕捉圖像。 我的問題是,無論我使用的相機如何,我都會檢測到相同的標記,除了我之前提到的相機。我的代碼 最小工作例子如下:OpenCV Aruco標記未在工業相機上識別

#include <opencv2/highgui.hpp> 
#include <opencv2/aruco/charuco.hpp> 

using namespace std; 
using namespace cv; 

int main(int argc, char *argv[]) { 

int squaresX = 10; 
int squaresY = 7; 
float squareLength = 28; 
float markerLength = 19; 
int dictionaryId = 6; 
bool showRejected = true; 
bool refindStrategy = true; 

Ptr<aruco::DetectorParameters> detectorParams = aruco::DetectorParameters::create(); 

Ptr<aruco::Dictionary> dictionary = 
    aruco::getPredefinedDictionary(aruco::PREDEFINED_DICTIONARY_NAME(dictionaryId)); 

// create charuco board object 
Ptr<aruco::CharucoBoard> charucoboard = 
    aruco::CharucoBoard::create(squaresX, squaresY, squareLength, markerLength, dictionary); 
Ptr<aruco::Board> board = charucoboard.staticCast<aruco::Board>(); 

Mat image = imread("C:\\Users\\Piotrek\\Desktop\\calib\\022.jpg"), imageCopy; 

vector<int> markerIds, charucoIds; 
vector< vector<Point2f> > markerCorners, rejectedMarkers; 
vector<Point2f> charucoCorners; 

// detect markers 
aruco::detectMarkers(image, dictionary, markerCorners, markerIds, detectorParams, 
    rejectedMarkers); 

image.copyTo(imageCopy); 
if (markerIds.size() > 0) { 
    aruco::drawDetectedMarkers(imageCopy, markerCorners); 
} 

if (showRejected && rejectedMarkers.size() > 0) 
    aruco::drawDetectedMarkers(imageCopy, rejectedMarkers, noArray(), Scalar(100, 0, 255)); 

//display results 
imshow("out", imageCopy); 
waitKey(0); 

return 0; 
} 

Sample image from camera:

的問題是,檢測到的標記,但不知什麼原因,他們被拒絕:

Rejected markers

我用的OpenCV 3.1 。

回答

0

問題解決了。我必須翻轉圖像,現在可以完美地檢測標記。