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  0struct image_meta
{char     fourcc[4];// crop infouint16_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 msuint16_t voltage_mv;	// 0~65535 mvuint16_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, & CONTINUOUSuint8_t  compress:1;uint8_t  dummy:7;uint16_t serial;	// continuous shootuint32_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 1for(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 1LOGI("[%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 1LOGI("[%s] sizeof(m_sync_header)=%d ,cmd=%d , ack=%d, len=%d;\n",__func__,sizeof(m_sync_header), cmd , ack, len);#endifreturn 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 0LOGI("[%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 0LOGI("[%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 0LOGI("[%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 0LOGI("[%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);#endifreturn 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 0if(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);
#elseif(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 1LOGI("[%s]item = %d,len=%d;\n",__func__,item,len);#endifreturn 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 0LOGI("[%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 0LOGI("[%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);
#endifm_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.mzph.cn/news/226151.shtml

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

相关文章

k8s如何部署seata(分布式事务)?(第一篇)

k8s如何部署seata(分布式事务)&#xff1f; 官方传送门https://seata.io/zh-cn/ 快速入门SEATA Seata 是一款开源的分布式事务解决方案&#xff0c;致力于提供高性能和简单易用的分布式事务服务。Seata 将为用户提供了 AT、TCC、SAGA 和 XA 事务模式&#xff0c;为用户打造一站…

《Linux C编程实战》笔记:实现自己的ls命令

关键函数的功能及说明 1.void display_attribute(struct stat buf,char *name) 函数功能&#xff1a;打印文件名为name的文件信息&#xff0c;如 含义分别为&#xff1a;文件的类型和访问权限&#xff0c;文件的链接数&#xff0c;文件的所有者&#xff0c;文件所有者所属的组…

后端项目全局异常处理-使用RuntimeException自定义异常异常分类简单举例

接上篇&#xff1a;后端项目操作数据库-中枢组件Service调用Mapper 自定义异常&#xff1a; 手动抛出异常&#xff0c;为了后续统一捕获&#xff0c;需要异常自定义&#xff1b; 如&#xff1a;当使用抛出异常的方式表示“操作失败”时&#xff0c;为了后续统一捕获&#xff0c…

灯具照明行业MES/开源mes/灯具行业免费MES

一、万界星空科技开源MES系统概述&#xff1a; 万界星空科技免费MES、开源MES、商业开源MES、市面上最好的开源MES、MES源代码、适合二开的开源MES。 1.万界星空开源MES制造执行系统的Java开源版本。 开源mes系统包括系统管理&#xff0c;车间基础数据管理&#xff0c;计划管…

Chapter 7 - 3. Congestion Management in Ethernet Storage Networks以太网存储网络的拥塞管理

Pause Threshold for Long Distance Links长途链路的暂停阈值 This section uses the following basic concepts: 本节使用以下基本概念: Bit Time (BT): It is the time taken to transmit one bit. It is the reciprocal of the bit rate. For example, BT of a 10 GbE po…

喝葡萄酒时观酒闻香尝味究竟有什么用?

对许多人来说&#xff0c;在品尝葡萄酒时能发现大多数人闻不到的香气和尝不到的味道似乎是一种神奇的能力。其他人则认为这是学究式葡萄酒爱好者过于活跃的想象&#xff0c;或者是保持葡萄酒鉴赏精英声誉的一种方式&#xff0c;但两者都不是。 部分是艺术&#xff0c;部分是科…

目前最火的大模型训练框架 DeepSpeed 详解来了

目前&#xff0c;大模型的发展已经非常火热&#xff0c;关于大模型的训练、微调也是各个公司重点关注方向&#xff0c;但是大模型训练的痛点是模型参数过大&#xff0c;动辄上百亿&#xff0c;如果单靠单个GPU来完成训练基本不可能。所以需要多卡或者分布式训练来完成这项工作。…

MBA-数学题概念和公式

{}公差大于零的等差数列:多个数字组成的数列&#xff0c;两两之间差相等,且后值减前值大于0&#xff0c;如&#xff1a;{-2,0,2,4}为公差数列为2的等差数列.因数是指整数a除以整数b(b≠0) 的商正好是整数而没有余数&#xff0c;10的因数为 2和5圆柱体表面积 2πr 2πrh球体表名…

生产环境_Apache Spark技术大牛的实践:使用DataFrame API计算唯一值数量并展示技术(属性报告)

业务背景 给前端提供算法集成好的数据&#xff0c;对算法处理后的数据进行进一步删选展示 可以使用下面代码运行一下看看结果&#xff0c;听有趣的&#xff0c;我写的代码中计算了不同字段的值的数量&#xff0c;并生成了一个显示字符串来描述这些数据的分布情况然后使用"…

MySQL数据库 DDL

目录 一、DDL 二、操作数据库 三、操作表 四、数据类型 五、表操作案例 六、修改表 七、删除表 一、DDL Data Definition Language&#xff0c;数据定义语言&#xff0c;用来定义数据库对象(数据库&#xff0c;表&#xff0c;字段) 。 二、操作数据库 &#xff08;1&am…

Git 使用教程(超级详细)

目录 一&#xff1a;Git二&#xff1a;SVN与Git的的区别三、安装Git四&#xff1a;常规操作五&#xff1a;远程仓库六&#xff1a;创建与合并分支七&#xff1a;bug分支八&#xff1a;多人协作九&#xff1a;git可视化工具 Git Git 是一种分布式版本控制系统&#xff0c;用于…

C# WPF上位机开发(加密和解密)

【 声明&#xff1a;版权所有&#xff0c;欢迎转载&#xff0c;请勿用于商业用途。 联系信箱&#xff1a;feixiaoxing 163.com】 在报文传输的过程中&#xff0c;根据报文传输的形态&#xff0c;有两种形式&#xff0c;一种是明文传输&#xff0c;一种是加密传输。当然明文传输…

Python+Requests+Pytest+YAML+Allure实现接口自动化

本项目实现接口自动化的技术选型&#xff1a;PythonRequestsPytestYAMLAllure &#xff0c;主要是针对之前开发的一个接口项目来进行学习&#xff0c;通过 PythonRequests 来发送和处理HTTP协议的请求接口&#xff0c;使用 Pytest 作为测试执行器&#xff0c;使用 YAML 来管理测…

Git使用rebase和merge区别

Git使用rebase和merge区别 模拟环境使用merge合并使用rebase 模拟环境 本地dev分支中DevTest增加addRole() 远程dev被同事提交增加了createResource() 使用merge合并 使用idea中merge解决冲突后, 推送远程dev后,日志图显示 使用rebase idea中使用功能rebase 解决冲突…

遥感图像分割系统:融合空间金字塔池化(FocalModulation)改进YOLOv8

1.研究背景与意义 项目参考AAAI Association for the Advancement of Artificial Intelligence 研究背景与意义 遥感图像分割是遥感技术领域中的一个重要研究方向&#xff0c;它的目标是将遥感图像中的不同地物或地物类别进行有效的分割和识别。随着遥感技术的不断发展和遥感…

Hystrix使用及原理概述

一、背景 1. 当前问题 一个系统&#xff0c;所有请求共用同一个APP容器&#xff08;Tomcat/jetty/等&#xff09;&#xff0c;共用一个用户线程池&#xff0c;依赖多个不同的远程服务。 当系统健康时&#xff0c;处理请求的延时较低&#xff0c;服务正常运行&#xff1b;当某…

大模型下开源文档解析工具总结及技术思考

1 基于文档解析工具的方法 pdf解析工具 导图一览&#xff1a; PyPDF2提取txt&#xff1a; import PyPDF2 def extract_text_from_pdf(pdf_path):with open(pdf_path, rb) as file:pdf_reader PyPDF2.PdfFileReader(file)num_pages pdf_reader.numPagestext ""f…

漏洞复现-网神SecGate3600防火墙敏感信息泄露漏洞(附漏洞检测脚本)

免责声明 文章中涉及的漏洞均已修复&#xff0c;敏感信息均已做打码处理&#xff0c;文章仅做经验分享用途&#xff0c;切勿当真&#xff0c;未授权的攻击属于非法行为&#xff01;文章中敏感信息均已做多层打马处理。传播、利用本文章所提供的信息而造成的任何直接或者间接的…

算法leetcode|92. 反转链表 II(rust重拳出击)

文章目录 92. 反转链表 II&#xff1a;样例 1&#xff1a;样例 2&#xff1a;提示&#xff1a;进阶&#xff1a; 分析&#xff1a;题解&#xff1a;rust&#xff1a;go&#xff1a;c&#xff1a;python&#xff1a;java&#xff1a; 92. 反转链表 II&#xff1a; 给你单链表的…

迈入数据结构殿堂——时间复杂度和空间复杂度

目录 一&#xff0c;算法效率 1.如何衡量一个算法的好坏&#xff1f; 2.算法效率 二&#xff0c;时间复杂度 1.时间复杂度的概念 2.大O的渐进表示法 3.推导大O的渐进表示法 4.常见时间复杂度举例 三&#xff0c;空间复杂度 一&#xff0c;算法效率 数据结构和算法是密…