2012-06-22 28 views
0

這是我的圖片鏈接:如何獲得測量在java中的肩膀,手臂的長度?

http://compsci.ca/v3/download.php?id=9165&sid=8b1ef1788c32286c495e956bc6cd2df3

我有檢測身體上的白線,並獲得長度。我的問題是如何檢測的肩膀,然後拿到肩膀,長度或手臂的測量..請幫助我:(

這是我的工作。如果有任何修正,請這樣做,建議我如何提高我的計劃..

import java.io.*; 

import java.awt.*; 

import javax.imageio.ImageIO; 

import java.awt.image.BufferedImage; 

import javax.swing.*; 

import javax.swing.JOptionPane; 


public class GetPixelColor 
{ 
    private static int maxCnt; 

    public static void main(String args[]) throws IOException 
    { 

     File file= new File("image.jpg"); 
     BufferedImage image = ImageIO.read(file); 
     int array[][] = new int [300][400]; 


      for(int i=0; i<300; i++) 
      { 
       for(int j=0; j<400; j++) 
       { 
        // Getting pixel color by position x=j and y=j 
        int clr= image.getRGB(j,i); 
        int red = (clr & 0x00ff0000) >> 16; 
        int green = (clr & 0x0000ff00) >> 8; 
        int blue = clr & 0x000000ff; 

        //System.out.println(".................................."); 
        //System.out.println("Red Color value = "+ red); 
        //System.out.println("Green Color value = "+ green); 
        //System.out.println("Blue Color value = "+ blue); 
        //System.out.println(".................................."); 

        if((red >= 160 && red <= 200) && (green >= 160 && green <= 190) && (blue >= 160 && blue <= 180))//cari kaler 
        { 
         //if(red > 160 && green > 160 && blue > 180) 
         // System.out.print("{"+j+"||"+i+"[0]}"); 
          array[i][j] = 0; 
          System.out.print("0"); 
         } 
         else 
         { 
          array[i][j] = 1; 
          System.out.print("-"); 
         } 
       } 
       System.out.println(); 
      } 

      System.out.println(array[0].length); 
      System.out.println(array.length); 
      int x2 = 0; 
      int y2 = 0; 
      for (int i = (400-1); i >= 0; i--)// 
      { 
       for(int j = (300-1); j >= 0; j--) 
       { 
        System.out.print(array[j][i]); 
        if(array[j][i] == 0) 
        { 
         //System.out.print("position2 : x="+i+" y="+j); 
         x2 = i; 
         y2 = j; 
         i = -1; 
         break; 

        } 
       } 
       System.out.println(); 
      } 
      JOptionPane.showMessageDialog(null,"coordinate : \n" + "x : " + x2 +"\n y : "+ y2); 
      int x = 0; 
      int y = 0; 
      for (int i = 0; i <400; i++) 
      { 
       for(int j = 0; j < 300; j++) 
       { 
        System.out.print(array[j][i]); 
        if(array[j][i] == 0) 
        { 
         //System.out.print("position1 : x="+i+" y="+j); 
         x = i; 
         y = j; 
         i = 400; 
         break; 
        } 
       } 
       System.out.println(); 
      } 
      JOptionPane.showMessageDialog(null,"coordinate : \n" + "x : " +x+"\n y : "+y); 

      double m = 0.0; 

      m = Math.sqrt(Math.pow(y-y2,2) + Math.pow(x-x2,2)); 
      JOptionPane.showMessageDialog(null,"length of the string : "+m); 
      double ratio = 0; 
      ratio = m/10; 
      JOptionPane.showMessageDialog(null,"ratio per inch : " + ratio); 
     } 

    } 

回答

0

您可以使用類似的標記在肩膀上的白線在前面也許在不同的顏色 - 這使得它更容易從白色標誌在前面區分。 一旦檢測到肩的標記,它應該很容易算出的長度(類似於您爲白線做了什麼)。