简体   繁体   中英

Cannot find symbol class vector in Android Studio

I'm getting this error "Cannot find symbol class vector" in my project. I have the whole java.util where is the Vector class. I tried to change the versions on my build.gradle but it didn't help.

I'd be grateful for any advice.

public class ObjectDetection {

    vector <DMatch> matches;
    public vector <ObjectRep> targets; // wektor zawierający obiekty klasy ObjectRep (jeszcze nie zawiera)
    float maxDist;
    ArrayList<Float> distances = new ArrayList<Float>();
    int noOfBestFeatures = 10;
    float distance;



    private float match(Mat frameDes, Mat objectDes)
    {
        MatOfDMatch matches = new MatOfDMatch();
        DescriptorMatcher matcher = DescriptorMatcher.create(DescriptorMatcher.
                BRUTEFORCE_HAMMINGLUT) ;

       matcher.match(frameDes, objectDes, matches);


        List<DMatch> matchesList = matches.toList();


        if(matchesList.size()<noOfBestFeatures)
            return Float.MAX_VALUE;


        float sum = 0f;
        float min = matchesList.get(0).distance;
        distances.clear();


        for(DMatch match : matchesList){
            min = Math.min(min, match.distance);
            distances.add(match.distance);
        }


        if(distances.size()<noOfBestFeatures)
            return Float.MAX_VALUE;


        Collections.sort(distances);
        for(int i = 0; i<noOfBestFeatures; i++) sum += distances.get(i);
        return sum;
    }

    public void findBestMatch(Mat cFrameDescriptors){


        if(targets==null)
            return;
        //Log.d("", " MAtching");


        if(cFrameDescriptors.size().height<1)   //jeżeli ramka ta jest mniejsza od 1 nie bierzemy pod uwagę
            return;
        matches.clear();
        float bestMatch = maxDist;
        Log.d("", " No of objects: " + targets.size());

        for(ObjectRep item : targets)
        {

            float match = match(cFrameDescriptors, item.bytesToMat());
            //Log.d("DETECTOR","OBJECT NAME: "+item.getName()+", match="+match );
            if(match>=maxDist) continue;
            matches.put(match, item);  // dodajemy do listy


            //Log.v("", Statics.LOGTAG+"item name: "+item.getName()+" match: "+match);
            bestMatch = Math.min(bestMatch, match);
        }


        Log.v("", " bestMatch: " + bestMatch);
        if(bestMatch == maxDist) return ;
        else
        {

            ObjectRep detectedObject=matches.get(bestMatch);
            String str=detectedObject.name;
            System.out.println("DETECTED: "+str);


        }


    }




}

You have to use

Vector

instead of

vector

The right class is java.util.Vector . Here the full doc .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM