2012-12-12 下载ndk编译出so和可执行文件,放到android 真机运行,包含源码。

一、下载ndk链接NDK 下载  |  Android NDK  |  Android Developers

二、解压ndk后得到下面的文件,里面包含ndk-build.cmd,这个是用来编译的。

三、Android.mk和C源码。完整源码下载路径https://download.csdn.net/download/qq_37858386/88622702

3.1 Android.mk

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE    := libgiada
LOCAL_SRC_FILES := giada.c
LOCAL_LDLIBS += -llog 
LOCAL_LDLIBS +=-lm
LOCAL_HEADER_LIBRARIES := jni_headers
include $(BUILD_SHARED_LIBRARY)


include $(CLEAR_VARS)
LOCAL_MODULE    := test
LOCAL_SRC_FILES := test.c
LOCAL_LDLIBS += -llog 
LOCAL_LDLIBS +=-lm
LOCAL_HEADER_LIBRARIES := jni_headers
include $(BUILD_EXECUTABLE)

3.2 Application.mk

APP_ABI :=  armeabi-v7a arm64-v8a

3.3 test.c

/* DO NOT EDIT THIS FILE - it is machine generated */


#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <errno.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
#include <stdint.h>
#include <termios.h>
#include <android/log.h>

void main()
{
	printf("Hello world\n");
}

3.4 giada.c

/* DO NOT EDIT THIS FILE - it is machine generated */


#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <errno.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
#include <stdint.h>
#include <termios.h>
#include <android/log.h>
#include <sys/ioctl.h>

#include "giada.h"


#define CAMERA_INFO_STRUCT_CONTAIN_BYTES_LEN  0

struct image_meta
{
	char     fourcc[4];
	// crop info
	uint16_t left;
	uint16_t top;
	uint16_t width;
	uint16_t height;
	uint8_t  subsample;
	uint8_t  dummy;
	uint16_t dc;
	uint32_t exposure_us;	// 0~65535 ms
	uint16_t voltage_mv;	// 0~65535 mv
	uint16_t prehold_ms;	// ms
}__attribute__((packed));

struct cmd_header 
{
	uint16_t cmd;
	uint16_t ack;
	struct image_meta meta;
}__attribute__((packed));

struct sync_header
{
	uint8_t cmd;
	uint8_t ack;
    uint16_t len;
}__attribute__((packed));

struct file_content_header
{
    uint32_t magic;
    uint32_t len;
    int64_t  size;
    int64_t  off;
    char     path[256];
    uint8_t  content[0];
}__attribute__((packed));

#define CONTENT_LEN 0x10000
struct file_content
{
    uint32_t magic;
    uint32_t len;
    int64_t  size;
    int64_t  off;
    char     path[256];
    uint8_t  content[CONTENT_LEN];
}__attribute__((packed));

struct image_content_header
{
	uint32_t magic;
	uint8_t  type;	// PREVIEW, CAPTURE, & CONTINUOUS
    uint8_t  compress:1;
    uint8_t  dummy:7;
	uint16_t serial;	// continuous shoot
	uint32_t len;
    uint32_t  size;	// total size
    //int64_t  off;
    struct   image_meta meta;
    char     path[128];
    char     name[128];
}__attribute__((packed));

struct enum_header
{
	uint8_t  magic;
	uint8_t  cmd;
	uint8_t  ack;
	uint8_t serial;
	uint16_t len;
}__attribute__((packed));

struct thermal
{
    uint32_t soc;
    uint32_t near_sensor;
    uint32_t sensor;
};
struct camera_config
{
	char CamPartNum[16];
	char FPIPartNum[16];
	char SensorPartNum[16];
	uint16_t FPIMaxVoltage;
	uint16_t FPIMaxPreviewVoltage;;
	uint16_t FPIVoltageStep;
	uint16_t FPIStepSleep;
	uint16_t FPIMaxPrehold;
	uint16_t MaxExposure;
	uint16_t MaxWidth;
	uint16_t MaxHeight;
    uint16_t Transpose;
    uint16_t dummy;
    char     reserved[128];
}__attribute__((packed));

struct camera_info
{
    uint16_t width;
    uint16_t height;
    uint8_t  channel;
    uint8_t  bits_per_channel;
    uint8_t  bytes_per_channel;
    uint8_t  hw_version;
    uint16_t version;
    uint16_t cache_count;
    struct camera_config config;
    struct thermal thermal;
}__attribute__((packed));

struct capture_time
{
        int      frame_advanced;
        uint32_t set_expo_time;
        uint32_t set_volt_time;
        uint32_t volt_hold_time;
        uint32_t first_frame_time;
        uint32_t second_frame_time;
        uint64_t trig_start_time;
        uint64_t trig_timestamp;
        uint64_t frame_timestamp;
        uint64_t real_timestamp;
}__attribute__((packed));

struct voltage_step
{
    uint16_t step_mv;
    uint16_t sleep_ms;
}__attribute__((packed));

#define VERSIONS_LEN  255
struct camera_desc
{
    uint32_t ip;
    uint32_t client_ip;
    uint8_t  mac[6];
    char     ifname[18];
    char	 cam_name[32];
    struct   camera_config config;
    char     versions[VERSIONS_LEN];
    char     hw_version;
}__attribute__((packed));

