无法找到本地变量' point'并且无法检测地标点

时间:2017-03-27 10:23:35

标签: android variables face-detection dlib

我正在使用Dlib来检测脸部地标。

如果我使用z3 compact来检测它,我可以得到68分。

但是,我在其他设备上得到 0点,例如nexus 5x,z5或一加二。

以下是我用来检测面部地标点的代码。

private Runnable landmarkDetection = new Runnable() {

    public void run() {
        // TODO Auto-generated method stu
        try {
            Canvas canvas = new Canvas(temp);
            canvas.drawBitmap(temp, new Matrix(), null);
            if (mFaceDet == null) {
                mFaceDet = new FaceDet(Constants.getFaceShapeModelPath());
            }
            List<VisionDetRet> faceList = mFaceDet.detect(path);
            if (faceList.size() > 0) {
                for (VisionDetRet ret : faceList) {
                    float width = 1080;
                    // By ratio scale
                    float aspectRatio = originalImg.getWidth() / (float) originalImg.getHeight();
                    float resizeRatio = 1;
                    final int MAX_SIZE = 1;
                    newWidth = 1080;
                    newHeight = 1380;
                    newHeight = Math.round(newWidth / aspectRatio);

                    if (originalImg.getWidth() > MAX_SIZE && originalImg.getHeight() > MAX_SIZE) {
                        originalImg = getResizedBitmap(originalImg, newWidth, newHeight);
                        resizeRatio = (float) originalImg.getWidth() / (float) width;
                        Log.d("resizeRatio ", resizeRatio + "");
                    }

                    ArrayList<Point> landmarks = ret.getFaceLandmarks();
                    int count = 0;
                    for (Point point : landmarks) {
                        float pointX = (point.x * resizeRatio);
                        float pointY = (point.y * resizeRatio);
                            landmark_pt_x.add(pointX);
                            landmark_pt_y.add(pointY);
                        Log.d(TAG, count + " " + pointX + " : " + pointY);
                        count++;

                        drawpoint(pointX, pointY, temp, canvas);
                    }
                    Log.d(TAG + " added landmark", count + "");
                }
            } else {
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        Toast.makeText(getApplicationContext(), "No face", Toast.LENGTH_SHORT).show();
                    }
                });
            }
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    imageView.setImageBitmap(originalImg);
                    progressDialog.dismiss();
                }
            });
        } catch (Exception e) {
            Log.e(TAG, e.toString());
        }
    }
};

我在一加二中使用调试模式。运行时出现以下错误

  

ArrayList&lt;点&gt; landmarks = ret.getFaceLandmarks();

screen shot 2017-03-27 at 2 17 36 pm

为什么我无法获得变量&#39; point&#39;?请给我一些帮助。非常感谢你。

0 个答案:

没有答案