0
Android에서 사용해야하는 OpenCV를 사용하는 C++ 프로젝트가 있습니다.OpenCV는 Android에서 작동하지 않습니다.
Test.h :
#include <iostream>
class Test
{
public:
Test();
~Test();
static std::string getTest(std::string filePath);
};
Test.cpp에 : 단순화하기 위해,이 프로젝트의 코드라고 말할 수 있도록 나는 내 JNI 바인딩을 쓴 설정
#include "opencv2/imgcodecs.hpp"
#include "Test.h"
using namespace cv;
std::string Test::getSize(std::string filePath)
{
Mat image = imread(filePath, 1);
std::stringstream stringStream;
if(image.empty())
{
stringStream << "Error loading image at path: " << filePath;
std::string error = stringStream.str();
return error;
}
stringStream << "Image size: " << image.rows << " * " << image.cols;
std::string result = stringStream.str();
return result;
}
내 Android.mk가 컴파일되지만 imread 메소드가 작동하지 않습니다. 이미지가 비어 있습니다 (image.empty() 테스트가 true 임).
무엇이 잘못 될 수 있습니까? 나는 파일이 존재하는지 확인, 그래서 그것을 어느 것을 추측 :
- 권한 문제 (I 외부 저장 권한을 읽기/쓰기를 추가하지만 낮은 수준의 문제 일 수 있음)
- 파일 경로에 문제가 . 절대 경로 (예 : "/storage/emulated/0/test.jpg")를 제공했습니다. OpenCV는 상대 경로를 기대합니까? 그렇다면 무엇과 관련이 있나?