struct session_header
{
    uint16_t id;
    uint16_t ack;
    uint32_t len;
}__attribute__((packed));

#define TAG "NETCAP-JNI"
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, TAG, __VA_ARGS__)
#define LOGI(...) __android_log_print(ANDROID_LOG_INFO, TAG, __VA_ARGS__)
#define LOGW(...) __android_log_print(ANDROID_LOG_WARN, TAG, __VA_ARGS__)
#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, TAG, __VA_ARGS__)
#define LOGF(...) __android_log_print(ANDROID_LOG_FATAL, TAG, __VA_ARGS__)


uint16_t  *des_image_ushort_buf;
uint8_t   *des_image_uchar_buf;

int32_t ItemCount;
struct continuous_shoot_element
{
        int voltage_mv;
        int prehold_ms;
        int exposure_us;
};
struct continuous_shoot_element *continuousItems;

uint16_t convert_u10_to_u8(uint8_t *dst, uint16_t *src, int w, int h)
{
    int i;
    uint64_t dc=0;
    uint16_t ret;

    for( i=0; i<w*h; i++ )
    {
        dst[i] = (uint8_t)(src[i]>>2);
        dc += src[i];
    }
    ret = dc/(w*h);
    return ret;
}

void decompress_u16_u10_64_C(uint16_t *dest, uint8_t *src, int w, int h)
{
	int i, j, n;
	uint8_t  *src_upper = src + w*h;
	uint16_t tmp;

    uint16_t temp;
	for( i=0; i<w*h; i+=64 )
	{
		for( n=0; n<4; n++ )
		{
			for( j=0; j<16; j++ )
			{
				tmp = ((src_upper[j] >> (2*n)) & 0x3);
				dest[i + j + n*16] = src[i + j + n*16] | (tmp << 8);
			}
		}
		src_upper += 16;
	}
}

JNIEXPORT jint JNICALL Java_com_hypernano_netcap_Netcap_native_1get_1continuous_1data
  (JNIEnv *env, jobject obj,jbyteArray j_item_data,jbyteArray j_count_data,jint count,
                      jintArray j_voltage_mv,jintArray j_prehold_ms,jintArray j_exposure_us)
{
     int i = 0;
     ItemCount = count ;
     struct continuous_shoot_element m_continuousItems[ItemCount];

     uint32_t *voltage_buf = (*env)->GetIntArrayElements(env,j_voltage_mv,NULL);
     uint32_t *prehold_buf = (*env)->GetIntArrayElements(env,j_prehold_ms,NULL);
     uint32_t *exposure_buf = (*env)->GetIntArrayElements(env,j_exposure_us,NULL);

    #if 1
       for(i = 0;i < ItemCount; i++){

            m_continuousItems[i].voltage_mv  = voltage_buf[i];
            m_continuousItems[i].prehold_ms  = prehold_buf[i];
            m_continuousItems[i].exposure_us = exposure_buf[i];
            LOGI("[%s] m_continuousItems[%d].voltage_mv=%d,m_continuousItems[i].prehold_ms=%d,m_continuousItems[i].exposure_us=%d;\n",__func__,
                                       i,m_continuousItems[i].voltage_mv,m_continuousItems[i].prehold_ms,m_continuousItems[i].exposure_us);
       }
   	   LOGI("[%s] sizeof(ItemCount)=%d,ItemCount=%d;sizeof(struct continuous_shoot_element)=%d.\n",__func__,
   	                      sizeof(ItemCount),ItemCount,sizeof(struct continuous_shoot_element));

    #endif
    (*env)->SetByteArrayRegion(env, j_count_data, 0, sizeof(ItemCount), &ItemCount);
    (*env)->SetByteArrayRegion(env, j_item_data, 0, (sizeof(struct continuous_shoot_element)) * ItemCount, m_continuousItems);
    (*env)->ReleaseIntArrayElements(env,j_voltage_mv, voltage_buf, 0);
    (*env)->ReleaseIntArrayElements(env,j_prehold_ms, prehold_buf, 0);
    (*env)->ReleaseIntArrayElements(env,j_exposure_us, exposure_buf, 0);
    return 0;
}

JNIEXPORT jint JNICALL Java_com_hypernano_netcap_Netcap_native_1get_1rename_1content_1data
  (JNIEnv *env, jobject obj,jbyteArray byte_data,jbyteArray j_new_name)
{
    struct file_content m_file_content;
    jbyte   *byte_new_name = (*env)-> GetByteArrayElements(env,j_new_name, NULL);
    int     len_byte_new_name = (*env)-> GetArrayLength(env,j_new_name);
    memset(&m_file_content,0,sizeof(m_file_content));
    m_file_content.off = 0;
    m_file_content.size = len_byte_new_name;
    m_file_content.magic = 0xbeaffeed;
    strcpy(m_file_content.path, "camera-name");
    m_file_content.len = len_byte_new_name;

    #if 1
	   LOGI("[%s] sizeof(m_file_content)=%d,sizeof(struct file_content_header)=%d;len_byte_new_name=%d,new_name:%s;\n",__func__,sizeof(m_file_content),sizeof(struct file_content_header),len_byte_new_name,byte_new_name);
    #endif
    (*env)->GetByteArrayRegion(env,j_new_name, 0, m_file_content.len, m_file_content.content);
    (*env)->SetByteArrayRegion(env, byte_data, 0, sizeof(struct file_content_header) + m_file_content.len, &m_file_content);
    (*env)->ReleaseByteArrayElements(env,j_new_name, byte_new_name, 0);
	return 0;
}

JNIEXPORT jint JNICALL Java_com_hypernano_netcap_Netcap_native_1get_1sync_1header_1data
  (JNIEnv *env, jobject obj,jbyteArray byte_data,jint cmd,jint ack,jint len)
{
    struct sync_header m_sync_header;
    memset(&m_sync_header,0,sizeof(m_sync_header));
    m_sync_header.cmd = cmd;
    m_sync_header.ack = ack;
    m_sync_header.len = len;
    (*env)->SetByteArrayRegion(env, byte_data, 0, sizeof(m_sync_header), &m_sync_header);
    #if 1
	LOGI("[%s] sizeof(m_sync_header)=%d ,cmd=%d , ack=%d, len=%d;\n",__func__,sizeof(m_sync_header), cmd , ack, len);
    #endif
	return 0;
}


JNIEXPORT jint JNICALL Java_com_hypernano_netcap_Netcap_native_1get_1camera_1desc
  (JNIEnv *env, jobject obj,jbyteArray src_data,jbyteArray cam_name,jbyteArray ip)
{
      struct camera_desc m_camera_desc;
  	  uint8_t *src_buf = (*env)->GetByteArrayElements(env,src_data,NULL);
      memset(&m_camera_desc,0,sizeof(m_camera_desc));
      memcpy(&m_camera_desc,src_buf + 6, sizeof(m_camera_desc));
      (*env)->SetByteArrayRegion(env, cam_name, 0, sizeof(m_camera_desc.cam_name), &m_camera_desc.cam_name);
      (*env)->SetByteArrayRegion(env, ip, 0, sizeof(m_camera_desc.ip), &m_camera_desc.ip);
      #if 0
  	  LOGI("[%s] sizeof(camera_desc)=%d,m_camera_desc.cam_name=%s,m_camera_desc.ip=0x%x,client_ip=0x%x\n",__func__,
  	                            sizeof(m_camera_desc),m_camera_desc.cam_name,m_camera_desc.ip,m_camera_desc.client_ip);
  	  LOGI("[%s] sizeof(m_camera_desc.cam_name)=%d,versions=%s,hw_version=%d\n",__func__,sizeof(m_camera_desc.cam_name),m_camera_desc.versions,m_camera_desc.hw_version);
      #endif
      (*env)->ReleaseByteArrayElements(env,src_data,src_buf,0);
  	  return 0;
}
JNIEXPORT jint JNICALL Java_com_hypernano_netcap_Netcap_native_1get_1voltage_1step_1data
  (JNIEnv *env, jobject obj,jbyteArray byte_data,jint step_mv,jint sleep_ms)
{
    struct voltage_step m_voltage_step;
    m_voltage_step.step_mv = step_mv;
    m_voltage_step.sleep_ms = sleep_ms;
    (*env)->SetByteArrayRegion(env, byte_data, 0, sizeof(m_voltage_step), &m_voltage_step);
	LOGI("[%s] sizeof(voltage_step)=%d\n",__func__, sizeof(m_voltage_step));
	return 0;
}


JNIEXPORT jint JNICALL Java_com_hypernano_netcap_Netcap_native_1get_1session_1header
  (JNIEnv *env, jobject obj,jbyteArray j_src_data,jintArray j_member_data)
{
    int id;
    int ack;
    int len;
    struct session_header m_session_header;
    uint8_t *src_data_buf = (*env)->GetByteArrayElements(env,j_src_data,NULL);

    memcpy(&m_session_header,src_data_buf, sizeof(m_session_header));
    id  = m_session_header.id;
    ack  = m_session_header.ack;
    len  = m_session_header.len;
    (*env)->SetIntArrayRegion(env, j_member_data, 0, 1, &id);
    (*env)->SetIntArrayRegion(env, j_member_data, 1, 1, &ack);
    (*env)->SetIntArrayRegion(env, j_member_data, 2, 1, &len);
#if 0
    LOGI("[%s] sizeof(struct session_header)=%d\n;id=%d,ack=%d,len=%d \n",__func__,
                sizeof(struct session_header),m_session_header.id,m_session_header.ack,m_session_header.len);
#endif
    (*env)->ReleaseByteArrayElements(env,j_src_data,src_data_buf,0);
	return sizeof(struct session_header);
}
JNIEXPORT jint JNICALL Java_com_hypernano_netcap_Netcap_native_1getcapturetimeandthermal_1data
  (JNIEnv *env, jobject obj,jbyteArray src_data,jintArray soc,jintArray near_sensor,jintArray sensor)
{
    struct thermal  m_thermal;
    struct capture_time m_capture_time;
    uint8_t *src_buf = (*env)->GetByteArrayElements(env,src_data,NULL);
    memset(&m_capture_time,0,sizeof(m_capture_time));
    memset(&m_thermal,0,sizeof(m_thermal));
    memcpy(&m_capture_time,src_buf, sizeof(m_capture_time));
    memcpy(&m_thermal,src_buf + sizeof(m_capture_time), sizeof(m_thermal));
    (*env)->SetIntArrayRegion(env, soc, 0, 1, &m_thermal.soc);
    (*env)->SetIntArrayRegion(env, near_sensor, 0, 1, &m_thermal.near_sensor);
    (*env)->SetIntArrayRegion(env, sensor, 0, 1, &m_thermal.sensor);
    #if 0
	LOGI("[%s] sizeof(m_capture_time)=%d ,sizeof(m_thermal)=%d,soc=%d,near_sensor=%d,sensor=%d\n",__func__,
	                 sizeof(m_capture_time),sizeof(m_thermal),m_thermal.soc,m_thermal.near_sensor,m_thermal.sensor);
    #endif
    (*env)->ReleaseByteArrayElements(env,src_data,src_buf,0);
	return 0;
}

