imagecore 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. data/.gitignore +24 -0
  2. data/Gemfile +4 -0
  3. data/Rakefile +2 -0
  4. data/ext/imagecore/analyze_image.cxx +58 -0
  5. data/ext/imagecore/analyze_image.h +6 -0
  6. data/ext/imagecore/extconf.rb +9 -0
  7. data/ext/imagecore/imagecore.cxx +34 -0
  8. data/ext/opencv/core/___.c +3 -0
  9. data/ext/opencv/core/alloc.cpp +697 -0
  10. data/ext/opencv/core/array.cpp +3206 -0
  11. data/ext/opencv/core/datastructs.cpp +4064 -0
  12. data/ext/opencv/core/extconf.rb +22 -0
  13. data/ext/opencv/core/matrix.cpp +3777 -0
  14. data/ext/opencv/core/precomp.hpp +216 -0
  15. data/ext/opencv/core/system.cpp +832 -0
  16. data/ext/opencv/core/tables.cpp +3512 -0
  17. data/ext/opencv/highgui/___.c +3 -0
  18. data/ext/opencv/highgui/bitstrm.cpp +582 -0
  19. data/ext/opencv/highgui/bitstrm.hpp +182 -0
  20. data/ext/opencv/highgui/extconf.rb +28 -0
  21. data/ext/opencv/highgui/grfmt_base.cpp +128 -0
  22. data/ext/opencv/highgui/grfmt_base.hpp +113 -0
  23. data/ext/opencv/highgui/grfmt_bmp.cpp +564 -0
  24. data/ext/opencv/highgui/grfmt_bmp.hpp +99 -0
  25. data/ext/opencv/highgui/grfmt_exr.hpp +113 -0
  26. data/ext/opencv/highgui/grfmt_imageio.hpp +56 -0
  27. data/ext/opencv/highgui/grfmt_jpeg.cpp +622 -0
  28. data/ext/opencv/highgui/grfmt_jpeg.hpp +90 -0
  29. data/ext/opencv/highgui/grfmt_jpeg2000.cpp +529 -0
  30. data/ext/opencv/highgui/grfmt_jpeg2000.hpp +95 -0
  31. data/ext/opencv/highgui/grfmt_png.cpp +406 -0
  32. data/ext/opencv/highgui/grfmt_png.hpp +101 -0
  33. data/ext/opencv/highgui/grfmt_pxm.cpp +513 -0
  34. data/ext/opencv/highgui/grfmt_pxm.hpp +92 -0
  35. data/ext/opencv/highgui/grfmt_sunras.cpp +425 -0
  36. data/ext/opencv/highgui/grfmt_sunras.hpp +105 -0
  37. data/ext/opencv/highgui/grfmt_tiff.cpp +718 -0
  38. data/ext/opencv/highgui/grfmt_tiff.hpp +136 -0
  39. data/ext/opencv/highgui/grfmts.hpp +56 -0
  40. data/ext/opencv/highgui/loadsave.cpp +535 -0
  41. data/ext/opencv/highgui/precomp.hpp +223 -0
  42. data/ext/opencv/highgui/utils.cpp +689 -0
  43. data/ext/opencv/highgui/utils.hpp +128 -0
  44. data/ext/opencv/imgproc/___.c +3 -0
  45. data/ext/opencv/imgproc/_geom.h +72 -0
  46. data/ext/opencv/imgproc/color.cpp +3179 -0
  47. data/ext/opencv/imgproc/contours.cpp +1780 -0
  48. data/ext/opencv/imgproc/extconf.rb +11 -0
  49. data/ext/opencv/imgproc/filter.cpp +3063 -0
  50. data/ext/opencv/imgproc/precomp.hpp +159 -0
  51. data/ext/opencv/imgproc/shapedescr.cpp +1306 -0
  52. data/ext/opencv/imgproc/smooth.cpp +1566 -0
  53. data/ext/opencv/imgproc/tables.cpp +214 -0
  54. data/ext/opencv/imgproc/thresh.cpp +636 -0
  55. data/ext/opencv/imgproc/utils.cpp +242 -0
  56. data/ext/opencv/include/opencv2/core/core.hpp +4344 -0
  57. data/ext/opencv/include/opencv2/core/core_c.h +1885 -0
  58. data/ext/opencv/include/opencv2/core/internal.hpp +710 -0
  59. data/ext/opencv/include/opencv2/core/mat.hpp +2557 -0
  60. data/ext/opencv/include/opencv2/core/operations.hpp +3623 -0
  61. data/ext/opencv/include/opencv2/core/types_c.h +1875 -0
  62. data/ext/opencv/include/opencv2/core/version.hpp +58 -0
  63. data/ext/opencv/include/opencv2/highgui/highgui.hpp +198 -0
  64. data/ext/opencv/include/opencv2/highgui/highgui_c.h +506 -0
  65. data/ext/opencv/include/opencv2/imgproc/imgproc.hpp +1139 -0
  66. data/ext/opencv/include/opencv2/imgproc/imgproc_c.h +783 -0
  67. data/ext/opencv/include/opencv2/imgproc/types_c.h +538 -0
  68. data/imagecore.gemspec +20 -0
  69. data/lib/imagecore.rb +16 -0
  70. data/lib/imagecore/version.rb +3 -0
  71. metadata +119 -0
