bytedeco/javacv

Unable to Read File Despite Correct Path and Permissions

Open

#2,260 opened on Aug 2, 2024

View on GitHub
 (0 comments) (0 reactions) (0 assignees)Java (1,583 forks)batch import
help wantedquestion

Repository metrics

Stars
 (6,985 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

My code:

package com.example.myapplication;

import org.bytedeco.opencv.opencv_core.; import org.bytedeco.opencv.opencv_imgproc.; import static org.bytedeco.opencv.global.opencv_core.; import static org.bytedeco.opencv.global.opencv_imgproc.; import static org.bytedeco.opencv.global.opencv_imgcodecs.; public class CameraMovementExample { public static void main() { //System.loadLibrary(); // 从文件路径读取两张图片 Mat image1 = imread("/storage/emulated/0/DCIM/Screenshots/Screenshot_2024-08-01-21-51-34-386_com.miui.mediaviewer.jpg"/, IMREAD_GRAYSCALE*/); //Mat image2 = imread("/storage/emulated/0/DCIM/Screenshots/Screenshot_2024-08-01-21-51-41-629_com.miui.mediaviewer.jpg"/, IMREAD_GRAYSCALE/); // 创建 CameraMovementEstimator 实例 // CameraMovementEstimator estimator = new CameraMovementEstimator();

    // 处理第一张图片
   // estimator.processFrame(image1);

    // 处理第二张图片并计算移动量
  //  estimator.processFrame(image2);
}

}

The WARN:

OpenCV/4.7.0: [ WARN:0@0.204] global loadsave.cpp:244 findDecoder imread_('/storage/emulated/0/DCIM/Screenshots/Screenshot_2024-08-01-21-51-34-386_com.miui.mediaviewer.jpg'): can't open/read file: check file path/integrity

I have performed the following verifications:

The file path is correct and matches the one provided.

The file permissions have been set to r&w, and the application has the necessary permissions to access the path.->if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, 1); }

environment:

redmi phone k70(android 14)

Contributor guide