PageRenderTime 23ms CodeModel.GetById 12ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 1ms

/ocr/ocrservice/jni/imageutils/blur-jni.cpp

http://eyes-free.googlecode.com/
C++ | 57 lines | 30 code | 11 blank | 16 comment | 0 complexity | 1b8d67ba11c90e4308a62b5364c11fdb MD5 | raw file
 1/*
 2 * Copyright 2011, Google Inc.
 3 *
 4 * Licensed under the Apache License, Version 2.0 (the "License");
 5 * you may not use this file except in compliance with the License.
 6 * You may obtain a copy of the License at
 7 *
 8 *     http://www.apache.org/licenses/LICENSE-2.0
 9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17// Author: Xiaotao Duan
18
19#include <jni.h>
20#include <stdio.h>
21#include <stdlib.h>
22
23#include "types.h"
24#include "time_log.h"
25#include "blur.h"
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
31JNIEXPORT jboolean JNICALL
32Java_com_googlecode_eyesfree_opticflow_ImageBlur_isBlurred(
33    JNIEnv* env, jclass clazz, jbyteArray input, jint width, jint height);
34
35#ifdef __cplusplus
36}
37#endif
38
39JNIEXPORT jboolean JNICALL
40Java_com_googlecode_eyesfree_opticflow_ImageBlur_isBlurred(
41    JNIEnv* env, jclass clazz, jbyteArray input, jint width, jint height) {
42  jboolean inputCopy = JNI_FALSE;
43  jbyte* const i = env->GetByteArrayElements(input, &inputCopy);
44
45  float blur = 0;
46  float extent = 0;
47
48  resetTimeLog();
49  int blurred = IsBlurred(reinterpret_cast<uint8*>(i),
50                          width, height, &blur, &extent);
51  timeLog("Finished image blur detection");
52  printTimeLog();
53
54  env->ReleaseByteArrayElements(input, i, JNI_ABORT);
55
56  return blurred ? JNI_TRUE : JNI_FALSE;
57}