JNIEXPORT jint JNICALL Java_com_hypernano_netcap_Netcap_native_1getcommand_1data
  (JNIEnv *env, jobject obj,jbyteArray byte_data,jint cmd,jint left,jint top,jint width,jint height,
                                          jint prehold_ms,jint voltage_mv,jint exposure_us,jint ack,jshort subsample)
{
    struct cmd_header m_cmd_header;
    struct image_content_header  m_image_content_header;
    memset(&m_cmd_header,0,sizeof(m_cmd_header));
    m_cmd_header.cmd = cmd;
    m_cmd_header.meta.left = left;
    m_cmd_header.meta.top  = top;
    m_cmd_header.meta.width = width;
    m_cmd_header.meta.height = height;
    m_cmd_header.meta.prehold_ms = prehold_ms;
    m_cmd_header.meta.voltage_mv = voltage_mv;
    m_cmd_header.meta.exposure_us = exposure_us;
    m_cmd_header.ack = ack;
    m_cmd_header.meta.subsample = (uint8_t) subsample;

    (*env)->SetByteArrayRegion(env, byte_data, 0, sizeof(m_cmd_header), &m_cmd_header);
    #if 0
	LOGI("[%s] sizeof(m_cmd_header)=%d ,sizeof(m_image_content_header)=%d ,m_cmd_header.ack=%d,m_cmd_header.meta.subsample=%d;\n",__func__,
	                 sizeof(m_cmd_header),sizeof(m_image_content_header),m_cmd_header.ack, m_cmd_header.meta.subsample);
    #endif
	return 0;
}

JNIEXPORT jint JNICALL Java_com_hypernano_netcap_Netcap_native_1enumheader_1data
  (JNIEnv *env, jobject obj,jbyteArray byte_data,jint magic,jint cmd,jint ack,jint serial,jint len)
{
    int m_len;
    struct enum_header m_enum_header;
    memset(&m_enum_header,0,sizeof(m_enum_header));
    m_enum_header.magic = magic;
    m_enum_header.cmd = cmd;
    m_enum_header.ack = ack;
    m_enum_header.serial = serial;
    m_enum_header.len  = len;

    (*env)->SetByteArrayRegion(env, byte_data, 0, sizeof(m_enum_header), &m_enum_header);
    m_len = sizeof(m_enum_header);
	//LOGI("[%s] sizeof(m_enum_header)=%d ;\n",__func__,m_len);
	return 0;
}

JNIEXPORT jint JNICALL Java_com_hypernano_netcap_Netcap_native_1getcapture_1data
  (JNIEnv *env, jobject obj,jbyteArray des_data,jbyteArray src_data,jint width,jint height)
{
     uint8_t *image_buf = (*env)->GetByteArrayElements(env,src_data,NULL);
#if 0
     if(des_image_uchar_buf == NULL)
        des_image_uchar_buf = (uint8_t *)malloc(width * height);

     if(des_image_ushort_buf == NULL)
       des_image_ushort_buf = (uint16_t *)malloc(width * height);

     decompress_u16_u10_64_C(des_image_ushort_buf, image_buf,width, height);
     convert_u10_to_u8(des_image_uchar_buf, des_image_ushort_buf, width, height);
     (*env)->SetByteArrayRegion(env, des_data, 0, width * height, des_image_uchar_buf);
     LOGI("[%s]  m_width=%d,m_height=%d ",__func__,width,height);
#else
     if(des_image_ushort_buf == NULL)
       des_image_ushort_buf = (uint16_t *)malloc(width * height);

     decompress_u16_u10_64_C(des_image_ushort_buf, image_buf,width, height);
     (*env)->SetByteArrayRegion(env, des_data, 0, width * height * 2, des_image_ushort_buf);
     LOGI("[%s]  m_width=%d,m_height=%d ",__func__,width,height);
#endif
     (*env)->ReleaseByteArrayElements(env,src_data,image_buf,0);
     return 0;
}

JNIEXPORT jint JNICALL Java_com_hypernano_netcap_Netcap_native_1bayer10_1to_1rgb888
     (JNIEnv *env, jobject obj,jbyteArray rgb_des,jintArray j_bayer_src,jint w,jint h,jint type)
{
    int i, j;
    uint16_t r, g, b;
    uint64_t dc=0;
    uint16_t ret;
    uint32_t *bayer = (*env)->GetIntArrayElements(env,j_bayer_src,NULL);
    uint8_t  *rgb   = (uint8_t *) malloc(w * h * 3);
    int ta,tb,tc,td;
    for(i=0;i<h;i+=2)
    {
        for(j=0;j<w;j+=2)
        {
            switch(type)
            {
            case BGGR:
                b=bayer[ i*w + j];
                g=bayer[ i*w + (j+1)];
                r=bayer[(i+1)*w + (j+1)];
                break;
            case RGGB:
                r=bayer[ i*w + j];
                g=bayer[ i*w + (j+1)];
                b=bayer[(i+1)*w + (j+1)];
                break;
            case GRBG:
                g=bayer[ i*w + j];
                r=bayer[ i*w + (j+1)];
                b=bayer[(i+1)*w + j];
                break;
            case GBRG:
                g=bayer[ i*w + j];
                b=bayer[ i*w + (j+1)];
                r=bayer[(i+1)*w + j];
                break;
            }

            dc += g*2 + b + r;
            g >>= 2;
            b >>= 2;
            r >>= 2;
            rgb[i*w*3 + j*3 + 2]=(uint8_t)(b);
            rgb[(i+1)*w*3 + j*3 + 2]=(uint8_t)(b);
            rgb[i*w*3 + (j+1)*3 + 2]=(uint8_t)(b);
            rgb[(i+1)*w*3 + (j+1)*3 + 2]=(uint8_t)(b);

            rgb[i*w*3 + j*3 + 1]=(uint8_t)(g);
            rgb[(i+1)*w*3 + j*3 + 1]=(uint8_t)(g);
            rgb[i*w*3 + (j+1)*3 + 1]=(uint8_t)(g);
            rgb[(i+1)*w*3 + (j+1)*3 + 1]=(uint8_t)(g);

            rgb[i*w*3 + j*3]=(uint8_t)(r);
            rgb[(i+1)*w*3 + j*3]=(uint8_t)(r);
            rgb[i*w*3 + (j+1)*3]=(uint8_t)(r);
            rgb[(i+1)*w*3 + (j+1)*3]=(uint8_t)(r);

            ta=i*w*3 + j*3 + 2;
            tb=(i+1)*w*3 + j*3 + 2;
            tc=i*w*3 + (j+1)*3 + 2;
            td=(i+1)*w*3 + (j+1)*3 + 2;
        }
    }
     ret = dc/(w*h);
     (*env)->SetByteArrayRegion(env, rgb_des, 0, w * h * 3, rgb);
     (*env)->ReleaseIntArrayElements(env,j_bayer_src,bayer,0);
    return ret;
}

JNIEXPORT jint JNICALL Java_com_hypernano_netcap_Netcap_native_1get_1member_1contain_1bytes_1length
                      (JNIEnv *env, jobject obj, jint item)
{
    jint len = 0;
    switch( item )
    {
        case CAMERA_INFO_STRUCT_CONTAIN_BYTES_LEN:
             len = sizeof(struct camera_info);
        break;

        default :

        break;
    }
    #if 1
     LOGI("[%s]item = %d,len=%d;\n",__func__,item,len);
    #endif
    return len;
}

JNIEXPORT jint JNICALL Java_com_hypernano_netcap_Netcap_native_1get_1camera_1info
  (JNIEnv *env, jobject obj,jbyteArray des_data,jbyteArray src_data,jshortArray width,jshortArray height,
          jbyteArray bits_per_channel,jbyteArray channel,jshortArray cache_count,jshortArray version,jshortArray max_value,
          jbyteArray j_sensorpartnum ,jbyteArray j_campartnum,jshortArray j_transpose)
{
     struct camera_info m_camera_info;
     uint8_t *src_data_buf = (*env)->GetByteArrayElements(env,src_data,NULL);
     memcpy(&m_camera_info,src_data_buf, sizeof(m_camera_info));

    (*env)->SetShortArrayRegion(env, width,  0, 1, &m_camera_info.width);
    (*env)->SetShortArrayRegion(env, height, 0, 1, &m_camera_info.height);
    (*env)->SetShortArrayRegion(env, version, 0, 1, &m_camera_info.version);
    (*env)->SetByteArrayRegion(env, bits_per_channel, 0, 1, &m_camera_info.bits_per_channel);
    (*env)->SetShortArrayRegion(env, cache_count, 0, 1, &m_camera_info.cache_count);
    (*env)->SetByteArrayRegion(env, channel, 0, 1, &m_camera_info.channel);
    (*env)->SetShortArrayRegion(env, max_value, 0, 1, &m_camera_info.config.FPIMaxPreviewVoltage);
    (*env)->SetShortArrayRegion(env, max_value, 1, 1, &m_camera_info.config.FPIMaxVoltage);
    (*env)->SetShortArrayRegion(env, max_value, 2, 1, &m_camera_info.config.MaxExposure);
    (*env)->SetShortArrayRegion(env, max_value, 3, 1, &m_camera_info.config.FPIMaxPrehold);
    (*env)->SetByteArrayRegion(env, j_sensorpartnum, 0, 16, m_camera_info.config.SensorPartNum);
    (*env)->SetByteArrayRegion(env, j_campartnum, 0, 16, m_camera_info.config.CamPartNum);
    (*env)->SetShortArrayRegion(env,j_transpose, 0, 1, &m_camera_info.config.Transpose);

    #if 0
     LOGI("[%s]sizeof(m_camera_info)=%d;width=%d;height=%d;version=%d\n",
    	                          __func__, sizeof(m_camera_info),m_camera_info.width,m_camera_info.height,m_camera_info.version);
     LOGI("[%s]m_camera_info.SensorPartNum=%s\n",
    	                          __func__, m_camera_info.config.SensorPartNum);
	 LOGI("[%s]FPIMaxPreviewVoltage=%d;FPIMaxVoltage=%d;MaxExposure=%d;FPIMaxPrehold=%d\n",
	                          __func__, m_camera_info.config.FPIMaxPreviewVoltage,m_camera_info.config.FPIMaxVoltage,
	                          m_camera_info.config.MaxExposure,m_camera_info.config.FPIMaxPrehold);
    #endif
     (*env)->ReleaseByteArrayElements(env,src_data,src_data_buf,0);
     return 0;
}

