【发布时间】:2021-04-28 01:35:07
【问题描述】:
我尝试使用 我的文件保存在手机的木材文件夹中
`String cfgPath= Environment.getExternalStorageDirectory().getPath()+"/lumber/yolov3_custom.cfg";
String weightsPath=Environment.getExternalStorageDirectory().getPath()+"/lumber/yolov3_custom_final.weights";
yoloModel= Dnn.readNetFromDarknet(cfgPath,weightsPath);`
没用 我还尝试使用资产文件夹中的输入流,然后保存文件
AssetManager assetManager= getAssets();
InputStream cfgStream= assetManager.open("yolov3_custom.cfg");
byte[] buffer= new byte[cfgStream.available()];
cfgStream.read(buffer);
File cfgFile = new File(getFilesDir(), "yolov3_customCp.cfg");
OutputStream outCfgStream= new FileOutputStream(cfgFile);
outCfgStream.write(buffer);
String cfgPath= cfgFile.getAbsolutePath();
Log.d("path: ", cfgPath);
InputStream weightsStream= assetManager.open("yolov3_custom_final.weights");
byte[] _buffer= new byte[weightsStream.available()];
weightsStream.read(_buffer);
File weightsFile= new File(getFilesDir(), "yolo_customCp.weights");
OutputStream outWeightsStream=new FileOutputStream(weightsFile);
outWeightsStream.write(_buffer);
String weightsPath= weightsFile.getAbsolutePath();
我仍然无法读取 Dnn.ReadFromDarknet() 中的文件
有什么办法吗?
另外,对于使用getApplicationContext().getFilesDir().getAbsolutePath(),我应该把我的文件放在哪里?
【问题讨论】: