如何在匹配图像Opencv Android中确定图像的点

如何在匹配图像Opencv Android中确定图像的点,android,image,opencv,Android,Image,Opencv,如何利用旋转模板图像确定匹配图像中的图像点,并返回最近值。 我想匹配模板图像和输入图像。 使用旋转模板图像进行匹配时的定点。 模板图像每旋转一次。 匹配的返回值为float并保存在数组列表中。 如何使用opencvandroid实现这一点 private Bitmap MatchImage(int match_method){ Bitmap bitmapInput = BitmapFactory.decodeFile(path+"/input_image_pj.bmp"); Ma

如何利用旋转模板图像确定匹配图像中的图像点,并返回最近值。 我想匹配模板图像和输入图像。 使用旋转模板图像进行匹配时的定点。 模板图像每旋转一次。 匹配的返回值为float并保存在数组列表中。 如何使用opencvandroid实现这一点

private Bitmap MatchImage(int match_method){
    Bitmap bitmapInput = BitmapFactory.decodeFile(path+"/input_image_pj.bmp");
    Mat matInput = new Mat ( bitmapInput.getHeight(), bitmapInput.getWidth(), CvType.CV_8U);
    Bitmap bitmapCopyInput = bitmapInput.copy(Bitmap.Config.ARGB_8888, true);
    Utils.bitmapToMat(bitmapCopyInput, matInput);


    Bitmap  tempImage = BitmapFactory.decodeResource(this.getResources(),R.drawable.image_template);
    Mat matTemp = new Mat ( tempImage.getHeight(), tempImage.getWidth(), CvType.CV_8U);
    Bitmap bitmapCopyTemp = tempImage.copy(Bitmap.Config.ARGB_8888, true);
    Utils.bitmapToMat(bitmapCopyTemp, matTemp);

    rotateTemp(matTemp,1);
    int result_cols = matInput.cols() - matTemp.cols() + 1;
    int result_rows = matInput.rows() - matTemp.rows() + 1;
    Mat matResult = new Mat(result_rows, result_cols, CvType.CV_32FC1);

    Imgproc.matchTemplate(matInput, matTemp, matResult, match_method);
    Core.normalize(matResult, matResult, 0, 1, Core.NORM_MINMAX, -1, new Mat());
    Toast.makeText(this, "Result : "+matResult, Toast.LENGTH_LONG).show();
    MinMaxLocResult mmr = Core.minMaxLoc(matResult);
    Point matchLoc;
    if (match_method == Imgproc.TM_SQDIFF || match_method == Imgproc.TM_SQDIFF_NORMED) {
        matchLoc = mmr.minLoc;
    } else {
        matchLoc = mmr.maxLoc;
    }

    Core.rectangle(matInput, matchLoc, new Point(matchLoc.x + matTemp.cols(),
            matchLoc.y + matTemp.rows()), new Scalar(0, 255, 0));

    // Save the visualized detection.
    System.out.println("Writing "+ resulfFile);
    Highgui.imwrite(path+resulfFile, matInput);

    Bitmap resultBitmap = Bitmap.createBitmap(matInput.cols(),  matInput.rows(),Bitmap.Config.ARGB_8888);;
    Utils.matToBitmap(matInput, resultBitmap);
    bitmapInput = resultBitmap;

    return resultBitmap;
}

private Mat rotateTemp(Mat matRotate,int degMore){
    //Rotate Image
    int degrees = 30 + degMore;
    Point center = new Point(matRotate.cols()/2, matRotate.rows()/2);
    Mat rotImage = Imgproc.getRotationMatrix2D(center, degrees, 1.0);
    Imgproc.warpAffine(matRotate, matRotate, rotImage, matRotate.size());
    //mat is rotated    
    return matRotate;
}

向我们展示您已经尝试过的内容。我添加了代码top@im0rtaliti。我不知道变量matResult中的值。