1
Android 용 OpenCV 응용 프로그램을 작성했으며 기능을 테스트하기 위해 내 컴퓨터에서 일부 샘플 이미지를로드하고 결과를 내 컴퓨터에 다시 저장하여 기능 올바르게 작동합니다. Android Studio의 resources 폴더 아래에 jpg 파일을 놓고이 폴더에서 파일을로드 할 수 있지만 BitmapFactory는 항상 null을 반환합니다. 이 문제를 어떻게 해결해야합니까?안드로이드 스튜디오에서 단위 테스트를 위해 이미지를 로딩합니다.
File file = getFileFromPath(this, "roi_RGB.jpg");
BitmapFactory.Options options = new BitmapFactory.Options();
options.inPreferredConfig = Bitmap.Config.ARGB_8888;
options.inSampleSize = 4;
Bitmap bitmap = BitmapFactory.decodeFile(file.getAbsolutePath(), options);
나는대로 이미지를로드 :
private static File getFileFromPath(Object obj, String fileName) {
ClassLoader classLoader = obj.getClass().getClassLoader();
URL resource = classLoader.getResource(fileName);
return new File(resource.getPath());
}
비트 맵은 항상 null입니다.
리소스 폴더에 이미지를 저장하고로드하려고했습니다. (내 게시물에서 편집). 나는 여전히 null 비트 맵을 얻는다. – hAlE