@@ -0,0 +1,182 @@
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) 2000-2008, Intel Corporation, all rights reserved.
14
+ // Copyright (C) 2009, Willow Garage Inc., all rights reserved.
15
+ // Third party copyrights are property of their respective owners.
16
+ //
17
+ // Redistribution and use in source and binary forms, with or without modification,
18
+ // are permitted provided that the following conditions are met:
19
+ //
20
+ // * Redistribution's of source code must retain the above copyright notice,
21
+ // this list of conditions and the following disclaimer.
22
+ //
23
+ // * Redistribution's in binary form must reproduce the above copyright notice,
24
+ // this list of conditions and the following disclaimer in the documentation
25
+ // and/or other materials provided with the distribution.
26
+ //
27
+ // * The name of the copyright holders may not be used to endorse or promote products
28
+ // derived from this software without specific prior written permission.
29
+ //
30
+ // This software is provided by the copyright holders and contributors "as is" and
31
+ // any express or implied warranties, including, but not limited to, the implied
32
+ // warranties of merchantability and fitness for a particular purpose are disclaimed.
33
+ // In no event shall the Intel Corporation or contributors be liable for any direct,
34
+ // indirect, incidental, special, exemplary, or consequential damages
35
+ // (including, but not limited to, procurement of substitute goods or services;
36
+ // loss of use, data, or profits; or business interruption) however caused
37
+ // and on any theory of liability, whether in contract, strict liability,
38
+ // or tort (including negligence or otherwise) arising in any way out of
39
+ // the use of this software, even if advised of the possibility of such damage.
40
+ //
41
+ //M*/
42
+
43
+ #ifndef _BITSTRM_H_
44
+ #define _BITSTRM_H_
45
+
46
+ #include <stdio.h>
47
+
48
+ namespace cv
49
+ {
50
+
51
+ enum
52
+ {
53
+ RBS_THROW_EOS=-123, // <end of stream> exception code
54
+ RBS_THROW_FORB=-124, // <forrbidden huffman code> exception code
55
+ RBS_HUFF_FORB=2047, // forrbidden huffman code "value"
56
+ RBS_BAD_HEADER=-125, // invalid header
57
+ };
58
+
59
+ typedef unsigned long ulong;
60
+
61
+ // class RBaseStream - base class for other reading streams.
62
+ class RBaseStream
63
+ {
64
+ public:
65
+ //methods
66
+ RBaseStream();
67
+ virtual ~RBaseStream();
68
+
69
+ virtual bool open( const string& filename );
70
+ virtual bool open( const Mat& buf );
71
+ virtual void close();
72
+ bool isOpened();
73
+ void setPos( int pos );
74
+ int getPos();
75
+ void skip( int bytes );
76
+
77
+ protected:
78
+
79
+ bool m_allocated;
80
+ uchar* m_start;
81
+ uchar* m_end;
82
+ uchar* m_current;
83
+ FILE* m_file;
84
+ int m_block_size;
85
+ int m_block_pos;
86
+ bool m_is_opened;
87
+
88
+ virtual void readBlock();
89
+ virtual void release();
90
+ virtual void allocate();
91
+ };
92
+
93
+
94
+ // class RLByteStream - uchar-oriented stream.
95
+ // l in prefix means that the least significant uchar of a multi-uchar value goes first
96
+ class RLByteStream : public RBaseStream
97
+ {
98
+ public:
99
+ virtual ~RLByteStream();
100
+
101
+ int getByte();
102
+ int getBytes( void* buffer, int count );
103
+ int getWord();
104
+ int getDWord();
105
+ };
106
+
107
+ // class RMBitStream - uchar-oriented stream.
108
+ // m in prefix means that the most significant uchar of a multi-uchar value go first
109
+ class RMByteStream : public RLByteStream
110
+ {
111
+ public:
112
+ virtual ~RMByteStream();
113
+
114
+ int getWord();
115
+ int getDWord();
116
+ };
117
+
118
+ // WBaseStream - base class for output streams
119
+ class WBaseStream
120
+ {
121
+ public:
122
+ //methods
123
+ WBaseStream();
124
+ virtual ~WBaseStream();
125
+
126
+ virtual bool open( const string& filename );
127
+ virtual bool open( vector<uchar>& buf );
128
+ virtual void close();
129
+ bool isOpened();
130
+ int getPos();
131
+
132
+ protected:
133
+
134
+ uchar* m_start;
135
+ uchar* m_end;
136
+ uchar* m_current;
137
+ int m_block_size;
138
+ int m_block_pos;
139
+ FILE* m_file;
140
+ bool m_is_opened;
141
+ vector<uchar>* m_buf;
142
+
143
+ virtual void writeBlock();
144
+ virtual void release();
145
+ virtual void allocate();
146
+ };
147
+
148
+
149
+ // class WLByteStream - uchar-oriented stream.
150
+ // l in prefix means that the least significant uchar of a multi-byte value goes first
151
+ class WLByteStream : public WBaseStream
152
+ {
153
+ public:
154
+ virtual ~WLByteStream();
155
+
156
+ void putByte( int val );
157
+ void putBytes( const void* buffer, int count );
158
+ void putWord( int val );
159
+ void putDWord( int val );
160
+ };
161
+
162
+
163
+ // class WLByteStream - uchar-oriented stream.
164
+ // m in prefix means that the least significant uchar of a multi-byte value goes last
165
+ class WMByteStream : public WLByteStream
166
+ {
167
+ public:
168
+ virtual ~WMByteStream();
169
+ void putWord( int val );
170
+ void putDWord( int val );
171
+ };
172
+
173
+ inline unsigned BSWAP(unsigned v)
174
+ {
175
+ return (v<<24)|((v&0xff00)<<8)|((v>>8)&0xff00)|((unsigned)v>>24);
176
+ }
177
+
178
+ bool bsIsBigEndian( void );
179
+
180
+ }
181
+
182
+ #endif/*_BITSTRM_H_*/
@@ -0,0 +1,28 @@
1
+ require 'mkmf'
2
+
3
+ # not valid for C++ code
4
+ $warnflags = ($warnflags.split - %w(-Wdeclaration-after-statement -Wimplicit-function-declaration)) * ' '
5
+
6
+ # OpenCV includes
7
+ $INCFLAGS << ' -I ../include'
8
+
9
+ # Find stuff
10
+ if have_library('jpeg')
11
+ $defs.push '-DHAVE_JPEG'
12
+ end
13
+
14
+ if have_library('tiff')
15
+ $defs.push '-DHAVE_TIFF'
16
+ end
17
+
18
+ if have_library('png')
19
+ $defs.push '-DHAVE_PNG'
20
+ end
21
+
22
+ if have_library('jasper')
23
+ $defs.push '-DHAVE_JASPER'
24
+ end
25
+
26
+ create_header('cvconfig.h')
27
+
28
+ create_makefile("opencv_highgui")
@@ -0,0 +1,128 @@
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
+ // Intel License Agreement
11
+ // For Open Source Computer Vision Library
12
+ //
13
+ // Copyright (C) 2000, Intel Corporation, all rights reserved.
14
+ // 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 Intel Corporation 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
+ #include "precomp.hpp"
43
+
44
+ #include "grfmt_base.hpp"
45
+ #include "bitstrm.hpp"
46
+
47
+ namespace cv
48
+ {
49
+
50
+ BaseImageDecoder::BaseImageDecoder()
51
+ {
52
+ m_width = m_height = 0;
53
+ m_type = -1;
54
+ m_buf_supported = false;
55
+ }
56
+
57
+ bool BaseImageDecoder::setSource( const string& filename )
58
+ {
59
+ m_filename = filename;
60
+ m_buf.release();
61
+ return true;
62
+ }
63
+
64
+ bool BaseImageDecoder::setSource( const Mat& buf )
65
+ {
66
+ if( !m_buf_supported )
67
+ return false;
68
+ m_filename = string();
69
+ m_buf = buf;
70
+ return true;
71
+ }
72
+
73
+ size_t BaseImageDecoder::signatureLength() const
74
+ {
75
+ return m_signature.size();
76
+ }
77
+
78
+ bool BaseImageDecoder::checkSignature( const string& signature ) const
79
+ {
80
+ size_t len = signatureLength();
81
+ return signature.size() >= len && memcmp( signature.c_str(), m_signature.c_str(), len ) == 0;
82
+ }
83
+
84
+ ImageDecoder BaseImageDecoder::newDecoder() const
85
+ {
86
+ return ImageDecoder();
87
+ }
88
+
89
+ BaseImageEncoder::BaseImageEncoder()
90
+ {
91
+ m_buf_supported = false;
92
+ }
93
+
94
+ bool BaseImageEncoder::isFormatSupported( int depth ) const
95
+ {
96
+ return depth == CV_8U;
97
+ }
98
+
99
+ string BaseImageEncoder::getDescription() const
100
+ {
101
+ return m_description;
102
+ }
103
+
104
+ bool BaseImageEncoder::setDestination( const string& filename )
105
+ {
106
+ m_filename = filename;
107
+ m_buf = 0;
108
+ return true;
109
+ }
110
+
111
+ bool BaseImageEncoder::setDestination( vector<uchar>& buf )
112
+ {
113
+ if( !m_buf_supported )
114
+ return false;
115
+ m_buf = &buf;
116
+ m_buf->clear();
117
+ m_filename = string();
118
+ return true;
119
+ }
120
+
121
+ ImageEncoder BaseImageEncoder::newEncoder() const
122
+ {
123
+ return ImageEncoder();
124
+ }
125
+
126
+ }
127
+
128
+ /* End of file. */
@@ -0,0 +1,113 @@
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) 2000-2008, Intel Corporation, all rights reserved.
14
+ // Copyright (C) 2009, Willow Garage Inc., all rights reserved.
15
+ // Third party copyrights are property of their respective owners.
16
+ //
17
+ // Redistribution and use in source and binary forms, with or without modification,
18
+ // are permitted provided that the following conditions are met:
19
+ //
20
+ // * Redistribution's of source code must retain the above copyright notice,
21
+ // this list of conditions and the following disclaimer.
22
+ //
23
+ // * Redistribution's in binary form must reproduce the above copyright notice,
24
+ // this list of conditions and the following disclaimer in the documentation
25
+ // and/or other materials provided with the distribution.
26
+ //
27
+ // * The name of the copyright holders may not be used to endorse or promote products
28
+ // derived from this software without specific prior written permission.
29
+ //
30
+ // This software is provided by the copyright holders and contributors "as is" and
31
+ // any express or implied warranties, including, but not limited to, the implied
32
+ // warranties of merchantability and fitness for a particular purpose are disclaimed.
33
+ // In no event shall the Intel Corporation or contributors be liable for any direct,
34
+ // indirect, incidental, special, exemplary, or consequential damages
35
+ // (including, but not limited to, procurement of substitute goods or services;
36
+ // loss of use, data, or profits; or business interruption) however caused
37
+ // and on any theory of liability, whether in contract, strict liability,
38
+ // or tort (including negligence or otherwise) arising in any way out of
39
+ // the use of this software, even if advised of the possibility of such damage.
40
+ //
41
+ //M*/
42
+
43
+ #ifndef _GRFMT_BASE_H_
44
+ #define _GRFMT_BASE_H_
45
+
46
+ #include "utils.hpp"
47
+ #include "bitstrm.hpp"
48
+
49
+ namespace cv
50
+ {
51
+
52
+ class BaseImageDecoder;
53
+ class BaseImageEncoder;
54
+ typedef Ptr<BaseImageEncoder> ImageEncoder;
55
+ typedef Ptr<BaseImageDecoder> ImageDecoder;
56
+
57
+ ///////////////////////////////// base class for decoders ////////////////////////
58
+ class BaseImageDecoder
59
+ {
60
+ public:
61
+ BaseImageDecoder();
62
+ virtual ~BaseImageDecoder() {};
63
+
64
+ int width() const { return m_width; };
65
+ int height() const { return m_height; };
66
+ virtual int type() const { return m_type; };
67
+
68
+ virtual bool setSource( const string& filename );
69
+ virtual bool setSource( const Mat& buf );
70
+ virtual bool readHeader() = 0;
71
+ virtual bool readData( Mat& img ) = 0;
72
+
73
+ virtual size_t signatureLength() const;
74
+ virtual bool checkSignature( const string& signature ) const;
75
+ virtual ImageDecoder newDecoder() const;
76
+
77
+ protected:
78
+ int m_width; // width of the image ( filled by readHeader )
79
+ int m_height; // height of the image ( filled by readHeader )
80
+ int m_type;
81
+ string m_filename;
82
+ string m_signature;
83
+ Mat m_buf;
84
+ bool m_buf_supported;
85
+ };
86
+
87
+
88
+ ///////////////////////////// base class for encoders ////////////////////////////
89
+ class BaseImageEncoder
90
+ {
91
+ public:
92
+ BaseImageEncoder();
93
+ virtual ~BaseImageEncoder() {};
94
+ virtual bool isFormatSupported( int depth ) const;
95
+
96
+ virtual bool setDestination( const string& filename );
97
+ virtual bool setDestination( vector<uchar>& buf );
98
+ virtual bool write( const Mat& img, const vector<int>& params ) = 0;
99
+
100
+ virtual string getDescription() const;
101
+ virtual ImageEncoder newEncoder() const;
102
+
103
+ protected:
104
+ string m_description;
105
+
106
+ string m_filename;
107
+ vector<uchar>* m_buf;
108
+ bool m_buf_supported;
109
+ };
110
+
111
+ }
112
+
113
+ #endif/*_GRFMT_BASE_H_*/