/ocr/ocrservice/src/com/googlecode/eyesfree/opticflow/ImageBlur.java
Java | 66 lines | 10 code | 6 blank | 50 comment | 0 complexity | 7151b6c3ed9ce74c5de6a613dea5a197 MD5 | raw file
1/* 2 * Copyright (C) 2011 Google Inc. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 * use this file except in compliance with the License. You may obtain a copy of 6 * 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, WITHOUT 12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 * License for the specific language governing permissions and limitations under 14 * the License. 15 */ 16 17package com.googlecode.eyesfree.opticflow; 18 19/** 20 * Wrapper for native image blur detection code. Modified by Alan Viverette from 21 * Xiaotao Duan's original source. 22 * 23 * @author Xiaotao Duan 24 * @author alanv@google.com (Alan Viverette) 25 */ 26public class ImageBlur { 27 28 /** 29 * Tests if a given image is blurred or not. 30 * 31 * @param input An array of input pixels in YUV420SP format. 32 * @param width The width of the input image. 33 * @param height The height of the input image. 34 * @return true when input image is blurred. 35 */ 36 public static native boolean isBlurred(byte[] input, int width, int height); 37 38 /** 39 * Computes signature of a given image. 40 * 41 * @param input An array of input pixels in YUV420SP format. 42 * @param width The width of the input image. 43 * @param height The height of the input image. 44 * @param signatureBuffer A buffer for output signature. If it's null or not 45 * in the right size, this buffer will be ignored and not used. 46 * This is used to avoid GC. 47 * @return Signature of input image. If signatureBuffer is valid, 48 * signatureBuffer will be returned. Otherwise a new array will be 49 * returned and can be used as signature buffer in next function 50 * call. 51 */ 52 public static native int[] computeSignature( 53 byte[] input, int width, int height, int[] signatureBuffer); 54 55 /** 56 * Computes how similar of two given images represented by their signatures. 57 * 58 * @return An integer from 0 to 100 is returned indicating how much 59 * percentage of signature2 is different from signature1. 60 */ 61 public static native int diffSignature(int[] signature1, int[] signature2); 62 63 static { 64 System.loadLibrary("imageutils"); 65 } 66}