JNIEXPORT jint JNICALL Java_com_hypernano_netcap_Netcap_native_1get_1image_1content_1header_1data
  (JNIEnv *env, jobject obj,jbyteArray byte_data,jshortArray width,jshortArray height,jintArray size,jintArray serial,jshortArray subsample,jbyteArray type)
{
    struct image_content_header  m_image_content_header;
    unsigned char * pBuffer = (*env)->GetByteArrayElements(env,byte_data,NULL);
    uint16_t m_subsample ;
    uint32_t m_serial ;
	memcpy(&m_image_content_header,pBuffer, sizeof(m_image_content_header));
#if 0
    LOGI("[%s] strlenp Buffer=%d ",__func__,strlen(pBuffer));
	LOGI("[%s]sizeof(m_image_content_header)=%d,type=%d,width=%d,height=%d,size=%d,m_image_content_header.meta.serial=%d,m_image_content_header.subsample=%d,m_image_content_header.compress=%d \n",
	                          __func__, sizeof(m_image_content_header),m_image_content_header.type,
	                          m_image_content_header.meta.width,m_image_content_header.meta.height,
	                          m_image_content_header.size,m_image_content_header.serial,m_image_content_header.meta.subsample,
	                          m_image_content_header.compress);
#endif
    m_subsample = m_image_content_header.meta.subsample;
    m_serial = m_image_content_header.serial;
    (*env)->SetShortArrayRegion(env, width,  0, 1, &m_image_content_header.meta.width);
    (*env)->SetShortArrayRegion(env, height, 0, 1, &(m_image_content_header.meta.height));
    (*env)->SetIntArrayRegion(env, serial, 0, 1, &m_serial);
    (*env)->SetShortArrayRegion(env, subsample, 0, 1, &m_subsample);
    (*env)->SetIntArrayRegion(env, size, 0, 1, &(m_image_content_header.size));
    (*env)->SetByteArrayRegion(env, type, 0, 1, &(m_image_content_header.type));
    (*env)->ReleaseByteArrayElements(env,byte_data,pBuffer,0);
    /*
    jbyte* array= (*env)->GetByteArrayElements(env,jarray,&isCopy);
    (*env)->ReleaseByteArrayElements(env,jarray,array,0);
    */
	return 0;
}
#ifdef __cplusplus
}
#endif

3.5 giada.h

/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class _Included_android_netcap_api */

#ifndef _Included_android_netcap_api
#define _Included_android_netcap_api
#ifdef __cplusplus
extern "C" {
#endif
const  int RGGB=0;
const  int BGGR=1;
const  int GRBG=2;
const  int GBRG=3;

JNIEXPORT jint JNICALL Java_com_hypernano_netcap_Netcap_native_1get_1rename_1content_1data
  (JNIEnv *, jobject ,jbyteArray ,jbyteArray );

JNIEXPORT jint JNICALL Java_com_hypernano_netcap_Netcap_native_1get_1camera_1desc
  (JNIEnv *, jobject ,jbyteArray ,jbyteArray ,jbyteArray );

JNIEXPORT jint JNICALL Java_com_hypernano_netcap_Netcap_native_1get_1voltage_1step_1data
  (JNIEnv *, jobject ,jbyteArray ,jint step_mv,jint );

JNIEXPORT jint JNICALL Java_com_hypernano_netcap_Netcap_native_1getcapturetimeandthermal_1data
  (JNIEnv *, jobject ,jbyteArray ,jintArray ,jintArray ,jintArray );

JNIEXPORT jint JNICALL Java_com_hypernano_netcap_Netcap_native_1getcommand_1data
	(JNIEnv *, jobject,jbyteArray, jint ,jint,jint, jint, jint, jint, jint, jint,jint,jshort);

JNIEXPORT jint JNICALL Java_com_hypernano_netcap_Netcap_native_1enumheader_1data
  (JNIEnv *env, jobject ,jbyteArray ,jint ,jint ,jint ack,jint ,jint );

JNIEXPORT jint JNICALL Java_com_hypernano_netcap_Netcap_native_1get_1image_1content_1header_1data
    (JNIEnv *, jobject,jbyteArray,jshortArray,jshortArray,jintArray ,jshortArray,jshortArray,jbyteArray type);

JNIEXPORT jint JNICALL Java_com_hypernano_netcap_Netcap_native_1getcapture_1data
  (JNIEnv *, jobject ,jbyteArray ,jbyteArray ,jint ,jint );

JNIEXPORT jint JNICALL Java_com_hypernano_netcap_Netcap_native_1get_1camera_1info
  (JNIEnv *, jobject ,jbyteArray ,jbyteArray ,jshortArray ,jshortArray ,
                jbyteArray ,jbyteArray ,jshortArray ,jshortArray ,jshortArray ,jbyteArray,jbyteArray,jshortArray);
JNIEXPORT jint JNICALL Java_com_hypernano_netcap_Netcap_native_1get_1member_1contain_1bytes_1length
  (JNIEnv *, jobject , jint );
JNIEXPORT jint JNICALL Java_com_hypernano_netcap_Netcap_native_1bayer10_1to_1rgb888
  (JNIEnv *, jobject ,jbyteArray,jintArray,jint,jint ,jint);

JNIEXPORT jint JNICALL Java_com_hypernano_netcap_Netcap_native_1get_1session_1header
  (JNIEnv *, jobject ,jbyteArray ,jintArray );
#ifdef __cplusplus
}
#endif
#endif

四、使用ndk-build.cmd编译C源码成so和可执行文件。

五、push到android 真机去运行

六、参考文章:

在Clion开发工具上使用NDK编译可以在安卓上执行的程序_clion ndk-CSDN博客

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:/a/250000.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

SpringIOC之LoadTimeWeavingConfigurer

博主介绍&#xff1a;✌全网粉丝5W&#xff0c;全栈开发工程师&#xff0c;从事多年软件开发&#xff0c;在大厂呆过。持有软件中级、六级等证书。可提供微服务项目搭建与毕业项目实战&#xff0c;博主也曾写过优秀论文&#xff0c;查重率极低&#xff0c;在这方面有丰富的经验…

spring 笔记七 Spring JdbcTemplate

文章目录 Spring JdbcTemplateJdbcTemplate概述JdbcTemplate开发步骤Spring产生JdbcTemplate对象 Spring JdbcTemplate JdbcTemplate概述 它是spring框架中提供的一个对象&#xff0c;是对原始繁琐的JdbcAPI对象的简单封装。spring框架为我们提供了很多的操作模板类。例如&am…

Python基础教程——制作一个宿舍管理系统(完整版,附源码)

今天我们一起学习一个新的小案例——宿舍管理系统。主要涉及列表、字典的初始化、增加、删除、修改和查询操作&#xff0c;以及函数的定义和调用。 一、需求&#xff1a; 有操作指引界面&#xff0c;显示操作号 能添加一个新的入住学生信息&#xff0c;包括学生姓名、宿舍号床…

vue3引入Echarts图表

说明&#xff1a;echarts是父组件&#xff0c;stack是子组件&#xff0c;将stack引入到echarts文件中 查看echarts.vue时可看到stack.vue中的图表 # # # 引入方式 第一步 Echarts官网&#xff1a;快速上手 - 使用手册 - Apache ECharts 第二步 在控制台安装Echarts模块…

25.Java程序设计-基于SSM框架的微信小程序校园求职系统的设计与实现

1. 引言 1.1 背景 介绍校园求职系统的背景&#xff0c;说明为什么设计这个系统以及系统的重要性。 1.2 研究目的 阐述设计基于SSM框架的微信小程序校园求职系统的目标和意义。 2. 需求分析 2.1 行业背景 分析校园求职行业的特点和需求&#xff0c;以及目前市场上同类系统…

基于Java的教学信息反馈系统设计与实现(源码+调试)

项目描述 临近学期结束&#xff0c;还是毕业设计&#xff0c;你还在做java程序网络编程&#xff0c;期末作业&#xff0c;老师的作业要求觉得大了吗?不知道毕业设计该怎么办?网页功能的数量是否太多?没有合适的类型或系统?等等。今天给大家介绍一篇基于Java的教学信息反馈…

高频Postman接口测试面试题

一、Postman在工作中使用流程是什么样的&#xff1f; 新建集合管理根据接口所属的模块&#xff0c;在集合中不同模块下编写接口测试用例处理接口之间的数据关联操作添加环境变量在tests tab下中增加断言调试接口&#xff0c;确保接口能被正常调用批量运行用例或者导出通过Newm…

Dubbo 快速入门使用教程

文章目录 Dubbo 介绍Dubbo 入门使用一、Zookeeper 注册中心安装启动二、服务提供方三、服务消费方 Dubbo 介绍 dubbo 2.x版本官方文档 参考 Apache Dubbo 是一款 RPC&#xff08;Remote Procedure Call 远程过程调用&#xff09;服务开发框架&#xff0c;提供了远程调用方案和…

