一、下载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 真机去运行
六、参考文章: