Advertisement
Guest User

Untitled

a guest
Feb 20th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.03 KB | None | 0 0
  1. /*M///////////////////////////////////////////////////////////////////////////////////////
  2. //
  3. //  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
  4. //
  5. //  By downloading, copying, installing or using the software you agree to this license.
  6. //  If you do not agree to this license, do not download, install,
  7. //  copy or use the software.
  8. //
  9. //
  10. //                           License Agreement
  11. //                For Open Source Computer Vision Library
  12. //
  13. // Copyright (C) 2015, University of Ostrava, Institute for Research and Applications of Fuzzy Modeling,
  14. // Pavel Vlasanek, all rights reserved. Third party copyrights are property of their respective owners.
  15. //
  16. // Redistribution and use in source and binary forms, with or without modification,
  17. // are permitted provided that the following conditions are met:
  18. //
  19. //   * Redistribution's of source code must retain the above copyright notice,
  20. //     this list of conditions and the following disclaimer.
  21. //
  22. //   * Redistribution's in binary form must reproduce the above copyright notice,
  23. //     this list of conditions and the following disclaimer in the documentation
  24. //     and/or other materials provided with the distribution.
  25. //
  26. //   * The name of the copyright holders may not be used to endorse or promote products
  27. //     derived from this software without specific prior written permission.
  28. //
  29. // This software is provided by the copyright holders and contributors "as is" and
  30. // any express or implied warranties, including, but not limited to, the implied
  31. // warranties of merchantability and fitness for a particular purpose are disclaimed.
  32. // In no event shall the Intel Corporation or contributors be liable for any direct,
  33. // indirect, incidental, special, exemplary, or consequential damages
  34. // (including, but not limited to, procurement of substitute goods or services;
  35. // loss of use, data, or profits; or business interruption) however caused
  36. // and on any theory of liability, whether in contract, strict liability,
  37. // or tort (including negligence or otherwise) arising in any way out of
  38. // the use of this software, even if advised of the possibility of such damage.
  39. //
  40. //M*/
  41.  
  42. #ifndef __OPENCV_BLOCK_MEAN_HASH_HPP__
  43. #define __OPENCV_BLOCK_MEAN_HASH_HPP__
  44.  
  45. #include "opencv2/core.hpp"
  46.  
  47. namespace cv
  48. {
  49.  
  50. namespace img_hash
  51. {
  52. //! @addtogroup block_mean_hash
  53. //! @{
  54.  
  55. /** @brief Computes block mean hash of the input image
  56.     @param inputArr input image want to compute hash value,
  57.     type should be CV_8UC4, CV_8UC3 or CV_8UC1.
  58.     @param outputArr Hash value of input, it will contain 16 hex
  59.     decimal number, return type is CV_8U
  60.     @param mode By now only support mode 0 and mode 1.
  61.     mode 0 : use fewer block and generate 16*16/8 uchar hash value
  62.     mode 1 : use block blocks(step sizes/2), generate 31*31/8 + 1 uchar hash value
  63.      */
  64. CV_EXPORTS_W void blockMeanHash(cv::InputArray inputArr,
  65.                                 cv::OutputArray outputArr,
  66.                                 size_t mode = 0);
  67.  
  68. class CV_EXPORTS_W BlockMeanHash : public ImgHashBase
  69. {
  70.   //This friend class is design for unit test only, please do not
  71.   //use it under normal case
  72.   friend class BlockMeanHashTester;
  73. public:
  74.    /** @brief Constructor
  75.         @param mode By now only support mode 0 and mode 1.
  76.         mode 0 : use fewer block and generate 16*16/8 uchar hash value
  77.         mode 1 : use block blocks(step sizes/2), generate 31*31/8 + 1 uchar hash value
  78.     */
  79.     CV_WRAP explicit BlockMeanHash(size_t mode = 0);
  80.     CV_WRAP ~BlockMeanHash();
  81.  
  82.     /** @brief Computes Block mean hash of the input image
  83.         @param inputArr input image want to compute hash value,
  84.         type should be CV_8UC4, CV_8UC3 or CV_8UC1.
  85.         @param outputArr hash of the image
  86.       */
  87.     CV_WRAP virtual void compute(cv::InputArray inputArr,
  88.                                  cv::OutputArray outputArr);
  89.  
  90.     /** @brief Compare the hash value between inOne and inTwo
  91.       @param hashOne Hash value one
  92.       @param hashTwo Hash value two
  93.       @return zero means the images are likely very similar;
  94.       5 means a few things maybe different; 10 or more means
  95.       they maybe are very different image
  96.       */
  97.     CV_WRAP virtual double compare(cv::InputArray hashOne,
  98.                                    cv::InputArray hashTwo) const;
  99.  
  100.     /** @brief Create BLockMeanHash object
  101.         @param mode By now only support mode 0 and mode 1.
  102.         mode 0 : use fewer block and generate 16*16/8 uchar hash value
  103.         mode 1 : use block blocks(step sizes/2), generate 31*31/8 + 1 uchar hash value
  104.     */
  105.     CV_WRAP static Ptr<BlockMeanHash> create(size_t mode = 0);
  106.  
  107.     /** Returns the algorithm string identifier.*/
  108.     CV_WRAP virtual String getDefaultName() const;
  109.  
  110.     CV_WRAP void setMode(size_t mode);
  111.  
  112. private:
  113.     void createHash(cv::Mat &hash);
  114.     void findMean(int pixRowStep, int pixColStep);
  115.  
  116.     cv::Mat grayImg_;
  117.     std::vector<double> mean_;
  118.     size_t mode_;
  119.     cv::Mat resizeImg_;
  120. };
  121.  
  122. //! @}
  123. }
  124. }
  125.  
  126. #endif // __OPENCV_PHASH_HPP__
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement