/ocr/ocrservice/src/com/googlecode/eyesfree/opticflow/ImageBlur.java

http://eyes-free.googlecode.com/ · 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. package com.googlecode.eyesfree.opticflow;
  17. /**
  18. * Wrapper for native image blur detection code. Modified by Alan Viverette from
  19. * Xiaotao Duan's original source.
  20. *
  21. * @author Xiaotao Duan
  22. * @author alanv@google.com (Alan Viverette)
  23. */
  24. public class ImageBlur {
  25. /**
  26. * Tests if a given image is blurred or not.
  27. *
  28. * @param input An array of input pixels in YUV420SP format.
  29. * @param width The width of the input image.
  30. * @param height The height of the input image.
  31. * @return true when input image is blurred.
  32. */
  33. public static native boolean isBlurred(byte[] input, int width, int height);
  34. /**
  35. * Computes signature of a given image.
  36. *
  37. * @param input An array of input pixels in YUV420SP format.
  38. * @param width The width of the input image.
  39. * @param height The height of the input image.
  40. * @param signatureBuffer A buffer for output signature. If it's null or not
  41. * in the right size, this buffer will be ignored and not used.
  42. * This is used to avoid GC.
  43. * @return Signature of input image. If signatureBuffer is valid,
  44. * signatureBuffer will be returned. Otherwise a new array will be
  45. * returned and can be used as signature buffer in next function
  46. * call.
  47. */
  48. public static native int[] computeSignature(
  49. byte[] input, int width, int height, int[] signatureBuffer);
  50. /**
  51. * Computes how similar of two given images represented by their signatures.
  52. *
  53. * @return An integer from 0 to 100 is returned indicating how much
  54. * percentage of signature2 is different from signature1.
  55. */
  56. public static native int diffSignature(int[] signature1, int[] signature2);
  57. static {
  58. System.loadLibrary("imageutils");
  59. }
  60. }