Started porting the camera calibration functions.
This commit is contained in:
@@ -21,8 +21,6 @@
|
||||
|
||||
//#define CAN_LOG
|
||||
|
||||
extern "C"{
|
||||
|
||||
#ifdef CAN_LOG
|
||||
#define log(TAG, MSG) (__android_log_write(ANDROID_LOG_DEBUG, TAG, MSG))
|
||||
const char * TAG = "CVPROC_NATIVE";
|
||||
@@ -30,57 +28,61 @@ const char * TAG = "CVPROC_NATIVE";
|
||||
#define log(TAG, MSG) (1 + 1)
|
||||
#endif
|
||||
|
||||
JNIEXPORT void JNICALL Java_ve_ucv_ciens_ccg_nxtar_MainActivity_getMarkerCodesAndLocations(
|
||||
JNIEnv* env,
|
||||
jobject jobj,
|
||||
jlong addrMatIn,
|
||||
jlong addrMatOut,
|
||||
jintArray codes
|
||||
){
|
||||
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;
|
||||
|
||||
log(TAG, "Requesting native data.");
|
||||
log(TAG, "getMarkerCodesAndLocations(): Requesting native data.");
|
||||
|
||||
cv::Mat& myuv = *(cv::Mat*)addrMatIn;
|
||||
cv::Mat& mbgr = *(cv::Mat*)addrMatOut;
|
||||
jint * _codes = env->GetIntArrayElements(codes, 0);
|
||||
jint * _codes = env->GetIntArrayElements(codes, 0);
|
||||
|
||||
log(TAG, "Converting color space before processing.");
|
||||
log(TAG, "getMarkerCodesAndLocations(): Converting color space before processing.");
|
||||
cv::cvtColor(myuv, mbgr, CV_RGB2BGR);
|
||||
|
||||
log(TAG, "Finding markers.");
|
||||
log(TAG, "getMarkerCodesAndLocations(): Finding markers.");
|
||||
nxtar::getAllMarkers(vCodes, mbgr);
|
||||
|
||||
log(TAG, "Copying marker codes.");
|
||||
log(TAG, "getMarkerCodesAndLocations(): Copying marker codes.");
|
||||
for(int i = 0; i < vCodes.size() && i < 15; i++){
|
||||
_codes[i] = vCodes[i];
|
||||
sprintf(codeMsg, "Code [%d] = %d", i, vCodes[i]);
|
||||
log(TAG, codeMsg);
|
||||
_codes[i] = (jint)vCodes[i];
|
||||
}
|
||||
vCodes.clear();
|
||||
|
||||
log(TAG, "Releasing native data.");
|
||||
log(TAG, "getMarkerCodesAndLocations(): Releasing native data.");
|
||||
|
||||
env->ReleaseIntArrayElements(codes, _codes, 0);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_ve_ucv_ciens_ccg_nxtar_MainActivity_findCalibrationPattern(
|
||||
JNIEnv* env,
|
||||
jobject jobj,
|
||||
jlong addrMatIn,
|
||||
jlong addrMatOut
|
||||
){
|
||||
log(TAG, "Requesting native data.");
|
||||
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;
|
||||
|
||||
log(TAG, "findCalibrationPattern(): Requesting native data.");
|
||||
|
||||
cv::Mat& myuv = *(cv::Mat*)addrMatIn;
|
||||
cv::Mat& mbgr = *(cv::Mat*)addrMatOut;
|
||||
jfloat * _points = env->GetFloatArrayElements(points, 0);
|
||||
|
||||
log(TAG, "Converting color space before processing.");
|
||||
log(TAG, "findCalibrationPattern(): Converting color space before processing.");
|
||||
cv::cvtColor(myuv, mbgr, CV_RGB2BGR);
|
||||
|
||||
log(TAG, "Finding markers.");
|
||||
nxtar::calibrateCamera(mbgr);
|
||||
log(TAG, "findCalibrationPattern(): Finding calibration pattern.");
|
||||
found = nxtar::findCalibrationPattern(v_points, mbgr);
|
||||
|
||||
log(TAG, "findCalibrationPattern(): Copying calibration points.");
|
||||
for(size_t i = 0, p = 0; i < v_points.size(); i++, p += 2){
|
||||
_points[p] = (jfloat)v_points[i].x;
|
||||
_points[p + 1] = (jfloat)v_points[i].y;
|
||||
}
|
||||
|
||||
log(TAG, "findCalibrationPattern(): Releasing native data.");
|
||||
env->ReleaseFloatArrayElements(points, _points, 0);
|
||||
|
||||
return (jboolean)found;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user