我确实在原生部件中搜索了打印到文本或csv文件。人们讨论了如何使用AAssetManager_open & AAsset_read来创建资源文件夹。但我的文本文件只是为了调试目的,所以我认为我不需要使用它们。我只按如下方式实现了代码
LOGD("file start");
std::ofstream ofs("/data/data/com.prg.astralinkpeoplecount/image.csv", ios::out | ios::app);
LOGD("file created");
// for each row
for (int i = 0; i < img.rows; ++i) {
// for each column
const unsigned char* img_ptr = (unsigned char*) img.data + img.step * i;
for (int j = 0; j < img.cols; ++j)
ofs << *(img_ptr+j) << ',';
ofs << "\n";
}
ofs.close();代码运行。但我在任何文件夹里都找不到csv文件。可能会遗漏什么?谢谢
发布于 2014-08-07 11:49:01
我实现了打印到SDCARD,它工作了。我的代码如下。
int print(Mat &img) {
LOGD("file start");
std::ofstream ofs("/sdcard/mysdfile.csv", ios::out | ios::app);
LOGD("file created");
if(ofs!=NULL)
{
// for each row
for (int i = 0; i < img.rows; ++i) {
// for each column
const unsigned char* img_ptr = (unsigned char*) img.data + img.step * i;
for (int j = 0; j < img.cols; ++j)
ofs << *(img_ptr+j) << ',';
ofs << "\n";
}
ofs.close();
LOGD("file closed");
}
//
LOGD("file printed");
return 0;
}https://stackoverflow.com/questions/25173328
复制相似问题