0

这是我的图片链接:

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);
        }

    }
4

1 回答 1

0

您可以在肩部使用与前面的白线类似的标记。可能是不同的颜色——这样更容易与前面的白色标记区分开来。一旦你检测到肩标,计算长度应该很容易(类似于你为白色字符串所做的)。

于 2012-06-22T13:54:26.930 回答