Skip to content

Commit

Permalink
format cpp files to match DMZ (2-space indent instead of tabs)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeff Brateman committed Mar 4, 2015
1 parent 8ad0e6f commit 039b6a2
Show file tree
Hide file tree
Showing 3 changed files with 294 additions and 294 deletions.
114 changes: 57 additions & 57 deletions card.io/src/main/jni/glesExperimental.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,88 +14,88 @@
#define DEBUG_TAG "card.io native experimental"

JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
return JNI_VERSION_1_6;
return JNI_VERSION_1_6;
}

extern "C"
JNIEXPORT void JNICALL Java_io_card_development_NativeGLESWarp_nSetup(JNIEnv *env, jobject thiz, jint width, jint height) {
llcv_gles_setup(kCreditCardTargetWidth, kCreditCardTargetHeight);
llcv_gles_setup(kCreditCardTargetWidth, kCreditCardTargetHeight);
}

extern "C"
JNIEXPORT jint JNICALL Java_io_card_development_NativeGLESWarp_nCardWidth(JNIEnv *env, jobject thiz) {
return kCreditCardTargetWidth;
return kCreditCardTargetWidth;
}

extern "C"
JNIEXPORT jint JNICALL Java_io_card_development_NativeGLESWarp_nCardHeight(JNIEnv *env, jobject thiz) {
return kCreditCardTargetHeight;
return kCreditCardTargetHeight;
}

extern "C"
JNIEXPORT jboolean JNICALL Java_io_card_development_NativeGLESWarp_nWarp(JNIEnv *env, jobject thiz,
jbyteArray jbImage, jint width, jint height, jintArray jCorners, jobject dinfo, jstring dInfoClassName)
jbyteArray jbImage, jint width, jint height, jintArray jCorners, jobject dinfo, jstring dInfoClassName)
{
jint *jCornerBytes = env->GetIntArrayElements(jCorners, 0);
jint *jCornerBytes = env->GetIntArrayElements(jCorners, 0);

IplImage *image = cvCreateImageHeader(cvSize(width, height), IPL_DEPTH_8U, 4);
IplImage *image = cvCreateImageHeader(cvSize(width, height), IPL_DEPTH_8U, 4);

jbyte *jBytes = env->GetByteArrayElements(jbImage, 0);
image->imageData = (char *)jBytes;
jbyte *jBytes = env->GetByteArrayElements(jbImage, 0);
image->imageData = (char *)jBytes;

IplImage *card = cvCreateImage( cvSize(kCreditCardTargetWidth, kCreditCardTargetHeight), IPL_DEPTH_8U, 4 );
IplImage *card = cvCreateImage( cvSize(kCreditCardTargetWidth, kCreditCardTargetHeight), IPL_DEPTH_8U, 4 );

CvPoint2D32f corners[4];
for (int i = 0; i < 4; i++) {
corners[i].x = (float)jCornerBytes[2*i + 0];
corners[i].y = (float)jCornerBytes[2*i + 1];
CvPoint2D32f corners[4];
for (int i = 0; i < 4; i++) {
corners[i].x = (float)jCornerBytes[2 * i + 0];
corners[i].y = (float)jCornerBytes[2 * i + 1];
}

llcv_warp_perspective(image, corners, NULL, card);

int size = card->width * card->height * card->nChannels;

dmz_debug_log("need array sized %i x %i x %i (%i)", card->width, card->height, card->nChannels, size);

jclass clazz;
jfieldID fid;

const char *nativeDInfoClassName = env->GetStringUTFChars(dInfoClassName, 0);
clazz = env->FindClass(nativeDInfoClassName);
env->ReleaseStringUTFChars(dInfoClassName, nativeDInfoClassName);

if (clazz) {
fid = env->GetFieldID(clazz, "cardImageWidth", "I");
if (fid) {
env->SetIntField(dinfo, fid, card->width);
}

llcv_warp_perspective(image, corners, NULL, card);

int size = card->width * card->height * card->nChannels;

dmz_debug_log("need array sized %i x %i x %i (%i)", card->width, card->height, card->nChannels, size);

jclass clazz;
jfieldID fid;

const char *nativeDInfoClassName = env->GetStringUTFChars(dInfoClassName, 0);
clazz = env->FindClass(nativeDInfoClassName);
env->ReleaseStringUTFChars(dInfoClassName, nativeDInfoClassName);

if (clazz) {
fid = env->GetFieldID(clazz, "cardImageWidth", "I");
if (fid) {
env->SetIntField(dinfo, fid, card->width);
}

fid = env->GetFieldID(clazz, "cardImageHeight", "I");
if (fid) {
env->SetIntField(dinfo, fid, card->height);
}

fid = env->GetFieldID(clazz, "cardImageRGB", "[B");
if (fid) {
dmz_debug_log("- card->nSize: %d", card->nSize);
dmz_debug_log("- card->width: %d", card->width);
dmz_debug_log("- card->height: %d", card->height);
dmz_debug_log("- card->nChannels: %d", card->nChannels);
dmz_debug_log("- card->depth: %d", card->depth);

jbyteArray jb = env->NewByteArray(size);
env->SetByteArrayRegion(jb, 0, size, (jbyte *)card->imageData);
env->SetObjectField(dinfo, fid, jb);
}

}
cvReleaseImageHeader(&image);
cvReleaseImage(&card);

return (jboolean) true;
fid = env->GetFieldID(clazz, "cardImageHeight", "I");
if (fid) {
env->SetIntField(dinfo, fid, card->height);
}

fid = env->GetFieldID(clazz, "cardImageRGB", "[B");
if (fid) {
dmz_debug_log("- card->nSize: %d", card->nSize);
dmz_debug_log("- card->width: %d", card->width);
dmz_debug_log("- card->height: %d", card->height);
dmz_debug_log("- card->nChannels: %d", card->nChannels);
dmz_debug_log("- card->depth: %d", card->depth);

jbyteArray jb = env->NewByteArray(size);
env->SetByteArrayRegion(jb, 0, size, (jbyte *)card->imageData);
env->SetObjectField(dinfo, fid, jb);
}

}
cvReleaseImageHeader(&image);
cvReleaseImage(&card);

return (jboolean) true;
}

extern "C"
JNIEXPORT void JNICALL Java_io_card_development_NativeGLESWarp_nCleanup(JNIEnv *env, jobject thiz) {
llcv_gles_teardown();
llcv_gles_teardown();
}
6 changes: 3 additions & 3 deletions card.io/src/main/jni/nativeDecider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@

extern "C"
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
return JNI_VERSION_1_6;
return JNI_VERSION_1_6;
}

extern "C" jboolean JNICALL Java_io_card_payment_CardScanner_nUseNeon() {
return (dmz_has_neon_runtime());
return (dmz_has_neon_runtime());
}

extern "C" jboolean JNICALL Java_io_card_payment_CardScanner_nUseTegra() {
return (dmz_use_vfp3_16());
return (dmz_use_vfp3_16());
}
Loading

0 comments on commit 039b6a2

Please sign in to comment.