Added c/c++ builder and finished calibration jni calls.
This commit is contained in:
@@ -26,4 +26,67 @@ include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := gdx-freetype
|
||||
LOCAL_SRC_FILES := $(TARGET_ARCH_ABI)/libgdx-freetype.so
|
||||
|
||||
include $(PREBUILT_SHARED_LIBRARY)
|
||||
include $(PREBUILT_SHARED_LIBRARY)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE := ocv_tegra_java
|
||||
LOCAL_SRC_FILES := C:\NVPACK\OpenCV-2.4.5-Tegra-sdk-r2\sdk\native\libs\tegra3\libopencv_java.so
|
||||
|
||||
include $(PREBUILT_SHARED_LIBRARY)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE := ocv_tegra_info
|
||||
LOCAL_SRC_FILES := C:\NVPACK\OpenCV-2.4.5-Tegra-sdk-r2\sdk\native\libs\tegra3\libopencv_info.so
|
||||
|
||||
include $(PREBUILT_SHARED_LIBRARY)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE := ocv_tegra_native_camera_220
|
||||
LOCAL_SRC_FILES := C:\NVPACK\OpenCV-2.4.5-Tegra-sdk-r2\sdk\native\libs\tegra3\libnative_camera_r2.2.0.so
|
||||
|
||||
include $(PREBUILT_SHARED_LIBRARY)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE := ocv_tegra_native_camera_233
|
||||
LOCAL_SRC_FILES := C:\NVPACK\OpenCV-2.4.5-Tegra-sdk-r2\sdk\native\libs\tegra3\libnative_camera_r2.3.3.so
|
||||
|
||||
include $(PREBUILT_SHARED_LIBRARY)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE := ocv_tegra_native_camera_301
|
||||
LOCAL_SRC_FILES := C:\NVPACK\OpenCV-2.4.5-Tegra-sdk-r2\sdk\native\libs\tegra3\libnative_camera_r3.0.1.so
|
||||
|
||||
include $(PREBUILT_SHARED_LIBRARY)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE := ocv_tegra_native_camera_400
|
||||
LOCAL_SRC_FILES := C:\NVPACK\OpenCV-2.4.5-Tegra-sdk-r2\sdk\native\libs\tegra3\libnative_camera_r4.0.0.so
|
||||
|
||||
include $(PREBUILT_SHARED_LIBRARY)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE := ocv_tegra_native_camera_403
|
||||
LOCAL_SRC_FILES := C:\NVPACK\OpenCV-2.4.5-Tegra-sdk-r2\sdk\native\libs\tegra3\libnative_camera_r4.0.3.so
|
||||
|
||||
include $(PREBUILT_SHARED_LIBRARY)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE := ocv_tegra_native_camera_411
|
||||
LOCAL_SRC_FILES := C:\NVPACK\OpenCV-2.4.5-Tegra-sdk-r2\sdk\native\libs\tegra3\libnative_camera_r4.1.1.so
|
||||
|
||||
include $(PREBUILT_SHARED_LIBRARY)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE := ocv_tegra_native_camera_420
|
||||
LOCAL_SRC_FILES := C:\NVPACK\OpenCV-2.4.5-Tegra-sdk-r2\sdk\native\libs\tegra3\libnative_camera_r4.2.0.so
|
||||
|
||||
include $(PREBUILT_SHARED_LIBRARY)
|
||||
|
@@ -16,10 +16,13 @@
|
||||
#include <jni.h>
|
||||
#include <android/log.h>
|
||||
#include <stdio.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "marker.hpp"
|
||||
|
||||
//#define CAN_LOG
|
||||
#define CAN_LOG
|
||||
#define POINTS_PER_CALIBRATION_SAMPLE 54
|
||||
#define CALIBRATION_SAMPLES 10
|
||||
|
||||
#ifdef CAN_LOG
|
||||
#define log(TAG, MSG) (__android_log_write(ANDROID_LOG_DEBUG, TAG, MSG))
|
||||
@@ -27,10 +30,13 @@
|
||||
#define log(TAG, MSG) (1 + 1)
|
||||
#endif
|
||||
|
||||
extern "C"{
|
||||
|
||||
const char * TAG = "CVPROC_NATIVE";
|
||||
|
||||
extern "C"{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_ve_ucv_ciens_ccg_nxtar_MainActivity_getMarkerCodesAndLocations(JNIEnv* env, jobject jobj, jlong addrMatIn, jlong addrMatOut, jintArray codes){
|
||||
char codeMsg[128];
|
||||
std::vector<int> vCodes;
|
||||
@@ -60,6 +66,9 @@ JNIEXPORT void JNICALL Java_ve_ucv_ciens_ccg_nxtar_MainActivity_getMarkerCodesAn
|
||||
env->ReleaseIntArrayElements(codes, _codes, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_ve_ucv_ciens_ccg_nxtar_MainActivity_findCalibrationPattern(JNIEnv* env, jobject jobj, jlong addrMatIn, jlong addrMatOut, jfloatArray points){
|
||||
nxtar::points_vector v_points;
|
||||
bool found;
|
||||
@@ -91,4 +100,47 @@ JNIEXPORT jboolean JNICALL Java_ve_ucv_ciens_ccg_nxtar_MainActivity_findCalibrat
|
||||
return (jboolean)found;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
JNIEXPORT jdouble JNICALL Java_ve_ucv_ciens_ccg_nxtar_MainActivity_calibrateCameraParameters(JNIEnv* env, jobject jobj, jlong addrMatIn, jlong addrMatOut, jlong addrMatFrame, jfloatArray points){
|
||||
double error;
|
||||
std::vector<nxtar::points_vector> imagePoints;
|
||||
|
||||
// Get native object addresses.
|
||||
log(TAG, "calibrateCameraParameters(): Requesting native data.");
|
||||
cv::Mat& mIn = *(cv::Mat*)addrMatIn;
|
||||
cv::Mat& mOut = *(cv::Mat*)addrMatOut;
|
||||
cv::Mat& mFrame = *(cv::Mat*)addrMatFrame;
|
||||
jfloat * _points = env->GetFloatArrayElements(points, 0);
|
||||
|
||||
// Prepare the image points data structure.
|
||||
log(TAG, "calibrateCameraParameters(): Preparing image points.");
|
||||
for(int i = 0; i < CALIBRATION_SAMPLES; i++){
|
||||
nxtar::points_vector tempVector;
|
||||
for(int j = 0, p = 0; j < POINTS_PER_CALIBRATION_SAMPLE; j++, p += 2){
|
||||
tempVector.push_back(cv::Point2f(_points[p], _points[p + 1]));
|
||||
}
|
||||
imagePoints.push_back(tempVector);
|
||||
}
|
||||
|
||||
// Get the camera parameters.
|
||||
log(TAG, "calibrateCameraParameters(): Getting camera parameters.");
|
||||
error = nxtar::getCameraParameters(mIn, mOut, imagePoints, mFrame.size());
|
||||
|
||||
// Clear the image points.
|
||||
log(TAG, "calibrateCameraParameters(): Clearing memory.");
|
||||
for(int i = 0; i < imagePoints.size(); i++){
|
||||
imagePoints[i].clear();
|
||||
}
|
||||
imagePoints.clear();
|
||||
|
||||
// Release native memory.
|
||||
log(TAG, "calibrateCameraParameters(): Releasing native data.");
|
||||
env->ReleaseFloatArrayElements(points, _points, 0);
|
||||
|
||||
// Return the calibration error as calculated by OpenCV.
|
||||
return error;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -16,6 +16,7 @@
|
||||
#include <algorithm>
|
||||
#include <utility>
|
||||
#include <limits>
|
||||
#include <stddef.h>
|
||||
#ifdef DESKTOP
|
||||
#include <iostream>
|
||||
#endif
|
||||
@@ -394,9 +395,9 @@ cv::Mat rotate(cv::Mat in){
|
||||
cv::Mat out;
|
||||
|
||||
in.copyTo(out);
|
||||
for (int i=0;i<in.rows;i++){
|
||||
for (int j=0;j<in.cols;j++){
|
||||
out.at<uchar>(i,j)=in.at<uchar>(in.cols-j-1,i);
|
||||
for (int i = 0; i < in.rows; i++){
|
||||
for (int j = 0; j < in.cols; j++){
|
||||
out.at<uchar>(i, j)=in.at<uchar>(in.cols-j - 1, i);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user