RabbitMQ死信队列详解

什么是死信队列 由于特定的**原因导致 Queue 中的某些消息无法被消费&#xff0c;**这类消费异常的数据将会保存在死信队列中防止消息丢失&#xff0c;例如用户在商城下单成功并点击支付后&#xff0c;在指定时间未支付时的订单自动失效死信队列只不过是绑定在死信交换机上的队…

为什么谷歌每年向苹果支付180亿美元“保护费”

在大众印象里&#xff0c;谷歌和苹果似乎处处“水火不容”。 两大科技巨擘在各类产品和服务上竞争&#xff0c;比如操作系统、浏览器、地图、数字助理、手机&#xff0c;数不胜数。但是在这种敌对关系背后&#xff0c;却有着对他们双方都有利的秘密伙伴关系。 你或许不知道&am…

Qt 数据库QSqlDatabase使用记录

记录一些在QT中使用QSqlDatabase操作数据库时&#xff0c;需要注意的地方 创建数据库 bool CDBOperatorAbstract::_openDBConn(CDatabaseConfig config) {QWriteLocker locker(&m_locker);QSqlDatabase db;if(QSqlDatabase::contains(m_connectionName)){db QSqlDatabas…

CloudFlare 优选ip 和 优选域名的获取方法

1.CloudFlare优选IP网站:【链接直达】 2.CloudFlare 优选IP工具&#xff1a;【开源软件】 3.CloudFlare 优选域名&#xff1a;【GitHub开源工具】 4.CF优选域名推荐&#xff1a; time.cloudflare.com shopify.com time.is icook.hk icook.tw ip.sb japan.com malaysia.com rus…

深入学习《大学计算机》系列之第1章 1.2节——问题描述与抽象

一.欢迎来到我的酒馆 第1章 1.2节&#xff0c;问题描述与抽象。 目录 一.欢迎来到我的酒馆二.问题描述、抽象与建模1.什么是抽象2.为什么要抽象3.什么是建模4.建什么模 三.面向计算机的问题分析四.总结 二.问题描述、抽象与建模 什么是抽象&#xff1f;为什么要抽象&#xff1f…

Chrome限制第三方Cookie:未来无法再追踪你看过哪些敏感的“色色”内容了

当我们在浏览网络的时候&#xff0c;常听到「Cookie」这个词&#xff0c;但许多人可能不太清楚它到底是什么。最近&#xff0c;Google 宣布了一项重要更新&#xff0c;Google Chrome 将减少对第三方cookie 的支持&#xff0c;以提高用户隐私保护。 下面我会解释一下这个改变对…

打印机设置发票收据打印

由于各种打印机型号不一样&#xff0c;设置方式打印效果出入也很大&#xff0c;存在打印不全问题&#xff0c;发票右侧小数点后面的数字打印不出来、位置靠上下左右登问题&#xff0c;比较通用的设置方式如下&#xff1a; 首先找到控制面板&#xff0c;找到设备和打印机 进入到…

Aurora8B10B(二) 从手册和仿真学习Aurora8B10B

一. 简介 在上篇文章中&#xff0c;主要结合IP配置界面介绍了一下Aurora8B10B&#xff0c;这篇文章将结合文档来学习一下Aurora8B10B内部的一些细节 和 相关的时序吧。文档主要是参考的是这个 pg046-aurora-8b10b-en-us-11.1 二. Aurora8B10B内部细节 在手册上&#xff0c;对…

弧形导轨的精度等级

为符合工控自动化生产制造必须&#xff0c;弧形导轨在运输武器装备领域应时而生&#xff0c;并已在电子生产制造、手机上、半导体材料、动力锂电池等领域获得广泛运用。其中&#xff0c;弧形导轨的精度等级是评估其运动精度的重要指标&#xff0c;通常包括制造精度和运行精度两…

低代码核心能力详解:简化应用开发的新思路

低代码平台作为一种快速地应用开发解决方法&#xff0c;为中小企业实现数字化转型提供了机会。但是&#xff0c;对于一些刚开始触碰低代码平台的企业来说&#xff0c;了解其核心能力是很重要的。本文将详细分析低代码平台的核心能力&#xff0c;并在挑选低代码平台以前为中小企…

【星环云课堂大数据实验】InceptorSQL使用方法

文章目录 一、InceptorSQL概述二、实验环境三、实验准备四、实验目的五、实验步骤5.1 使用Waterdrop连接Inceptor5.2、WordCount5.3、外部表与内部表5.4、普通ORC表5.5、创建ORC事务表5.6、创建ORC分区表5.7、创建ORC分区分桶表 一、InceptorSQL概述 InceptorSQL是一个**分布式…

数据结构-迷宫问题

文章目录 1、题目描述2、题目分析3、代码实现 1、题目描述 题目链接&#xff1a;迷宫问题 、 注意不能斜着走&#xff01; 2、题目分析 &#xff08;1&#xff09;0为可以走&#xff0c;1不能走且只有唯一一条通路 &#xff08;2&#xff09;我们可以通过判断上下左右来确定…