2014-11-14 61 views

回答

0

如果你知道的顏色你可以看它:

C++

glm::vec3 targetColor(1.0f,0,0);//(red,blue,green) 
float accepted_color_distance = 0.1f; 
/*how much must look the colors alike? distance 0 means the colors must be equal, 
but there are numeric precission problems. Use 0.0001f or 
something instead of 0.*/ 

bool markersFound[image.rows][image.cols]; //true means pixel y,x is a markers 

for(unsigned int a = 0; a < image.rows; a++) //init markersFound with false 
{ 
    for(unsigned int b = 0; b < image.cols; b++) 
    { 
     bool markersFound[a][b] = false; 
    } 
}  

for(unsigned int a = 0; a < image.rows; a++) 
{ 
    for(unsigned int b = 0; b < image.rows; b++) 
    { 
     glm::vec3 currentColor = image.at(a,b); 
     float color_distance = glm::distance(currentColor, targetColor); 

     if(color_distance < accepted_color_distance) //if a marker is found save it 
     { 
     bool markersFound[a][b] = true; 
     } 
     } 
} 
+0

你能請用C# – 2014-11-14 17:03:58

+4

如何無碼?你可以自己翻譯。你也應該更新你的帖子中的標籤來表示'C#'。這樣人們就不會用不想要的語言浪費時間。 – rayryeng 2014-11-14 17:20:47

+0

現在你正在進入SO:家庭作業。新的社區網站。 – mass 2014-11-15 04:16:43

相關問題