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

news2024/11/13 9:26:59

一、下载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博客

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

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

SD-WAN是怎样实现SaaS性能优化的?

在数字化时代&#xff0c;SaaS应用已经成为许多企业不可或缺的核心业务工具。为实现高效的SaaS应用和卓越的用户体验&#xff0c;企业可考虑采用SD-WAN技术。通过就近访问、智能带宽管理、多路径冗余、高级安全和简化的管理监控&#xff0c;SD-WAN为企业带来显著价值。 1. 就近…

单域名https证书怎么申请

单域名https证书可以保护www和两个域名记录&#xff0c;如果保护的域名是子域名时&#xff0c;只能保护一个子域名。单域名https证书能够为网站提供加密的HTTPS连接&#xff0c;保护网站的数据安全。今天随SSL盾小编了解单域名https证书的申请。 1. 确定证书类型&#xff1a;根…

python自动下载网页中的文件,python 自动下载脚本

本篇文章给大家谈谈python自动下载文件 下载的不完整&#xff0c;以及python登录网站自动下载文件&#xff0c;希望对各位有所帮助&#xff0c;不要忘了收藏本站喔。 问题描述 Python自动下载文件&#xff0c;通用文件&#xff0c;包括但不限于压缩文件、图片等。 解决方法 一般…

隐语开源|周爱辉:隐语 TEE 技术解读与跨域管控实践

“隐语”是开源的可信隐私计算框架&#xff0c;内置 MPC、TEE、同态等多种密态计算虚拟设备供灵活选择&#xff0c;提供丰富的联邦学习算法和差分隐私机制 开源项目 github.com/secretflow gitee.com/secretflow 11月25日&#xff0c;「隐语开源社区 Meetup西安站」顺利举办&…

【动态规划】03斐波那契数列模型_最小花费爬楼梯_C++(easy1)

题目链接&#xff1a;leetcode使用最小花费爬楼梯 目录 题目解析&#xff1a; 算法原理 1.状态表示 2.状态转移方程 3.初始化 4.填表顺序 5.返回值 编写代码 题目解析&#xff1a; 题目让我们求达到楼梯顶部的最低花费. 由题可得&#xff1a; cost[i] 是从楼梯第 i 个…

【EMQX】通过EMQX webhook实现转发消息到Python web服务器

EMQX webhook消息转发Web服务器 一、前言二、实现1、EMQX服务器搭建EMQX下载、安装、启动 2、本地Web服务搭建创建Flask项目代码 3、EMQX中创建webhook数据桥接4、EMQX中创建数据转发规则 三、效果 一、前言 需求&#xff1a;获取设备通过mqtt协议发送过来的数据并将数据保存到…

【sqli靶场】第四关和第五关通关思路

目录 前言 一、sqli靶场第四关 1.1 判断注入类型 1.2 观察报错 1.3 判断数据表中的列数 1.4 使用union联合查询 1.5 使用group_concat()函数 二、sqli靶场第五关 2.1 判断注入类型 2.2 使用extractvalue函数报错 2.3 爆出数据库中的表名 2.4 爆出users表中的列名 2.5 爆出use…

异地现场工控设备,如何实现远程配置、调试?

南京某企业专注于工业物联领域&#xff0c;在相关项目中往往会在各个点位部署基于Linux系统的中控主机&#xff0c;实现各类物联设备信息的采集、汇总。但是&#xff0c;由于各点位分散多地&#xff0c;且数量达到了上百个&#xff0c;虽然中控主机具备4G物联网接入能力&#x…

Java设计模式-单例(Singleton)设计模式的概述及实现

目录 &#x1f436;1 设计模式概述 &#x1f436;2 何为单例模式 &#x1f436;3 实现思路 &#x1f436;4 饿汉式实现代码 &#x1f436;5 懒汉式实现代码 &#x1f436;6 对比两种模式&#xff08;特点、优缺点&#xff09; &#x1f436;7 单例模式的优点及应用场景 &…

系统提示:comres.dll丢失怎么办,comres.dll丢失的解决方法

comres.dll是Windows操作系统中一个非常重要的动态链接库文件&#xff0c;它负责提供一些重要的功能和资源。当这个文件丢失或损坏时&#xff0c;可能会导致一系列的问题和影响。本文将介绍comres.dll文件丢失对电脑的影响以及comres.dll丢失的原因&#xff0c;并提供5个解决方…

