android jni打印log

  1. android log 头文件
#include "log.h"
#include
#include 

#define TAG "NDK"
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,TAG ,__VA_ARGS__)

2.打印log
与C中的printf 一样

LOGD("box pos\n");
LOGD("%f %f %f %f\n",box[0],box[1],box[2],box[3]);

3.保存日志
/storage/emulated/0 为手机根目录

 ofstream ofile;
 ofile.open("/storage/emulated/0/jpg_1_out.txt");
 ofile<<"[";
 for (int i = 0;i 0)
            ofile<<",";
        LOGD("%f,%f\n",coors[i],coors[i+1]);
        ofile<<"["<

4.char *保存yuv图片

 std::ofstream yuvofile;
 yuvofile.open("/storage/emulated/0/input_YUV.yuv");
 for (int i = 0;i

5.opencv FileStorage write yuv图片

    cv::Mat image_YUV, image_BGR;
    image_YUV.create(height*1.5, width, CV_8UC1);
    image_YUV.data = (unsigned char*)pBuf;
    cv::cvtColor(image_YUV, image_BGR,cv::COLOR_YUV2BGR_NV21);
    FileStorage storage("/storage/emulated/0/pic_1.txt", FileStorage::WRITE);
    storage<<"mat1"<

6.opencv FileStorage read pic_1.txt图片

   cv::Mat image1;
   cv::FileStorage fs(path1+image_yuv_bgr, cv::FileStorage::READ);
   fs ["mat1"]>> image1;
   fs.release();
   cv::imshow("face111111", image1);

7.python FileStorage 保存bgr 图片

    location_file_name="./real_input.txt"
    infile=cv2.FileStorage(location_file_name,cv2.FILE_STORAGE_WRITE)
    infile.write("mat1",src_img)
    infile.release()

android与jni互调暂时写这么多。

你可能感兴趣的:(linux,C++)