数据科学工作的20个Pandas函数(备忘)

Pandas 是数据科学社区中使用最广泛的库之一&#xff0c;它是一个强大的工具&#xff0c;可以进行数据操作、清理和分析。 本文将提供最常用的 Pandas 函数以及如何实际使用它们的样例。我们将涵盖从基本数据操作到高级数据分析技术的所有内容&#xff0c;到本文结束时&#xf…

Fnac、Darty跨境利用利用自养号测评补单提升销量和排名

Fnac是法国最有名字的零售商之一&#xff0c;成立于1954年&#xff0c;也是欧洲增长最快的平台之一&#xff0c;2016年&#xff0c;Fnac并购Darty&#xff0c;同时在自己的网站上添加了Darty板块&#xff0c;FnacDarty集团正式成立 国内的产品在Fnac&#xff0c;Darty平台上还…

使用shell脚本将一台虚拟机上面数据分发到其他虚拟机上面xsync

目录 1&#xff0c;功能2&#xff0c;注意点3&#xff0c;shell脚本介绍4&#xff0c;bash内容 1&#xff0c;功能 使用shell脚本将一台虚拟机上面数据分发到其他虚拟机上面。 2&#xff0c;注意点 需要修改的地方&#xff1a;hadoop250 hadoop251 hadoop252 hadoop253 hado…

【Redis】深入理解 Redis 常用数据类型源码及底层实现(1.结构与源码概述)

在文章【Redis】不卡壳的 Redis 学习之路&#xff1a;从十大数据类型开始入手中我们介绍了Redis常用的10大数据类型&#xff0c;这10大数据类型可并不是直接在底层通过代码实现的&#xff0c;而是通过不同的底层数据结构组合起来的&#xff0c;这篇我们介绍下Redis常用数据类型…

多域名和通配符SSL证书的区别

域名SSL证书和通配符SSL证书都是SSL数字证书中用一张证书保护多个域名站点的证书产品&#xff0c;这两种类型的SSL数字证书各自有各自的特色&#xff0c;今天就随SSL盾小编了解多域名SSL证书和通配符SSL证书的区别。 1.保护的域名类型不同&#xff1a;多域名SSL证书默认保护3-…

从视频中提取图片,轻松制作专属视频封面

你是否曾经为如何制作一个吸引人的视频封面而烦恼&#xff1f;现在&#xff0c;我们将向你展示如何从视频中提取图片&#xff0c;并轻松制作专属的视频封面。无论你是视频编辑新手&#xff0c;还是经验丰富的专业人士&#xff0c;这个技巧都能够帮助你快速提升你的视频品质。 …

外包干了3年,技术退步太明显了。。。。。

先说一下自己的情况&#xff0c;本科生生&#xff0c;18年通过校招进入武汉某软件公司&#xff0c;干了差不多3年的功能测试&#xff0c;今年国庆&#xff0c;感觉自己不能够在这样下去了&#xff0c;长时间呆在一个舒适的环境会让一个人堕落!而我已经在一个企业干了四年的功能…

4fiddler抓包工具的使用

一、定义 1.1 抓包的定义 说明&#xff1a;客户端向服务器发送请求以及服务器响应客户端的请求&#xff0c;都是以数据包来传递的。 抓包(packet capture)&#xff1a;通过工具拦截客户端与服务器交互的数据包 1.2 fiddler的介绍 Fiddler是一个http协议调试代理工具&#…

黄油市场调研:预计2028年将达到717亿美元

黄油富含矿物质和维生素&#xff0c;奶油主要为脂肪和蛋白质组成&#xff0c;黄油主要用于涂抹面包和煎牛排等&#xff0c;随着西餐认可度提升&#xff0c;国内需求持续上行。黄油营养成分为乳制品之首&#xff0c;脂肪含量更高。 黄油主要用于涂抹面包和煎牛排等&#xff0c;随…

二叉树的所有路径

257. 二叉树的所有路径 - 力扣&#xff08;LeetCode&#xff09; 题目描述 给你一个二叉树的根节点 root &#xff0c;按 任意顺序 &#xff0c;返回所有从根节点到叶子节点的路径。 叶子节点 是指没有子节点的节点。 样例输入 示例 1&#xff1a; 输入&#xff1a;root […