├── .gitignore ├── FlameDetection.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── liberize.xcuserdatad │ │ ├── UserInterfaceState.xcuserstate │ │ ├── WorkspaceSettings.xcsettings │ │ └── xcdebugger │ │ └── Expressions.xcexplist └── xcuserdata │ └── liberize.xcuserdatad │ ├── xcdebugger │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ ├── FlameDetection.xcscheme │ └── xcschememanagement.plist ├── FlameDetection ├── FeatureAnalyzer.cpp ├── FeatureAnalyzer.h ├── FlameDecider.cpp ├── FlameDecider.h ├── FlameDetection.1 ├── FlameDetection.v11.suo ├── FlameDetector.cpp ├── FlameDetector.h ├── TargetExtractor.cpp ├── TargetExtractor.h ├── VideoHandler.cpp ├── VideoHandler.h ├── common.h ├── main.cpp ├── utils.cpp └── utils.h ├── LICENSE ├── README.md ├── build └── Debug │ └── FlameDetection ├── clips ├── 1.avi ├── 10.avi ├── 11.avi ├── 12.avi ├── 13.avi ├── 14.avi ├── 2.avi ├── 3.avi ├── 4.avi ├── 5.avi ├── 6.avi ├── 7.avi ├── 8.avi └── 9.avi ├── images ├── 2.gif └── 6.gif ├── samples ├── sample2.txt ├── sample4.txt └── sample6.txt └── test └── plot.py /.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | .DS_Store 3 | -------------------------------------------------------------------------------- /FlameDetection.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 6B3F15501908C88300D5DE4A /* TargetExtractor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6B3F154E1908C88300D5DE4A /* TargetExtractor.cpp */; }; 11 | 6B450DAB190C254800F017A1 /* libopencv_ml.2.4.8.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 6B450DAA190C254800F017A1 /* libopencv_ml.2.4.8.dylib */; }; 12 | 6B6D57B0192AFAE40026E0D7 /* FlameDecider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6B6D57AE192AFAE40026E0D7 /* FlameDecider.cpp */; }; 13 | 6B6E30DC192A2ACD00A3F9C6 /* utils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6B6E30DA192A2ACD00A3F9C6 /* utils.cpp */; }; 14 | 6B81AFD718FAF6E40001E950 /* FeatureAnalyzer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6B81AFD518FAF6E40001E950 /* FeatureAnalyzer.cpp */; }; 15 | 6B89752818F5AC8900B09507 /* libopencv_video.2.4.8.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 6B89752718F5AC8900B09507 /* libopencv_video.2.4.8.dylib */; }; 16 | 6BA07EBD18EDC67B00B50840 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6BA07EBC18EDC67B00B50840 /* main.cpp */; }; 17 | 6BA07EBF18EDC67B00B50840 /* FlameDetection.1 in CopyFiles */ = {isa = PBXBuildFile; fileRef = 6BA07EBE18EDC67B00B50840 /* FlameDetection.1 */; }; 18 | 6BBF3A5318F0544400759B8B /* FlameDetector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6BBF3A5118F0544400759B8B /* FlameDetector.cpp */; }; 19 | 6BBF3A5918F0662C00759B8B /* VideoHandler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6BBF3A5718F0662C00759B8B /* VideoHandler.cpp */; }; 20 | 6BCDD97A18F4487000664554 /* libopencv_core.2.4.8.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 6BCDD97718F4487000664554 /* libopencv_core.2.4.8.dylib */; }; 21 | 6BCDD97B18F4487000664554 /* libopencv_highgui.2.4.8.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 6BCDD97818F4487000664554 /* libopencv_highgui.2.4.8.dylib */; }; 22 | 6BCDD97C18F4487000664554 /* libopencv_imgproc.2.4.8.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 6BCDD97918F4487000664554 /* libopencv_imgproc.2.4.8.dylib */; }; 23 | /* End PBXBuildFile section */ 24 | 25 | /* Begin PBXCopyFilesBuildPhase section */ 26 | 6BA07EB718EDC67B00B50840 /* CopyFiles */ = { 27 | isa = PBXCopyFilesBuildPhase; 28 | buildActionMask = 2147483647; 29 | dstPath = /usr/share/man/man1/; 30 | dstSubfolderSpec = 0; 31 | files = ( 32 | 6BA07EBF18EDC67B00B50840 /* FlameDetection.1 in CopyFiles */, 33 | ); 34 | runOnlyForDeploymentPostprocessing = 1; 35 | }; 36 | /* End PBXCopyFilesBuildPhase section */ 37 | 38 | /* Begin PBXFileReference section */ 39 | 6B3F154E1908C88300D5DE4A /* TargetExtractor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TargetExtractor.cpp; sourceTree = ""; }; 40 | 6B3F154F1908C88300D5DE4A /* TargetExtractor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TargetExtractor.h; sourceTree = ""; }; 41 | 6B450DAA190C254800F017A1 /* libopencv_ml.2.4.8.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libopencv_ml.2.4.8.dylib; path = ../../../../usr/local/lib/libopencv_ml.2.4.8.dylib; sourceTree = ""; }; 42 | 6B6D57AE192AFAE40026E0D7 /* FlameDecider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FlameDecider.cpp; sourceTree = ""; }; 43 | 6B6D57AF192AFAE40026E0D7 /* FlameDecider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FlameDecider.h; sourceTree = ""; }; 44 | 6B6E30DA192A2ACD00A3F9C6 /* utils.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = utils.cpp; sourceTree = ""; }; 45 | 6B6E30DB192A2ACD00A3F9C6 /* utils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = utils.h; sourceTree = ""; }; 46 | 6B81AFD518FAF6E40001E950 /* FeatureAnalyzer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FeatureAnalyzer.cpp; sourceTree = ""; }; 47 | 6B81AFD618FAF6E40001E950 /* FeatureAnalyzer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FeatureAnalyzer.h; sourceTree = ""; }; 48 | 6B89752718F5AC8900B09507 /* libopencv_video.2.4.8.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libopencv_video.2.4.8.dylib; path = ../../../../usr/local/lib/libopencv_video.2.4.8.dylib; sourceTree = ""; }; 49 | 6BA07EB918EDC67B00B50840 /* FlameDetection */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = FlameDetection; sourceTree = BUILT_PRODUCTS_DIR; }; 50 | 6BA07EBC18EDC67B00B50840 /* main.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = ""; }; 51 | 6BA07EBE18EDC67B00B50840 /* FlameDetection.1 */ = {isa = PBXFileReference; lastKnownFileType = text.man; path = FlameDetection.1; sourceTree = ""; }; 52 | 6BBF3A5118F0544400759B8B /* FlameDetector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FlameDetector.cpp; sourceTree = ""; }; 53 | 6BBF3A5218F0544400759B8B /* FlameDetector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FlameDetector.h; sourceTree = ""; }; 54 | 6BBF3A5418F0577C00759B8B /* common.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = common.h; sourceTree = ""; }; 55 | 6BBF3A5718F0662C00759B8B /* VideoHandler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VideoHandler.cpp; sourceTree = ""; }; 56 | 6BBF3A5818F0662C00759B8B /* VideoHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VideoHandler.h; sourceTree = ""; }; 57 | 6BCDD97718F4487000664554 /* libopencv_core.2.4.8.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libopencv_core.2.4.8.dylib; path = ../../../../usr/local/lib/libopencv_core.2.4.8.dylib; sourceTree = ""; }; 58 | 6BCDD97818F4487000664554 /* libopencv_highgui.2.4.8.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libopencv_highgui.2.4.8.dylib; path = ../../../../usr/local/lib/libopencv_highgui.2.4.8.dylib; sourceTree = ""; }; 59 | 6BCDD97918F4487000664554 /* libopencv_imgproc.2.4.8.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libopencv_imgproc.2.4.8.dylib; path = ../../../../usr/local/lib/libopencv_imgproc.2.4.8.dylib; sourceTree = ""; }; 60 | /* End PBXFileReference section */ 61 | 62 | /* Begin PBXFrameworksBuildPhase section */ 63 | 6BA07EB618EDC67B00B50840 /* Frameworks */ = { 64 | isa = PBXFrameworksBuildPhase; 65 | buildActionMask = 2147483647; 66 | files = ( 67 | 6BCDD97C18F4487000664554 /* libopencv_imgproc.2.4.8.dylib in Frameworks */, 68 | 6B450DAB190C254800F017A1 /* libopencv_ml.2.4.8.dylib in Frameworks */, 69 | 6B89752818F5AC8900B09507 /* libopencv_video.2.4.8.dylib in Frameworks */, 70 | 6BCDD97A18F4487000664554 /* libopencv_core.2.4.8.dylib in Frameworks */, 71 | 6BCDD97B18F4487000664554 /* libopencv_highgui.2.4.8.dylib in Frameworks */, 72 | ); 73 | runOnlyForDeploymentPostprocessing = 0; 74 | }; 75 | /* End PBXFrameworksBuildPhase section */ 76 | 77 | /* Begin PBXGroup section */ 78 | 6BA07EB018EDC67B00B50840 = { 79 | isa = PBXGroup; 80 | children = ( 81 | 6BCDD97718F4487000664554 /* libopencv_core.2.4.8.dylib */, 82 | 6BCDD97918F4487000664554 /* libopencv_imgproc.2.4.8.dylib */, 83 | 6BCDD97818F4487000664554 /* libopencv_highgui.2.4.8.dylib */, 84 | 6B89752718F5AC8900B09507 /* libopencv_video.2.4.8.dylib */, 85 | 6B450DAA190C254800F017A1 /* libopencv_ml.2.4.8.dylib */, 86 | 6BA07EBB18EDC67B00B50840 /* FlameDetection */, 87 | 6BA07EBA18EDC67B00B50840 /* Products */, 88 | ); 89 | sourceTree = ""; 90 | }; 91 | 6BA07EBA18EDC67B00B50840 /* Products */ = { 92 | isa = PBXGroup; 93 | children = ( 94 | 6BA07EB918EDC67B00B50840 /* FlameDetection */, 95 | ); 96 | name = Products; 97 | sourceTree = ""; 98 | }; 99 | 6BA07EBB18EDC67B00B50840 /* FlameDetection */ = { 100 | isa = PBXGroup; 101 | children = ( 102 | 6BA07EBE18EDC67B00B50840 /* FlameDetection.1 */, 103 | 6BA07EBC18EDC67B00B50840 /* main.cpp */, 104 | 6BBF3A5418F0577C00759B8B /* common.h */, 105 | 6B6E30DA192A2ACD00A3F9C6 /* utils.cpp */, 106 | 6B6E30DB192A2ACD00A3F9C6 /* utils.h */, 107 | 6BBF3A5718F0662C00759B8B /* VideoHandler.cpp */, 108 | 6BBF3A5818F0662C00759B8B /* VideoHandler.h */, 109 | 6BBF3A5118F0544400759B8B /* FlameDetector.cpp */, 110 | 6BBF3A5218F0544400759B8B /* FlameDetector.h */, 111 | 6B3F154E1908C88300D5DE4A /* TargetExtractor.cpp */, 112 | 6B3F154F1908C88300D5DE4A /* TargetExtractor.h */, 113 | 6B81AFD518FAF6E40001E950 /* FeatureAnalyzer.cpp */, 114 | 6B81AFD618FAF6E40001E950 /* FeatureAnalyzer.h */, 115 | 6B6D57AE192AFAE40026E0D7 /* FlameDecider.cpp */, 116 | 6B6D57AF192AFAE40026E0D7 /* FlameDecider.h */, 117 | ); 118 | path = FlameDetection; 119 | sourceTree = ""; 120 | }; 121 | /* End PBXGroup section */ 122 | 123 | /* Begin PBXNativeTarget section */ 124 | 6BA07EB818EDC67B00B50840 /* FlameDetection */ = { 125 | isa = PBXNativeTarget; 126 | buildConfigurationList = 6BA07EC218EDC67B00B50840 /* Build configuration list for PBXNativeTarget "FlameDetection" */; 127 | buildPhases = ( 128 | 6BA07EB518EDC67B00B50840 /* Sources */, 129 | 6BA07EB618EDC67B00B50840 /* Frameworks */, 130 | 6BA07EB718EDC67B00B50840 /* CopyFiles */, 131 | ); 132 | buildRules = ( 133 | ); 134 | dependencies = ( 135 | ); 136 | name = FlameDetection; 137 | productName = FlameDetection; 138 | productReference = 6BA07EB918EDC67B00B50840 /* FlameDetection */; 139 | productType = "com.apple.product-type.tool"; 140 | }; 141 | /* End PBXNativeTarget section */ 142 | 143 | /* Begin PBXProject section */ 144 | 6BA07EB118EDC67B00B50840 /* Project object */ = { 145 | isa = PBXProject; 146 | attributes = { 147 | LastUpgradeCheck = 0500; 148 | ORGANIZATIONNAME = liberize; 149 | }; 150 | buildConfigurationList = 6BA07EB418EDC67B00B50840 /* Build configuration list for PBXProject "FlameDetection" */; 151 | compatibilityVersion = "Xcode 3.2"; 152 | developmentRegion = English; 153 | hasScannedForEncodings = 0; 154 | knownRegions = ( 155 | en, 156 | ); 157 | mainGroup = 6BA07EB018EDC67B00B50840; 158 | productRefGroup = 6BA07EBA18EDC67B00B50840 /* Products */; 159 | projectDirPath = ""; 160 | projectRoot = ""; 161 | targets = ( 162 | 6BA07EB818EDC67B00B50840 /* FlameDetection */, 163 | ); 164 | }; 165 | /* End PBXProject section */ 166 | 167 | /* Begin PBXSourcesBuildPhase section */ 168 | 6BA07EB518EDC67B00B50840 /* Sources */ = { 169 | isa = PBXSourcesBuildPhase; 170 | buildActionMask = 2147483647; 171 | files = ( 172 | 6B6D57B0192AFAE40026E0D7 /* FlameDecider.cpp in Sources */, 173 | 6B81AFD718FAF6E40001E950 /* FeatureAnalyzer.cpp in Sources */, 174 | 6BBF3A5318F0544400759B8B /* FlameDetector.cpp in Sources */, 175 | 6BBF3A5918F0662C00759B8B /* VideoHandler.cpp in Sources */, 176 | 6B6E30DC192A2ACD00A3F9C6 /* utils.cpp in Sources */, 177 | 6BA07EBD18EDC67B00B50840 /* main.cpp in Sources */, 178 | 6B3F15501908C88300D5DE4A /* TargetExtractor.cpp in Sources */, 179 | ); 180 | runOnlyForDeploymentPostprocessing = 0; 181 | }; 182 | /* End PBXSourcesBuildPhase section */ 183 | 184 | /* Begin XCBuildConfiguration section */ 185 | 6BA07EC018EDC67B00B50840 /* Debug */ = { 186 | isa = XCBuildConfiguration; 187 | buildSettings = { 188 | ALWAYS_SEARCH_USER_PATHS = NO; 189 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 190 | CLANG_CXX_LIBRARY = "libc++"; 191 | CLANG_ENABLE_OBJC_ARC = YES; 192 | CLANG_WARN_BOOL_CONVERSION = YES; 193 | CLANG_WARN_CONSTANT_CONVERSION = YES; 194 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 195 | CLANG_WARN_EMPTY_BODY = YES; 196 | CLANG_WARN_ENUM_CONVERSION = YES; 197 | CLANG_WARN_INT_CONVERSION = YES; 198 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 199 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 200 | COPY_PHASE_STRIP = NO; 201 | GCC_C_LANGUAGE_STANDARD = gnu99; 202 | GCC_DYNAMIC_NO_PIC = NO; 203 | GCC_ENABLE_OBJC_EXCEPTIONS = YES; 204 | GCC_OPTIMIZATION_LEVEL = 0; 205 | GCC_PREPROCESSOR_DEFINITIONS = ( 206 | "DEBUG=1", 207 | "$(inherited)", 208 | ); 209 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 210 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 211 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 212 | GCC_WARN_UNDECLARED_SELECTOR = YES; 213 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 214 | GCC_WARN_UNUSED_FUNCTION = YES; 215 | GCC_WARN_UNUSED_VARIABLE = YES; 216 | MACOSX_DEPLOYMENT_TARGET = 10.9; 217 | ONLY_ACTIVE_ARCH = YES; 218 | SDKROOT = macosx; 219 | }; 220 | name = Debug; 221 | }; 222 | 6BA07EC118EDC67B00B50840 /* Release */ = { 223 | isa = XCBuildConfiguration; 224 | buildSettings = { 225 | ALWAYS_SEARCH_USER_PATHS = NO; 226 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 227 | CLANG_CXX_LIBRARY = "libc++"; 228 | CLANG_ENABLE_OBJC_ARC = YES; 229 | CLANG_WARN_BOOL_CONVERSION = YES; 230 | CLANG_WARN_CONSTANT_CONVERSION = YES; 231 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 232 | CLANG_WARN_EMPTY_BODY = YES; 233 | CLANG_WARN_ENUM_CONVERSION = YES; 234 | CLANG_WARN_INT_CONVERSION = YES; 235 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 236 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 237 | COPY_PHASE_STRIP = YES; 238 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 239 | ENABLE_NS_ASSERTIONS = NO; 240 | GCC_C_LANGUAGE_STANDARD = gnu99; 241 | GCC_ENABLE_OBJC_EXCEPTIONS = YES; 242 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 243 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 244 | GCC_WARN_UNDECLARED_SELECTOR = YES; 245 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 246 | GCC_WARN_UNUSED_FUNCTION = YES; 247 | GCC_WARN_UNUSED_VARIABLE = YES; 248 | MACOSX_DEPLOYMENT_TARGET = 10.9; 249 | SDKROOT = macosx; 250 | }; 251 | name = Release; 252 | }; 253 | 6BA07EC318EDC67B00B50840 /* Debug */ = { 254 | isa = XCBuildConfiguration; 255 | buildSettings = { 256 | HEADER_SEARCH_PATHS = ( 257 | "$(inherited)", 258 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, 259 | /usr/local/include, 260 | ); 261 | LIBRARY_SEARCH_PATHS = ( 262 | "$(inherited)", 263 | /usr/local/lib, 264 | ); 265 | PRODUCT_NAME = "$(TARGET_NAME)"; 266 | }; 267 | name = Debug; 268 | }; 269 | 6BA07EC418EDC67B00B50840 /* Release */ = { 270 | isa = XCBuildConfiguration; 271 | buildSettings = { 272 | HEADER_SEARCH_PATHS = ( 273 | "$(inherited)", 274 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, 275 | /usr/local/include, 276 | ); 277 | LIBRARY_SEARCH_PATHS = ( 278 | "$(inherited)", 279 | /usr/local/lib, 280 | ); 281 | PRODUCT_NAME = "$(TARGET_NAME)"; 282 | }; 283 | name = Release; 284 | }; 285 | /* End XCBuildConfiguration section */ 286 | 287 | /* Begin XCConfigurationList section */ 288 | 6BA07EB418EDC67B00B50840 /* Build configuration list for PBXProject "FlameDetection" */ = { 289 | isa = XCConfigurationList; 290 | buildConfigurations = ( 291 | 6BA07EC018EDC67B00B50840 /* Debug */, 292 | 6BA07EC118EDC67B00B50840 /* Release */, 293 | ); 294 | defaultConfigurationIsVisible = 0; 295 | defaultConfigurationName = Release; 296 | }; 297 | 6BA07EC218EDC67B00B50840 /* Build configuration list for PBXNativeTarget "FlameDetection" */ = { 298 | isa = XCConfigurationList; 299 | buildConfigurations = ( 300 | 6BA07EC318EDC67B00B50840 /* Debug */, 301 | 6BA07EC418EDC67B00B50840 /* Release */, 302 | ); 303 | defaultConfigurationIsVisible = 0; 304 | defaultConfigurationName = Release; 305 | }; 306 | /* End XCConfigurationList section */ 307 | }; 308 | rootObject = 6BA07EB118EDC67B00B50840 /* Project object */; 309 | } 310 | -------------------------------------------------------------------------------- /FlameDetection.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /FlameDetection.xcodeproj/project.xcworkspace/xcuserdata/liberize.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liberize/flame-detection-system/4740a3ec7f28886b8ed0adc456a746f2df378d19/FlameDetection.xcodeproj/project.xcworkspace/xcuserdata/liberize.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /FlameDetection.xcodeproj/project.xcworkspace/xcuserdata/liberize.xcuserdatad/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liberize/flame-detection-system/4740a3ec7f28886b8ed0adc456a746f2df378d19/FlameDetection.xcodeproj/project.xcworkspace/xcuserdata/liberize.xcuserdatad/WorkspaceSettings.xcsettings -------------------------------------------------------------------------------- /FlameDetection.xcodeproj/project.xcworkspace/xcuserdata/liberize.xcuserdatad/xcdebugger/Expressions.xcexplist: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 7 | 8 | 10 | 11 | 13 | 14 | 16 | 17 | 18 | 19 | 21 | 22 | 24 | 25 | 27 | 28 | 29 | 30 | 32 | 33 | 35 | 36 | 38 | 39 | 41 | 42 | 44 | 45 | 47 | 48 | 49 | 50 | 52 | 53 | 55 | 56 | 57 | 58 | 60 | 61 | 63 | 64 | 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /FlameDetection.xcodeproj/xcuserdata/liberize.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /FlameDetection.xcodeproj/xcuserdata/liberize.xcuserdatad/xcschemes/FlameDetection.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 52 | 53 | 59 | 60 | 61 | 62 | 63 | 64 | 70 | 71 | 77 | 78 | 79 | 80 | 82 | 83 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /FlameDetection.xcodeproj/xcuserdata/liberize.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | FlameDetection.xcscheme 8 | 9 | orderHint 10 | 1 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 6BA07EB818EDC67B00B50840 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /FlameDetection/FeatureAnalyzer.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // FeatureAnalyzer.cpp 3 | // FlameDetection 4 | // 5 | // Created by liberize on 14-4-14. 6 | // Copyright (c) 2014年 liberize. All rights reserved. 7 | // 8 | 9 | #include "FeatureAnalyzer.h" 10 | #include "VideoHandler.h" 11 | #include "FlameDetector.h" 12 | #include "TargetExtractor.h" 13 | 14 | extern VideoHandler* videoHandler; 15 | 16 | /**************** Feature ****************/ 17 | 18 | void Feature::calcColorFeature() 19 | { 20 | // TODO: optimize this part, reduce extra work 21 | 22 | Mat hsv; 23 | cvtColor(mROI, hsv, CV_BGR2HSV_FULL); 24 | 25 | Mat temp(mROI.size(), CV_8UC3), mixed; 26 | Mat src[] = { mROI, mGray, hsv }; 27 | int fromTo[] = { 2,0, 3,1, 5,2 }; 28 | mixChannels(src, 3, &temp, 1, fromTo, 3); 29 | temp.convertTo(mixed, CV_64F); 30 | 31 | Scalar avg, stdDev; 32 | meanStdDev(mixed, avg, stdDev, mMask); 33 | Scalar var = stdDev.mul(stdDev); 34 | Mat temp1 = mixed - avg; 35 | Mat temp2 = temp1.mul(temp1); 36 | Scalar sk = mean(temp1.mul(temp2), mMask) / (var.mul(stdDev)); 37 | Scalar ku = mean(temp2.mul(temp2), mMask) / (var.mul(var)); 38 | 39 | Scalar stat[] = { avg, stdDev, sk, ku }; 40 | for (int i = 0; i < 4; i++) { 41 | red[i] = stat[i][0]; 42 | gray[i] = stat[i][1]; 43 | saturation[i] = stat[i][2]; 44 | } 45 | } 46 | 47 | void Feature::calcGeometryFeature(const Region& region) 48 | { 49 | circularity = 0; 50 | squareness = 0; 51 | aspectRatio = 0; 52 | roughness = 0; 53 | 54 | const vector& contours = region.contours; 55 | for (vector::const_iterator it = contours.begin(); it != contours.end(); it++) { 56 | const vector& contour = (*it)->contour; 57 | double area = (*it)->area; 58 | 59 | double perimeter = arcLength(contour, true); 60 | RotatedRect minRect = minAreaRect(Mat(contour)); 61 | vector hull; 62 | convexHull(contour, hull); 63 | double perimeterHull = arcLength(hull, true); 64 | double width = minRect.size.width, height = minRect.size.height; 65 | 66 | circularity += area * (4 * M_PI * area / (perimeter * perimeter)); 67 | squareness += area * (area / (width * height)); 68 | aspectRatio += area * (1.0 * min(width, height) / max(width, height)); 69 | roughness += area * (perimeterHull / perimeter); 70 | } 71 | 72 | circularity /= mArea; 73 | squareness /= mArea; 74 | aspectRatio /= mArea; 75 | roughness /= mArea; 76 | } 77 | 78 | void Feature::calcTexture(int levels, int dx, int dy) 79 | { 80 | assert(levels >= 2 && levels <= 256 && (levels & (levels - 1)) == 0); 81 | assert(dx >= 0 && dy >= 0 && dx + dy > 0); 82 | 83 | Mat temp; 84 | mGray.copyTo(temp); 85 | 86 | // TODO: implement my own version of 'equalizeHist' which accepts mask as an argument 87 | double minVal; 88 | minMaxLoc(temp, &minVal, NULL, NULL, NULL, mMask); 89 | uchar min = cvRound(minVal); 90 | for (int i = 0; i < temp.rows; i++) { 91 | for (int j = 0; j < temp.cols; j++) { 92 | if (mMask.at(i, j) == 0) { 93 | temp.at(i, j) = min; 94 | } 95 | } 96 | } 97 | equalizeHist(temp, temp); 98 | 99 | #ifdef DEBUG_OUTPUT 100 | imshow("hist", temp); 101 | #endif 102 | 103 | for (int i = 0; i < temp.rows; i++) { 104 | for (int j = 0; j < temp.cols; j++) { 105 | if (mMask.at(i, j) == 255) { 106 | temp.at(i, j) /= 256 / levels; 107 | } 108 | } 109 | } 110 | 111 | Mat glcm = Mat::zeros(Size(levels, levels), CV_64FC1); 112 | for (int i = 0; i < temp.rows; i++) { 113 | for (int j = 0; j < temp.cols; j++) { 114 | if (mMask.at(i, j) == 255) { 115 | uchar l = temp.at(i, j); 116 | int x1 = j + dx, y1 = i + dy; 117 | if (x1 < temp.cols && y1 < temp.rows && mMask.at(y1, x1) == 255) { 118 | uchar m = temp.at(y1, x1); 119 | glcm.at(l, m) += 1; 120 | } 121 | int x2 = j - dx, y2 = i - dy; 122 | if (x2 >= 0 && y2 >= 0 && mMask.at(y2, x2) == 255) { 123 | uchar m = temp.at(y2, x2); 124 | glcm.at(l, m) += 1; 125 | } 126 | } 127 | } 128 | } 129 | 130 | double sum = cv::sum(glcm)[0]; 131 | if (sum == 0) { 132 | memset(texture, 0, sizeof(texture)); 133 | return; 134 | } 135 | 136 | glcm *= 1.0 / sum; 137 | 138 | // in fact, the third one is not contrast... 139 | double entropy = 0, energy = 0, contrast = 0, homogenity = 0; 140 | for (int i = 0; i < levels; i++) { 141 | for (int j = 0; j < levels; j++) { 142 | double gij = glcm.at(i, j); 143 | if(gij > 0) { 144 | entropy -= gij * log10(gij); 145 | } 146 | energy += gij * gij; 147 | contrast += (i - j) * (i - j) * gij; 148 | homogenity += 1.0 / (1 + (i - j) * (i - j)) * gij; 149 | } 150 | } 151 | 152 | texture[0] = entropy; 153 | texture[1] = energy; 154 | texture[2] = contrast; 155 | texture[3] = homogenity; 156 | } 157 | 158 | void Feature::calcFrequency() 159 | { 160 | // TODO: optimize this part 161 | 162 | if (mAreaVec.size() < MAX_AREA_VEC_SIZE) { 163 | frequency = -1; 164 | return; 165 | } 166 | 167 | // limit n to integer power of 2 for simplicity 168 | // in fact, you can use function 'getOptimalDFTSize' to pad the input array 169 | assert((MAX_AREA_VEC_SIZE & (MAX_AREA_VEC_SIZE - 1)) == 0); 170 | 171 | vector spec(MAX_AREA_VEC_SIZE); 172 | dft(mAreaVec, spec); 173 | 174 | double maxAmpl = 0; 175 | int idx = 0; 176 | for (int i = 1; i < MAX_AREA_VEC_SIZE; i += 2) { 177 | double ampl = (i == MAX_AREA_VEC_SIZE - 1) ? spec[i] : 178 | sqrt(spec[i] * spec[i] + spec[i + 1] * spec[i + 1]); 179 | if (ampl > maxAmpl) { 180 | maxAmpl = ampl; 181 | idx = (i + 1) / 2; 182 | } 183 | } 184 | 185 | double fps = videoHandler->getVideoFPS(); 186 | frequency = fps / MAX_AREA_VEC_SIZE * idx; 187 | 188 | #ifdef DEBUG_OUTPUT 189 | cout << "fps: " << fps << ", frequency: " << frequency << endl; 190 | #endif 191 | } 192 | 193 | void Feature::calcAreaVar() 194 | { 195 | // TODO: optimize this part 196 | 197 | if (mAreaVec.size() < MAX_AREA_VEC_SIZE) { 198 | areaVar = -1; 199 | return; 200 | } 201 | 202 | Scalar m, s; 203 | meanStdDev(mAreaVec, m, s); 204 | areaVar = s[0] / m[0]; 205 | 206 | #ifdef DEBUG_OUTPUT 207 | cout << "areaVar: " << areaVar << endl; 208 | #endif 209 | } 210 | 211 | void Feature::calc(const Region& region, const Mat& frame) 212 | { 213 | mROI = frame(region.rect); 214 | cvtColor(mROI, mGray, CV_BGR2GRAY); 215 | const Mat& mask = videoHandler->getDetector().getExtractor().getMask(); 216 | mMask = mask(region.rect); 217 | mArea = 0; 218 | 219 | const vector& contours = region.contours; 220 | for (vector::const_iterator it = contours.begin(); it != contours.end(); it++) { 221 | mArea += (*it)->area; 222 | } 223 | 224 | calcColorFeature(); 225 | calcGeometryFeature(region); 226 | calcTexture(); 227 | 228 | if (mAreaVec.size() >= MAX_AREA_VEC_SIZE) { 229 | mAreaVec.erase(mAreaVec.begin()); 230 | } 231 | mAreaVec.push_back(mArea); 232 | 233 | calcFrequency(); 234 | calcAreaVar(); 235 | } 236 | 237 | void Feature::merge(const vector& src, Feature& feature) 238 | { 239 | vector::size_type maxAreaVecSize = 0; 240 | for (vector::const_iterator it = src.begin(); it != src.end(); it++) { 241 | vector::size_type areaVecSize = (*it)->mAreaVec.size(); 242 | if (areaVecSize > maxAreaVecSize) { 243 | maxAreaVecSize = areaVecSize; 244 | } 245 | } 246 | 247 | vector(maxAreaVecSize, 0).swap(feature.mAreaVec); 248 | 249 | for (vector::const_iterator it1 = src.begin(); it1 != src.end(); it1++) { 250 | const vector& areaVec = (*it1)->mAreaVec; 251 | vector::reverse_iterator it2 = feature.mAreaVec.rbegin(); 252 | 253 | for (vector::const_reverse_iterator it4 = areaVec.rbegin(); it4 != areaVec.rend(); it4++) { 254 | *(it2++) += *it4; 255 | } 256 | } 257 | } 258 | 259 | Feature::operator Mat() const 260 | { 261 | return (Mat_(1, LEN) << 262 | red[0], red[1], red[2], red[3], 263 | gray[0], gray[1], gray[2], gray[3], 264 | saturation[0], saturation[1], saturation[2], saturation[3], 265 | circularity, squareness, aspectRatio, roughness, 266 | texture[0], texture[1], texture[2], texture[3]); 267 | } 268 | 269 | ifstream& operator>>(ifstream& ifs, Feature& feature) 270 | { 271 | ifs >> feature.red[0] >> feature.red[1] 272 | >> feature.red[2] >> feature.red[3] 273 | >> feature.gray[0] >> feature.gray[1] 274 | >> feature.gray[2] >> feature.gray[3] 275 | >> feature.saturation[0] >> feature.saturation[1] 276 | >> feature.saturation[2] >> feature.saturation[3] 277 | >> feature.circularity >> feature.squareness 278 | >> feature.aspectRatio >> feature.roughness 279 | >> feature.texture[0] >> feature.texture[1] 280 | >> feature.texture[2] >> feature.texture[3]; 281 | return ifs; 282 | } 283 | 284 | ofstream& operator<<(ofstream& ofs, const Feature& feature) 285 | { 286 | ofs << feature.red[0] << " " << feature.red[1] << " " 287 | << feature.red[2] << " " << feature.red[3] << " " 288 | << feature.gray[0] << " " << feature.gray[1] << " " 289 | << feature.gray[2] << " " << feature.gray[3] << " " 290 | << feature.saturation[0] << " " << feature.saturation[1] << " " 291 | << feature.saturation[2] << " " << feature.saturation[3] << " " 292 | << feature.circularity << " " << feature.squareness << " " 293 | << feature.aspectRatio << " " << feature.roughness << " " 294 | << feature.texture[0] << " " << feature.texture[1] << " " 295 | << feature.texture[2] << " " << feature.texture[3] << " "; 296 | return ofs; 297 | } 298 | 299 | #ifdef DEBUG_OUTPUT 300 | void Feature::printAreaVec() const 301 | { 302 | vector::size_type size = mAreaVec.size(); 303 | 304 | for (int i = 0; i < size; i++) { 305 | cout << mAreaVec[i]; 306 | if (i != size - 1) { 307 | cout << ", "; 308 | } else { 309 | cout << endl; 310 | } 311 | } 312 | } 313 | #endif 314 | 315 | /**************** FeatureAnalyzer ****************/ 316 | 317 | void FeatureAnalyzer::featureMerge(Target& target, const map& targets, const vector& keys) 318 | { 319 | vector featureVec; 320 | for (vector::const_iterator it = keys.begin(); it != keys.end(); it++) { 321 | // const map can't be accessed by operator '[]', so use function 'find' instead 322 | map::const_iterator iter = targets.find(*it); 323 | featureVec.push_back(&(iter->second.feature)); 324 | } 325 | Feature::merge(featureVec, target.feature); 326 | } 327 | 328 | void FeatureAnalyzer::targetUpdate(map& targets) 329 | { 330 | for (map::iterator it = targets.begin(); it != targets.end(); ) { 331 | Target& target = it->second; 332 | 333 | if (target.type == Target::TARGET_LOST) { 334 | int maxTimes = min(target.times * 2, 10); 335 | if (target.lostTimes >= maxTimes) { 336 | targets.erase(it++); 337 | continue; 338 | } 339 | } else { 340 | if (target.lostTimes != 0) { 341 | target.lostTimes = 0; 342 | } 343 | if (target.type == Target::TARGET_MERGED) { 344 | vector& keys = target.mergeSrc; 345 | featureMerge(target, targets, keys); 346 | for (vector::const_iterator it2 = keys.begin(); it2 != keys.end(); it2++) { 347 | targets.erase(targets.find(*it2)); 348 | } 349 | vector().swap(keys); 350 | } 351 | } 352 | it++; 353 | } 354 | 355 | for (map::iterator it = targets.begin(); it != targets.end(); it++) { 356 | Target& target = it->second; 357 | if (target.type != Target::TARGET_LOST) { 358 | target.feature.calc(target.region, mFrame); 359 | } 360 | } 361 | } 362 | 363 | void FeatureAnalyzer::analyze(const Mat& frame, map& targets) 364 | { 365 | mFrame = frame; 366 | 367 | targetUpdate(targets); 368 | 369 | Mat temp; 370 | mFrame.copyTo(temp); 371 | for (map::iterator it = targets.begin(); it != targets.end(); it++) { 372 | rectangle(temp, it->second.region.rect, Scalar(0, 255, 0)); 373 | } 374 | namedWindow("frame"); 375 | moveWindow("frame", 10, 400); 376 | imshow("frame", temp); 377 | } 378 | -------------------------------------------------------------------------------- /FlameDetection/FeatureAnalyzer.h: -------------------------------------------------------------------------------- 1 | // 2 | // FeatureAnalyzer.h 3 | // FlameDetection 4 | // 5 | // Created by liberize on 14-4-14. 6 | // Copyright (c) 2014年 liberize. All rights reserved. 7 | // 8 | 9 | #ifndef __FlameDetection__FeatureAnalyzer__ 10 | #define __FlameDetection__FeatureAnalyzer__ 11 | 12 | #include "common.h" 13 | 14 | struct Target; 15 | class Region; 16 | 17 | 18 | class Feature { 19 | private: 20 | Mat mROI; 21 | Mat mGray; 22 | Mat mMask; 23 | double mArea; 24 | 25 | static const int MAX_AREA_VEC_SIZE = 32; 26 | 27 | // if we use list here, we need to convert it to vector each time. so use vector instead. 28 | vector mAreaVec; 29 | 30 | void calcColorFeature(); 31 | void calcGeometryFeature(const Region& region); 32 | void calcTexture(int levels = 16, int dx = 3, int dy = 3); 33 | void calcFrequency(); 34 | void calcAreaVar(); 35 | 36 | public: 37 | static const int LEN = 20; 38 | 39 | // color features 40 | double red[4]; 41 | double gray[4]; 42 | double saturation[4]; 43 | 44 | // geometric features 45 | double circularity; 46 | double squareness; 47 | double aspectRatio; 48 | double roughness; 49 | 50 | // structural features 51 | double texture[4]; 52 | 53 | // dynamic features 54 | double frequency; 55 | double areaVar; 56 | 57 | void calc(const Region& region, const Mat& frame); 58 | static void merge(const vector& src, Feature& feature); 59 | operator Mat() const; 60 | 61 | #ifdef DEBUG_OUTPUT 62 | void printAreaVec() const; 63 | #endif 64 | }; 65 | 66 | ifstream& operator>>(ifstream& ifs, Feature& feature); 67 | ofstream& operator<<(ofstream& ofs, const Feature& feature); 68 | 69 | 70 | class FeatureAnalyzer { 71 | private: 72 | Mat mFrame; 73 | 74 | void featureUpdate(Target& target); 75 | void featureMerge(Target& target, const map& targets, const vector& keys); 76 | void targetUpdate(map& targets); 77 | 78 | public: 79 | void analyze(const Mat& frame, map& targets); 80 | }; 81 | 82 | #endif /* defined(__FlameDetection__FeatureAnalyzer__) */ 83 | -------------------------------------------------------------------------------- /FlameDetection/FlameDecider.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // FlameDecider.cpp 3 | // FlameDetection 4 | // 5 | // Created by liberize on 14-5-20. 6 | // Copyright (c) 2014年 liberize. All rights reserved. 7 | // 8 | 9 | #include "FlameDecider.h" 10 | #include "FlameDetector.h" 11 | #include "FeatureAnalyzer.h" 12 | 13 | const string FlameDecider::SVM_DATA_FILE("svmdata.xml"); 14 | 15 | #ifdef TRAIN_MODE 16 | const string FlameDecider::SAMPLE_FILE("sample.txt"); 17 | #endif 18 | 19 | #ifdef TRAIN_MODE 20 | FlameDecider::FlameDecider() 21 | : mSampleEnough(false) 22 | , mFlameCount(0) 23 | , mNonFlameCount(0) 24 | , mFrameCount(0) 25 | { 26 | Feature feature; 27 | bool isFlame; 28 | 29 | ifstream ifs(SAMPLE_FILE); 30 | while (ifs >> feature >> isFlame) { 31 | mFeatureVec.push_back(feature); 32 | mResultVec.push_back(isFlame); 33 | if (isFlame) { 34 | mFlameCount++; 35 | } else { 36 | mNonFlameCount++; 37 | } 38 | } 39 | ifs.close(); 40 | 41 | if (mFlameCount >= MIN_SAMPLE_COUNT && mNonFlameCount >= MIN_SAMPLE_COUNT) { 42 | mSampleEnough = true; 43 | cout << "Flame count: " << mFlameCount << ", non-flame count: " << mNonFlameCount << "." << endl; 44 | } 45 | } 46 | #else 47 | FlameDecider::FlameDecider() 48 | { 49 | mSVM.load(SVM_DATA_FILE.c_str()); 50 | } 51 | #endif 52 | 53 | #ifdef TRAIN_MODE 54 | void FlameDecider::userInput(const map& targets) 55 | { 56 | ofstream ofs(SAMPLE_FILE, ios::app); 57 | for (map::const_iterator it = targets.begin(); it != targets.end(); it++) { 58 | if (it->second.lostTimes > 0) { 59 | continue; 60 | } 61 | 62 | const Feature& feature = it->second.feature; 63 | const Rectangle& rect = it->second.region.rect; 64 | 65 | Mat temp; 66 | mFrame.copyTo(temp); 67 | bool flag = true; 68 | 69 | while (true) { 70 | int key = waitKey(200); 71 | switch (key) { 72 | case -1: // no key pressed 73 | rectangle(temp, rect, flag ? Scalar(0, 0, 255) : Scalar(0, 255, 0)); 74 | namedWindow("temp"); 75 | moveWindow("temp", 350, 400); 76 | imshow("temp", temp); 77 | flag = !flag; 78 | break; 79 | case 'y': // press 'y' to add a positive record to sample 80 | ofs << feature << true << endl; 81 | #ifdef DEBUG_OUTPUT 82 | cout << "freq: " << feature.frequency << endl; 83 | feature.printAreaVec(); 84 | #endif 85 | mFeatureVec.push_back(feature); 86 | mResultVec.push_back(true); 87 | mFlameCount++; 88 | goto next; 89 | case 'n': // press 'n' to add a negative record to sample 90 | ofs << feature << false << endl; 91 | mFeatureVec.push_back(feature); 92 | mResultVec.push_back(false); 93 | mNonFlameCount++; 94 | goto next; 95 | case ' ': // press SPACE to skip current target 96 | goto next; 97 | case 's': // press 's' to skip current frame 98 | goto end; 99 | case 27: // press ESC to stop training and exit program 100 | trainComplete = true; 101 | goto end; 102 | case 'o': // press 'o' to stop input and start studying 103 | mSampleEnough = true; 104 | goto end; 105 | default: 106 | break; 107 | } 108 | } 109 | 110 | next: 111 | if (mFlameCount >= MIN_SAMPLE_COUNT && mNonFlameCount >= MIN_SAMPLE_COUNT) { 112 | mSampleEnough = true; 113 | goto end; 114 | } 115 | } 116 | 117 | end: 118 | ofs.close(); 119 | cout << "Flame count: " << mFlameCount << ", non-flame count: " << mNonFlameCount << "." << endl; 120 | } 121 | 122 | void FlameDecider::svmStudy() 123 | { 124 | assert(mFeatureVec.size() == mResultVec.size()); 125 | 126 | int size = int(mFeatureVec.size()); 127 | Mat data(size, Feature::LEN, CV_32FC1); 128 | Mat label(size, 1, CV_32FC1); 129 | 130 | for (int i = 0; i < size; i++) { 131 | Mat(mFeatureVec[i]).copyTo(data.row(i)); 132 | label.at(i, 0) = mResultVec[i] ? 1.0 : 0.0; 133 | } 134 | 135 | CvSVMParams params; 136 | params.svm_type = CvSVM::C_SVC; 137 | params.kernel_type = CvSVM::LINEAR; 138 | params.term_crit = cvTermCriteria(CV_TERMCRIT_ITER, 100, 1e-6); 139 | 140 | mSVM.train(data, label, Mat(), Mat(), params); 141 | mSVM.save(SVM_DATA_FILE.c_str()); 142 | } 143 | 144 | void FlameDecider::train(const map& targets) 145 | { 146 | if (!mSampleEnough) { 147 | if (mFrameCount++ % FRAME_GAP == 0) { 148 | userInput(targets); 149 | } 150 | } else { 151 | svmStudy(); 152 | trainComplete = true; 153 | } 154 | } 155 | #else 156 | inline bool FlameDecider::svmPredict(const Feature& feature) 157 | { 158 | float result = mSVM.predict(Mat(feature)); 159 | cout << "result: " << result << endl; 160 | return result == 1.0; 161 | } 162 | 163 | bool FlameDecider::judge(map& targets) 164 | { 165 | bool flameDetected = false; 166 | 167 | Mat temp; 168 | mFrame.copyTo(temp); 169 | 170 | for (map::iterator it = targets.begin(); it != targets.end(); it++) { 171 | bool isFlame = svmPredict(it->second.feature); 172 | it->second.isFlame = isFlame; 173 | if (isFlame) { 174 | flameDetected = true; 175 | rectangle(temp, it->second.region.rect, Scalar(0, 255, 0)); 176 | } 177 | } 178 | 179 | namedWindow("result"); 180 | moveWindow("result", 350, 400); 181 | imshow("result", temp); 182 | return flameDetected; 183 | } 184 | #endif 185 | 186 | bool FlameDecider::decide(const Mat& frame, map& targets) 187 | { 188 | mFrame = frame; 189 | 190 | #ifdef TRAIN_MODE 191 | train(targets); 192 | return false; 193 | #else 194 | return judge(targets); 195 | #endif 196 | } 197 | -------------------------------------------------------------------------------- /FlameDetection/FlameDecider.h: -------------------------------------------------------------------------------- 1 | // 2 | // FlameDecider.h 3 | // FlameDetection 4 | // 5 | // Created by liberize on 14-5-20. 6 | // Copyright (c) 2014年 liberize. All rights reserved. 7 | // 8 | 9 | #ifndef __FlameDetection__FlameDecider__ 10 | #define __FlameDetection__FlameDecider__ 11 | 12 | #include "common.h" 13 | 14 | struct Target; 15 | class Feature; 16 | 17 | 18 | class FlameDecider { 19 | private: 20 | static const string SVM_DATA_FILE; 21 | 22 | #ifdef TRAIN_MODE 23 | static const string SAMPLE_FILE; 24 | static const int MIN_SAMPLE_COUNT = 1000; 25 | static const int FRAME_GAP = 5; 26 | #endif 27 | 28 | Mat mFrame; 29 | CvSVM mSVM; 30 | 31 | #ifdef TRAIN_MODE 32 | bool mSampleEnough; 33 | int mFlameCount; 34 | int mNonFlameCount; 35 | vector mFeatureVec; 36 | vector mResultVec; 37 | int mFrameCount; 38 | #endif 39 | 40 | #ifdef TRAIN_MODE 41 | void userInput(const map& targets); 42 | void svmStudy(); 43 | void train(const map& targets); 44 | #else 45 | bool svmPredict(const Feature& feature); 46 | bool judge(map& targets); 47 | #endif 48 | 49 | public: 50 | FlameDecider(); 51 | bool decide(const Mat& frame, map& targets); 52 | }; 53 | 54 | #endif /* defined(__FlameDetection__FlameDecider__) */ 55 | -------------------------------------------------------------------------------- /FlameDetection/FlameDetection.1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liberize/flame-detection-system/4740a3ec7f28886b8ed0adc456a746f2df378d19/FlameDetection/FlameDetection.1 -------------------------------------------------------------------------------- /FlameDetection/FlameDetection.v11.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liberize/flame-detection-system/4740a3ec7f28886b8ed0adc456a746f2df378d19/FlameDetection/FlameDetection.v11.suo -------------------------------------------------------------------------------- /FlameDetection/FlameDetector.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // FlameDetector.cpp 3 | // FlameDetection 4 | // 5 | // Created by liberize on 14-4-5. 6 | // Copyright (c) 2014年 liberize. All rights reserved. 7 | // 8 | 9 | #include "FlameDetector.h" 10 | 11 | FlameDetector::FlameDetector() 12 | : mFrameCount(0) 13 | , mFlameCount(0) 14 | , mTrack(false) 15 | { 16 | } 17 | 18 | bool FlameDetector::detect(const Mat& frame) 19 | { 20 | mFrame = frame; 21 | 22 | clock_t start, finish; 23 | if(++mFrameCount > SKIP_FRAME_COUNT) { 24 | mTrack = true; 25 | start = clock(); 26 | } 27 | 28 | mExtractor.extract(mFrame, mTargetMap, mTrack); 29 | if (mTrack) { 30 | mAnalyzer.analyze(mFrame, mTargetMap); 31 | bool result = mDecider.decide(mFrame, mTargetMap); 32 | finish = clock(); 33 | cout << "duration: " << 1.0 * (finish - start) / CLOCKS_PER_SEC << endl; 34 | if (result) { 35 | mFlameCount++; 36 | } 37 | cout << "frame: " << (mFrameCount - SKIP_FRAME_COUNT) << ", flame: " << mFlameCount << endl; 38 | cout << "detection rate: " << 1.0 * mFlameCount / (mFrameCount - SKIP_FRAME_COUNT) << endl; 39 | return result; 40 | } 41 | 42 | return false; 43 | } 44 | -------------------------------------------------------------------------------- /FlameDetection/FlameDetector.h: -------------------------------------------------------------------------------- 1 | // 2 | // FlameDetector.h 3 | // FlameDetection 4 | // 5 | // Created by liberize on 14-4-5. 6 | // Copyright (c) 2014年 liberize. All rights reserved. 7 | // 8 | 9 | #ifndef __FlameDetection__FlameDetector__ 10 | #define __FlameDetection__FlameDetector__ 11 | 12 | #include "common.h" 13 | #include "TargetExtractor.h" 14 | #include "FeatureAnalyzer.h" 15 | #include "FlameDecider.h" 16 | 17 | 18 | struct Target { 19 | static const int TARGET_EXISTING = 0; 20 | static const int TARGET_NEW = 1; 21 | static const int TARGET_LOST = 2; 22 | static const int TARGET_MERGED = 3; 23 | 24 | int type; 25 | int times; 26 | int lostTimes; 27 | vector mergeSrc; 28 | Region region; 29 | Feature feature; 30 | bool isFlame; 31 | }; 32 | 33 | 34 | class FlameDetector { 35 | private: 36 | static const int SKIP_FRAME_COUNT = 20; 37 | 38 | Mat mFrame; 39 | TargetExtractor mExtractor; 40 | FeatureAnalyzer mAnalyzer; 41 | FlameDecider mDecider; 42 | map mTargetMap; 43 | int mFrameCount; 44 | int mFlameCount; 45 | bool mTrack; 46 | 47 | public: 48 | FlameDetector(); 49 | 50 | const TargetExtractor& getExtractor() const { return mExtractor; } 51 | const FeatureAnalyzer& getAnalyzer() const { return mAnalyzer; } 52 | const FlameDecider& getDecider() const { return mDecider; } 53 | bool detect(const Mat& frame); 54 | }; 55 | 56 | #endif /* defined(__FlameDetection__FlameDetector__) */ 57 | -------------------------------------------------------------------------------- /FlameDetection/TargetExtractor.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // TargetExtractor.cpp 3 | // FlameDetection 4 | // 5 | // Created by liberize on 14-4-11. 6 | // Copyright (c) 2014年 liberize. All rights reserved. 7 | // 8 | 9 | #include "TargetExtractor.h" 10 | #include "FlameDetector.h" 11 | 12 | /**************** Rectangle ****************/ 13 | 14 | Rectangle::Rectangle() 15 | { 16 | } 17 | 18 | Rectangle::Rectangle(const Rect& r) 19 | : Rect(r) 20 | { 21 | } 22 | 23 | inline bool Rectangle::near(const Rectangle& r) 24 | { 25 | return abs((x + width / 2.0) - (r.x + r.width / 2.0)) - (width + r.width) / 2.0 < 26 | max(width, r.width) * 0.2 && 27 | abs((y + height / 2.0) - (r.y + r.height / 2.0)) - (height + r.height) / 2.0 < 28 | max(height, r.height) * 0.2; 29 | } 30 | 31 | inline void Rectangle::merge(const Rectangle& r) 32 | { 33 | int tx = min(x, r.x); 34 | int ty = min(y, r.y); 35 | width = max(x + width, r.x + r.width) - tx; 36 | height = max(y + height, r.y + r.height) - ty; 37 | x = tx; 38 | y = ty; 39 | } 40 | 41 | /**************** Region ****************/ 42 | 43 | Region::Region() 44 | { 45 | } 46 | 47 | Region::Region(ContourInfo* contour, const Rectangle& rect) 48 | : contours(1, contour) 49 | , rect(rect) 50 | { 51 | } 52 | 53 | Region::Region(const vector& contours, const Rectangle& rect) 54 | : contours(contours) 55 | , rect(rect) 56 | { 57 | } 58 | 59 | inline bool Region::near(const Region& r) 60 | { 61 | return rect.near(r.rect); 62 | } 63 | 64 | void Region::merge(const Region& r) 65 | { 66 | rect.merge(r.rect); 67 | for (vector::const_iterator it = r.contours.begin(); it != r.contours.end(); it++) { 68 | contours.push_back(*it); 69 | } 70 | } 71 | 72 | /**************** TargetExtractor ****************/ 73 | 74 | TargetExtractor::TargetExtractor() 75 | { 76 | mMOG.set("detectShadows", false); 77 | } 78 | 79 | #ifdef OLD_ALGO 80 | void TargetExtractor::movementDetect2(int threshold, double learningRate) 81 | { 82 | Mat gray, temp, background; 83 | 84 | cvtColor(mFrame, gray, CV_BGR2GRAY); 85 | if (mBackground.empty()) { 86 | gray.convertTo(mBackground, CV_64F); 87 | } 88 | mBackground.convertTo(background, CV_8U); 89 | absdiff(background, gray, mMask); 90 | cv::threshold(mMask, mMask, threshold, 255, THRESH_BINARY); 91 | 92 | bitwise_not(mMask, temp); 93 | accumulateWeighted(gray, mBackground, learningRate, temp); 94 | } 95 | 96 | void TargetExtractor::colorDetect2(int threshold) 97 | { 98 | Mat temp; 99 | GaussianBlur(mFrame, temp, Size(3, 3), 0); 100 | cvtColor(temp, temp, CV_BGR2YCrCb); 101 | 102 | Vec4d mean = sum(temp) / (temp.rows * temp.cols); 103 | for (int i = 0; i < temp.rows; i++) { 104 | for (int j = 0; j < temp.cols; j++) { 105 | if (mMask.at(i, j) == 255) { 106 | Vec3b& v = temp.at(i, j); 107 | if (!(v[0] > v[2] && v[1] > v[2] && v[0] > mean[0] && v[2] < mean[2] && 108 | v[1] > mean[1] && abs(v[2] - v[1]) >= threshold)) { 109 | mMask.at(i, j) = 0; 110 | } 111 | } 112 | } 113 | } 114 | } 115 | 116 | void TargetExtractor::regionGrow2(int areaThreshold, int diffThreshold) 117 | { 118 | Mat gray; 119 | cvtColor(mFrame, gray, CV_BGR2GRAY); 120 | 121 | Mat temp; 122 | mMask.copyTo(temp); 123 | 124 | vector > contours; 125 | findContours(temp, contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_SIMPLE); 126 | 127 | int maxStackSize = gray.rows * gray.cols / 4; 128 | static int direction[8][2] = { 129 | { 0, 1 }, { 1, 1 }, { 1, 0 }, { 1, -1 }, 130 | { 0, -1 }, { -1, -1 }, { -1, 0 }, { -1, 1 } 131 | }; 132 | 133 | for (int i = 0; i < contours.size(); i++) { 134 | if (contourArea(contours[i]) < areaThreshold) { 135 | drawContours(mMask, contours, i, Scalar(0), CV_FILLED); 136 | continue; 137 | } 138 | 139 | // TODO: 修改种子选取方法 140 | Moments mu = moments(contours[i], false); 141 | Point seed(cvRound(mu.m10 / mu.m00), cvRound(mu.m01 / mu.m00)); 142 | if (pointPolygonTest(contours[i], seed, false) < 0) { 143 | cout << "Seed not in contour!" << endl; 144 | continue; 145 | } 146 | 147 | stack pointStack; 148 | temp.at(seed) = 255; 149 | pointStack.push(seed); 150 | 151 | Mat temp = Mat::zeros(mMask.size(), mMask.type()); 152 | uchar seedPixel = gray.at(seed); 153 | Point cur, pop; 154 | 155 | while (!pointStack.empty() && pointStack.size() < maxStackSize) { 156 | 157 | pop = pointStack.top(); 158 | pointStack.pop(); 159 | 160 | for (int k = 0; k < 8; k++) { 161 | cur.x = pop.x + direction[k][0]; 162 | cur.y = pop.y + direction[k][1]; 163 | 164 | if (cur.x < 0 || cur.x > gray.cols - 1 || cur.y < 0 || cur.y > gray.rows - 1) { 165 | continue; 166 | } 167 | 168 | if (temp.at(cur) != 255) { 169 | uchar curPixel = gray.at(cur); 170 | 171 | if (abs(curPixel - seedPixel) < diffThreshold) { 172 | temp.at(cur) = 255; 173 | pointStack.push(cur); 174 | } 175 | } 176 | } 177 | } 178 | if (pointStack.empty()) { 179 | bitwise_or(mMask, temp, mMask); 180 | } 181 | } 182 | } 183 | #endif 184 | 185 | void TargetExtractor::movementDetect(double learningRate) 186 | { 187 | mMOG(mFrame, mMask, learningRate); 188 | mMOG.getBackgroundImage(mBackground); 189 | } 190 | 191 | void TargetExtractor::colorDetect(int redThreshold, double saturationThreshold) 192 | { 193 | Mat temp; 194 | GaussianBlur(mFrame, temp, Size(3, 3), 0); 195 | 196 | for (int i = 0; i < temp.rows; i++) { 197 | for (int j = 0; j < temp.cols; j++) { 198 | if (mMask.at(i, j) == 255) { 199 | Vec3b& v = temp.at(i, j); 200 | double s = 1 - 3.0 * min(v[0], min(v[1], v[2])) / (v[0] + v[1] + v[2]); 201 | if (!(v[2] > redThreshold && v[2] >= v[1] && v[1] > v[0] && 202 | s >= ((255 - v[2]) * saturationThreshold / redThreshold))) { 203 | mMask.at(i, j) = 0; 204 | } 205 | } 206 | } 207 | } 208 | } 209 | 210 | void TargetExtractor::denoise(int ksize, int threshold) 211 | { 212 | int r = (ksize - 1) / 2; 213 | if (r <= 0) { 214 | return; 215 | } 216 | 217 | Mat density; 218 | calcDensity(mMask, density, ksize); 219 | 220 | for (int i = r; i < mMask.rows - r; i++) { 221 | for (int j = r; j < mMask.cols - r; j++) { 222 | int count = density.at(i, j); 223 | if (count < threshold) { 224 | mMask.at(i, j) = 0; 225 | } 226 | } 227 | } 228 | } 229 | 230 | void TargetExtractor::fill(int ksize, int threshold) 231 | { 232 | int r = (ksize - 1) / 2; 233 | if (r <= 0) { 234 | return; 235 | } 236 | 237 | Mat density; 238 | calcDensity(mMask, density, ksize); 239 | 240 | double half = ksize / 2.0, dist = ksize / 5.0; 241 | int max = ksize * ksize * 9 / 10; 242 | 243 | for (int i = r; i < mMask.rows - r; i++) { 244 | for (int j = r; j < mMask.cols - r; j++) { 245 | int count = density.at(i, j); 246 | if (count > max) { 247 | mMask.at(i, j) = 255; 248 | } else if (count >= threshold) { 249 | // TODO: further optimize the mass-center calculation 250 | Point center; 251 | Rect rect(j - r, i - r, ksize, ksize); 252 | getMassCenter(mMask(rect), center); 253 | if (abs(center.x - half) < dist && abs(center.y - half) < dist) { 254 | mMask.at(i, j) = 255; 255 | } 256 | } 257 | } 258 | } 259 | } 260 | 261 | void TargetExtractor::regionGrow(int threshold) 262 | { 263 | Mat gray; 264 | cvtColor(mFrame, gray, CV_BGR2GRAY); 265 | 266 | Mat temp; 267 | mMask.copyTo(temp); 268 | 269 | vector > contours; 270 | findContours(temp, contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE); 271 | 272 | int maxQueueSize = mFrame.rows * mFrame.cols / 4; 273 | static int direction[8][2] = { 274 | { 0, 1 }, { 1, 1 }, { 1, 0 }, { 1, -1 }, 275 | { 0, -1 }, { -1, -1 }, { -1, 0 }, { -1, 1 } 276 | }; 277 | 278 | for (int i = 0; i < contours.size(); i++) { 279 | Rect rect = boundingRect(Mat(contours[i])); 280 | Mat mask = Mat::zeros(gray.size(), CV_8U); 281 | drawContours(mask, contours, i, Scalar::all(255), CV_FILLED); 282 | int size = sum(mask(rect))[0] / 255; 283 | Scalar m, s; 284 | meanStdDev(gray(rect), m, s, mask(rect)); 285 | double mean = m[0], stdDev = s[0]; 286 | 287 | Mat temp; 288 | mMask.copyTo(temp); 289 | int origSize = size; 290 | 291 | queue pointQueue; 292 | for (int j = 0; j < contours[i].size(); j++) { 293 | uchar pixel = gray.at(contours[i][j]); 294 | if (abs(pixel - mean) < 1.0 * stdDev) { 295 | pointQueue.push(contours[i][j]); 296 | } 297 | } 298 | 299 | Point cur, pop; 300 | while (!pointQueue.empty() && pointQueue.size() < maxQueueSize) { 301 | 302 | pop = pointQueue.front(); 303 | pointQueue.pop(); 304 | uchar pixel = gray.at(pop); 305 | 306 | for (int k = 0; k < 8; k++) { 307 | cur.x = pop.x + direction[k][0]; 308 | cur.y = pop.y + direction[k][1]; 309 | 310 | if (cur.x < 0 || cur.x > gray.cols - 1 || cur.y < 0 || cur.y > gray.rows - 1) { 311 | continue; 312 | } 313 | 314 | if (temp.at(cur) != 255) { 315 | uchar curPixel = gray.at(cur); 316 | 317 | if (abs(curPixel - pixel) < threshold && 318 | abs(curPixel - mean) < 1.0 * stdDev) { 319 | 320 | temp.at(cur) = 255; 321 | 322 | double diff = curPixel - mean; 323 | double learningRate = 1.0 / (++size); 324 | mean = (1 - learningRate) * mean + learningRate * curPixel; 325 | stdDev = sqrt((1 - learningRate) * stdDev * stdDev + learningRate * diff * diff); 326 | 327 | pointQueue.push(cur); 328 | } 329 | } 330 | } 331 | } 332 | 333 | if (pointQueue.empty()) { 334 | int incSize = size - origSize; 335 | if (incSize < mFrame.rows * mFrame.cols / 6 && incSize / origSize < 5) { 336 | mMask = temp; 337 | } 338 | } 339 | } 340 | } 341 | 342 | void TargetExtractor::smallAreaFilter(int threshold, int keep) 343 | { 344 | vector > contours; 345 | // this will change mMask, but it doesn't matter 346 | findContours(mMask, contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_SIMPLE); 347 | 348 | vector indexes; 349 | vector areas; 350 | vector boundRects; 351 | 352 | for (int i = 0; i < contours.size(); i++) { 353 | double area = contourArea(contours[i]); 354 | if (area < threshold) { 355 | continue; 356 | } 357 | 358 | Rect rect = boundingRect(Mat(contours[i])); 359 | if (rect.width < 0.01 * mMask.cols && rect.height < 0.01 * mMask.rows) { 360 | continue; 361 | } 362 | 363 | indexes.push_back(i); 364 | areas.push_back(area); 365 | boundRects.push_back(rect); 366 | } 367 | 368 | mMask = Mat::zeros(mMask.size(), mMask.type()); 369 | vector().swap(mContours); 370 | 371 | if (areas.size() == 0) { 372 | return; 373 | } 374 | 375 | while (keep > 0) { 376 | vector::iterator it = max_element(areas.begin(), areas.end()); 377 | if (*it == 0) { 378 | break; 379 | } 380 | 381 | vector::difference_type offset = it - areas.begin(); 382 | int index = indexes[offset]; 383 | drawContours(mMask, contours, index, Scalar::all(255), CV_FILLED); 384 | 385 | // use 'resize' and 'swap' to avoid copy of contours 386 | vector::size_type size = mContours.size(); 387 | mContours.resize(size + 1); 388 | mContours[size].contour.swap(contours[index]); 389 | mContours[size].area = areas[offset]; 390 | mContours[size].boundRect = boundRects[offset]; 391 | 392 | *it = 0; 393 | keep--; 394 | } 395 | } 396 | 397 | void TargetExtractor::accumulate(int threshold) 398 | { 399 | if (mMaskSum.empty()) { 400 | mMaskSum = Mat::zeros(mMask.size(), CV_8U); 401 | } 402 | 403 | for (int i = 0; i < mMask.rows; i++) { 404 | for (int j = 0; j < mMask.cols; j++) { 405 | if (mMask.at(i, j) == 255) { 406 | mMaskSum.at(i, j)++; 407 | } 408 | } 409 | } 410 | 411 | Mat temp; 412 | mMask.copyTo(temp); 413 | 414 | mMaskQueue.push(temp); 415 | if (mMaskQueue.size() > MAX_MASK_QUEUE_SIZE) { 416 | Mat pop = mMaskQueue.front(); 417 | mMaskQueue.pop(); 418 | for (int i = 0; i < mMask.rows; i++) { 419 | for (int j = 0; j < mMask.cols; j++) { 420 | if (pop.at(i, j) == 255) { 421 | assert(mMaskSum.at(i, j) != 0); 422 | mMaskSum.at(i, j)--; 423 | } 424 | } 425 | } 426 | } 427 | 428 | if (mMaskQueue.size() == MAX_MASK_QUEUE_SIZE) { 429 | Mat result = Mat::zeros(mMask.size(), mMask.type()); 430 | for (int i = 0; i < mMask.rows; i++) { 431 | for (int j = 0; j < mMask.cols; j++) { 432 | if (mMaskSum.at(i, j) >= threshold) { 433 | result.at(i, j) = 255; 434 | } 435 | } 436 | } 437 | imshow("accumulated", result); 438 | } 439 | } 440 | 441 | void TargetExtractor::blobTrack(map& targets) 442 | { 443 | list regions; 444 | for (vector::iterator it = mContours.begin(); it != mContours.end(); it++) { 445 | regions.push_back(Region(&(*it), it->boundRect)); 446 | } 447 | 448 | list::size_type lastRegionsSize; 449 | do { 450 | lastRegionsSize = regions.size(); 451 | for (list::iterator it1 = regions.begin(); it1 != regions.end(); it1++) { 452 | list::iterator it2 = it1; 453 | for (it2++; it2 != regions.end(); ) { 454 | if (it1->near(*it2)) { 455 | it1->merge(*it2); 456 | regions.erase(it2++); 457 | } else { 458 | it2++; 459 | } 460 | } 461 | } 462 | } while (regions.size() != lastRegionsSize); 463 | 464 | srand((unsigned)clock()); 465 | 466 | if (targets.empty()) { 467 | int id; 468 | for (list::iterator it = regions.begin(); it != regions.end(); it++) { 469 | while (id = rand(), targets.find(id) != targets.end()); 470 | targets[id] = Target(); 471 | targets[id].type = Target::TARGET_NEW; 472 | targets[id].region = *it; 473 | targets[id].times++; 474 | } 475 | return; 476 | } 477 | 478 | list rects; 479 | map targetRects; 480 | for (list::iterator it = regions.begin(); it != regions.end(); it++) { 481 | rects.push_back(it->rect); 482 | } 483 | for (map::iterator it = targets.begin(); it != targets.end(); it++) { 484 | rects.push_back(it->second.region.rect); 485 | targetRects[it->first] = it->second.region.rect; 486 | } 487 | 488 | list::size_type lastRectsSize; 489 | do { 490 | lastRectsSize = rects.size(); 491 | for (list::iterator it1 = rects.begin(); it1 != rects.end(); it1++) { 492 | list::iterator it2 = it1; 493 | for (it2++; it2 != rects.end(); ) { 494 | if (it1->near(*it2)) { 495 | it1->merge(*it2); 496 | rects.erase(it2++); 497 | } else { 498 | it2++; 499 | } 500 | } 501 | } 502 | } while (rects.size() != lastRectsSize); 503 | 504 | for (list::iterator it1 = rects.begin(); it1 != rects.end(); it1++) { 505 | vector vi; 506 | vector::iterator> vlit; 507 | for (map::iterator it2 = targetRects.begin(); it2 != targetRects.end(); it2++) { 508 | if (it1->contains(it2->second.tl())) { 509 | vi.push_back(it2->first); 510 | } 511 | } 512 | for (list::iterator it2 = regions.begin(); it2 != regions.end(); it2++) { 513 | if (it1->contains(it2->rect.tl())) { 514 | vlit.push_back(it2); 515 | } 516 | } 517 | int id; 518 | if (vlit.size() == 0) { 519 | assert(vi.size() == 1); 520 | id = vi[0]; 521 | targets[id].type = Target::TARGET_LOST; 522 | targets[id].lostTimes++; 523 | } else if (vi.size() == 0) { 524 | assert(vlit.size() == 1); 525 | while (id = rand(), targets.find(id) != targets.end()); 526 | targets[id] = Target(); 527 | targets[id].type = Target::TARGET_NEW; 528 | targets[id].region = *(vlit[0]); 529 | targets[id].times++; 530 | } else { 531 | Region r(*(vlit[0])); 532 | vector::iterator>::iterator it3 = vlit.begin(); 533 | for (it3++; it3 != vlit.end(); it3++) { 534 | r.merge(**it3); 535 | } 536 | if (vi.size() == 1) { 537 | id = vi[0]; 538 | targets[id].type = Target::TARGET_EXISTING; 539 | targets[id].region = r; 540 | targets[id].times++; 541 | } else { 542 | while (id = rand(), targets.find(id) != targets.end()); 543 | targets[id] = Target(); 544 | targets[id].type = Target::TARGET_MERGED; 545 | targets[id].region = r; 546 | int times = 0; 547 | for (vector::iterator it4 = vi.begin(); it4 != vi.end(); it4++) { 548 | targets[id].mergeSrc.push_back(*it4); 549 | if (targets[*it4].times > times) { 550 | times = targets[*it4].times; 551 | } 552 | } 553 | targets[id].times = times; 554 | } 555 | } 556 | } 557 | } 558 | 559 | void TargetExtractor::extract(const Mat& frame, map& targets, bool track) 560 | { 561 | mFrame = frame; 562 | 563 | /* for 2.avi: 564 | * movement: 0.008; 565 | * color: 120, 0.2; 566 | * regionGrow: enable; 567 | * for 6.avi: 568 | * movement: 0.012; 569 | * color: 150, 0.4; 570 | * regionGrow: disable; 571 | */ 572 | 573 | movementDetect(0.012); 574 | colorDetect(150, 0.4); 575 | 576 | denoise(7, 5); 577 | fill(7, 5); 578 | medianBlur(mMask, mMask, 3); 579 | 580 | // TODO: make use of accumulate result 581 | 582 | //regionGrow(); 583 | //fill(7, 6); 584 | //medianBlur(mMask, mMask, 3); 585 | 586 | //Mat element = getStructuringElement(MORPH_CROSS, Size(3, 3)); 587 | //erode(mMask, mMask, element); 588 | //dilate(mMask, mMask, element); 589 | 590 | smallAreaFilter(12, 8); 591 | 592 | namedWindow("mask"); 593 | moveWindow("mask", 350, 120); 594 | imshow("mask", mMask); 595 | 596 | if (track) { 597 | blobTrack(targets); 598 | } 599 | } 600 | -------------------------------------------------------------------------------- /FlameDetection/TargetExtractor.h: -------------------------------------------------------------------------------- 1 | // 2 | // TargetExtractor.h 3 | // FlameDetection 4 | // 5 | // Created by liberize on 14-4-11. 6 | // Copyright (c) 2014年 liberize. All rights reserved. 7 | // 8 | 9 | #ifndef __FlameDetection__TargetExtractor__ 10 | #define __FlameDetection__TargetExtractor__ 11 | 12 | #include "common.h" 13 | #include "utils.h" 14 | 15 | struct Target; 16 | 17 | 18 | struct ContourInfo { 19 | vector contour; 20 | double area; 21 | Rect boundRect; 22 | }; 23 | 24 | 25 | class Rectangle : public Rect { 26 | public: 27 | Rectangle(); 28 | Rectangle(const Rect& r); 29 | 30 | bool near(const Rectangle& r); 31 | void merge(const Rectangle& r); 32 | }; 33 | 34 | 35 | class Region { 36 | public: 37 | vector contours; 38 | Rectangle rect; 39 | 40 | Region(); 41 | Region(ContourInfo* contour, const Rectangle& rect); 42 | Region(const vector& contours, const Rectangle& rect); 43 | bool near(const Region& r); 44 | void merge(const Region& r); 45 | }; 46 | 47 | 48 | class TargetExtractor { 49 | private: 50 | static const int MAX_MASK_QUEUE_SIZE = 10; 51 | 52 | Mat mFrame; 53 | Mat mMask; 54 | queue mMaskQueue; 55 | Mat mMaskSum; 56 | vector mContours; 57 | 58 | Mat mBackground; 59 | BackgroundSubtractorMOG2 mMOG; 60 | 61 | #ifdef OLD_ALGO 62 | void movementDetect2(int threshold = 30, double learningRate = 0.01); 63 | void colorDetect2(int threshold = 20); 64 | void regionGrow2(int areaThreshold, int diffThreshold); 65 | #endif 66 | 67 | void movementDetect(double learningRate = -1); 68 | void colorDetect(int redThreshold = 150, double saturationThreshold = 0.4); 69 | void denoise(int ksize = 7, int threshold = 6); 70 | void fill(int ksize = 7, int threshold = 6); 71 | void regionGrow(int threshold = 20); 72 | void smallAreaFilter(int threshold = 10, int keep = 5); 73 | void accumulate(int threshold = 5); 74 | void blobTrack(map& targets); 75 | 76 | public: 77 | TargetExtractor(); 78 | const Mat& getMask() const { return mMask; } 79 | void extract(const Mat& frame, map& targets, bool track); 80 | }; 81 | 82 | #endif /* defined(__FlameDetection__TargetExtractor__) */ 83 | -------------------------------------------------------------------------------- /FlameDetection/VideoHandler.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // VideoHandler.cpp 3 | // FlameDetection 4 | // 5 | // Created by liberize on 14-4-6. 6 | // Copyright (c) 2014年 liberize. All rights reserved. 7 | // 8 | 9 | #include "VideoHandler.h" 10 | 11 | VideoHandler::VideoHandler(int device, bool saveKeyFrame, bool saveVideo) 12 | : mCapture(device) 13 | , mSaveKeyFrame(saveKeyFrame) 14 | , mSaveVideo(saveVideo) 15 | , mFromCam(true) 16 | , mVideoFPS(0) 17 | { 18 | if (mCapture.isOpened()) { 19 | mVideoFPS = mCapture.get(CV_CAP_PROP_FPS); 20 | if (mVideoFPS == 0) { 21 | mVideoFPS = 8.0; 22 | } 23 | } 24 | } 25 | 26 | VideoHandler::VideoHandler(const string& file, bool saveKeyFrame) 27 | : mCapture(file) 28 | , mSaveKeyFrame(saveKeyFrame) 29 | , mFromCam(false) 30 | , mVideoFPS(0) 31 | { 32 | if (mCapture.isOpened()) { 33 | mVideoFPS = mCapture.get(CV_CAP_PROP_FPS); 34 | assert(mVideoFPS != 0); 35 | } 36 | } 37 | 38 | int VideoHandler::handle() 39 | { 40 | if (!mCapture.isOpened()) { 41 | return STATUS_OPEN_CAP_FAILED; 42 | } 43 | 44 | bool continueToDetect = true; 45 | int extraFrameCount = 0; 46 | 47 | while (true) { 48 | if (!mCapture.read(mFrame)) { 49 | cout << (mFromCam ? "Camera disconnected." : "Video file ended.") << endl; 50 | break; 51 | } 52 | 53 | namedWindow("original"); 54 | moveWindow("original", 10, 120); 55 | imshow("original", mFrame); 56 | 57 | if (mSaveVideo && !saveVideo()) { 58 | cout << "Save video failed." << endl; 59 | mSaveVideo = false; 60 | } 61 | 62 | if (continueToDetect) { 63 | if (mDetector.detect(mFrame)) { 64 | if (mSaveKeyFrame && !saveFrame()) { 65 | cout << "Save key frame failed." << endl; 66 | } 67 | if (mSaveVideo) { 68 | continueToDetect = false; 69 | continue; 70 | } 71 | cout << "Flame detected." << endl; 72 | //return STATUS_FLAME_DETECTED; 73 | } 74 | } else if (++extraFrameCount >= MAX_EXTRA_FRAME_COUNT) { 75 | return STATUS_FLAME_DETECTED; 76 | } 77 | 78 | #ifdef TRAIN_MODE 79 | if (trainComplete) { 80 | cout << "Train complete." << endl; 81 | break; 82 | } 83 | #endif 84 | if (waitKey(WAIT_INTERVAL) == 27) { 85 | cout << "User abort." << endl; 86 | break; 87 | } 88 | } 89 | 90 | return STATUS_NO_FLAME_DETECTED; 91 | } 92 | 93 | bool VideoHandler::saveFrame() 94 | { 95 | string fileName; 96 | getCurTime(fileName); 97 | fileName += ".jpg"; 98 | cout << "Saving key frame to '" << fileName << "'." << endl; 99 | 100 | return imwrite(fileName, mFrame); 101 | } 102 | 103 | bool VideoHandler::saveVideo() 104 | { 105 | if (mSaveVideoFile.empty()) { 106 | getCurTime(mSaveVideoFile); 107 | mSaveVideoFile += ".mov"; 108 | cout << "Saving video to '" << mSaveVideoFile << "'." << endl; 109 | 110 | // in Mac OS X, only 'mp4v' is supported 111 | int fourcc = CV_FOURCC('m', 'p', '4', 'v'); 112 | Size size = Size((int)mCapture.get(CV_CAP_PROP_FRAME_WIDTH), 113 | (int)mCapture.get(CV_CAP_PROP_FRAME_HEIGHT)); 114 | 115 | mWriter.open(mSaveVideoFile, fourcc, mVideoFPS, size, true); 116 | } 117 | 118 | if (!mWriter.isOpened()) { 119 | return false; 120 | } 121 | 122 | mWriter << mFrame; 123 | return true; 124 | } 125 | -------------------------------------------------------------------------------- /FlameDetection/VideoHandler.h: -------------------------------------------------------------------------------- 1 | // 2 | // VideoHandler.h 3 | // FlameDetection 4 | // 5 | // Created by liberize on 14-4-6. 6 | // Copyright (c) 2014年 liberize. All rights reserved. 7 | // 8 | 9 | #ifndef __FlameDetection__VideoHandler__ 10 | #define __FlameDetection__VideoHandler__ 11 | 12 | #include "common.h" 13 | #include "utils.h" 14 | #include "FlameDetector.h" 15 | 16 | 17 | class VideoHandler { 18 | private: 19 | static const int WAIT_INTERVAL = 30; 20 | static const int MAX_EXTRA_FRAME_COUNT = 80; 21 | 22 | VideoCapture mCapture; 23 | FlameDetector mDetector; 24 | Mat mFrame; 25 | bool mFromCam; 26 | bool mSaveVideo; 27 | bool mSaveKeyFrame; 28 | double mVideoFPS; 29 | string mSaveVideoFile; 30 | VideoWriter mWriter; 31 | 32 | bool saveFrame(); 33 | bool saveVideo(); 34 | 35 | public: 36 | static const int STATUS_FLAME_DETECTED = 0; 37 | static const int STATUS_OPEN_CAP_FAILED = 1; 38 | static const int STATUS_NO_FLAME_DETECTED = 2; 39 | 40 | VideoHandler(int device, bool saveKeyFrame = false, bool saveVideo = false); 41 | VideoHandler(const string& file, bool saveKeyFrame = false); 42 | 43 | const FlameDetector& getDetector() const { return mDetector; } 44 | double getVideoFPS() const { return mVideoFPS; } 45 | int handle(); 46 | }; 47 | 48 | #endif /* defined(__FlameDetection__VideoHandler__) */ 49 | -------------------------------------------------------------------------------- /FlameDetection/common.h: -------------------------------------------------------------------------------- 1 | // 2 | // common.h 3 | // FlameDetection 4 | // 5 | // Created by liberize on 14-4-5. 6 | // Copyright (c) 2014年 liberize. All rights reserved. 7 | // 8 | 9 | #ifndef FlameDetection_common_h 10 | #define FlameDetection_common_h 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | using namespace std; 29 | using namespace cv; 30 | 31 | //#define OLD_ALGO 32 | #define TRAIN_MODE 33 | //#define DEBUG_OUTPUT 34 | 35 | #ifdef TRAIN_MODE 36 | extern bool trainComplete; 37 | #endif 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /FlameDetection/main.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // main.cpp 3 | // FlameDetection 4 | // 5 | // Created by liberize on 14-4-4. 6 | // Copyright (c) 2014年 liberize. All rights reserved. 7 | // 8 | 9 | #include "common.h" 10 | #include "VideoHandler.h" 11 | #include "FlameDetector.h" 12 | 13 | #ifdef TRAIN_MODE 14 | bool trainComplete = false; 15 | #endif 16 | 17 | VideoHandler* videoHandler = NULL; 18 | 19 | int main(int argc, const char* argv[]) 20 | { 21 | VideoHandler handler("clips/6.avi"); 22 | videoHandler = &handler; 23 | 24 | int ret = handler.handle(); 25 | 26 | switch (ret) { 27 | case VideoHandler::STATUS_FLAME_DETECTED: 28 | cout << "Flame detected." << endl; 29 | break; 30 | case VideoHandler::STATUS_OPEN_CAP_FAILED: 31 | cout << "Open capture failed." << endl; 32 | break; 33 | case VideoHandler::STATUS_NO_FLAME_DETECTED: 34 | cout << "No flame detected." << endl; 35 | break; 36 | default: 37 | break; 38 | } 39 | 40 | return 0; 41 | } 42 | -------------------------------------------------------------------------------- /FlameDetection/utils.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // utils.cpp 3 | // FlameDetection 4 | // 5 | // Created by liberize on 14-5-19. 6 | // Copyright (c) 2014年 liberize. All rights reserved. 7 | // 8 | 9 | #include "utils.h" 10 | 11 | void getCurTime(string& curTime) 12 | { 13 | time_t rawtime; 14 | struct tm* timeinfo; 15 | time(&rawtime); 16 | timeinfo = localtime(&rawtime); 17 | 18 | char buffer[128]; 19 | strftime(buffer, 128, "%m-%d_%H-%M-%S", timeinfo); 20 | 21 | curTime = buffer; 22 | } 23 | 24 | // this function is an alternative to the old one which is implemented with 'sum' 25 | void calcDensity(const Mat& mask, Mat& density, int ksize) 26 | { 27 | int r = (ksize - 1) / 2; 28 | if (r <= 0) { 29 | return; 30 | } 31 | 32 | density = Mat::zeros(mask.size(), CV_32SC1); 33 | 34 | int rowBound = density.rows - r, colBound = density.cols - r; 35 | 36 | Rect rect(0, 0, ksize, ksize); 37 | density.at(r, r) = cvRound(sum(mask(rect))[0] / 255); 38 | 39 | for (int j = r + 1; j < colBound; j++) { 40 | int col1 = j - r - 1, col2 = j + r; 41 | int delta = 0; 42 | for (int k = 0; k < ksize; k++) { 43 | delta += mask.at(k, col2) - mask.at(k, col1); 44 | } 45 | density.at(r, j) = density.at(r, j - 1) + delta / 255; 46 | } 47 | 48 | for (int i = r + 1; i < rowBound; i++) { 49 | int row1 = i - r - 1, row2 = i + r; 50 | int delta = 0; 51 | for (int k = 0; k < ksize; k++) { 52 | delta += mask.at(row2, k) - mask.at(row1, k); 53 | } 54 | density.at(i, r) = density.at(i - 1, r) + delta / 255; 55 | } 56 | 57 | for (int i = r + 1; i < rowBound; i++) { 58 | for (int j = r + 1; j < colBound; j++) { 59 | int delta = (mask.at(i + r, j + r) - mask.at(i - r - 1, j + r) - 60 | mask.at(i + r, j - r - 1) + mask.at(i - r - 1, j - r - 1)) / 255; 61 | density.at(i, j) = density.at(i - 1, j) + density.at(i, j - 1) - 62 | density.at(i - 1, j - 1) + delta; 63 | } 64 | } 65 | } 66 | 67 | // this function is also an alternative to the old one which is implemented with 'moments' 68 | void getMassCenter(const Mat& mask, Point& center) 69 | { 70 | int sumX = 0, sumY = 0, count = 0; 71 | for (int i = 0; i < mask.rows; i++) { 72 | for (int j = 0; j < mask.cols; j++) { 73 | if (mask.at(i, j) == 255) { 74 | sumX += j; 75 | sumY += i; 76 | count++; 77 | } 78 | } 79 | } 80 | center.x = sumX / count; 81 | center.y = sumY / count; 82 | } 83 | 84 | void fixRect(const Mat& mask, Rect& rect) 85 | { 86 | Moments mu = moments(mask(rect), true); 87 | double x = mu.m10 / mu.m00; 88 | double y = mu.m01 / mu.m00; 89 | double w = 4 * sqrt(mu.m20 / mu.m00 - x * x); 90 | double h = 4 * sqrt(mu.m02 / mu.m00 - y * y); 91 | rect.x += cvRound(x - w / 2); 92 | rect.y += cvRound(y - h / 2); 93 | rect.width = min(cvRound(w), mask.cols - rect.x); 94 | rect.height = min(cvRound(h), mask.rows - rect.y); 95 | } 96 | -------------------------------------------------------------------------------- /FlameDetection/utils.h: -------------------------------------------------------------------------------- 1 | // 2 | // utils.h 3 | // FlameDetection 4 | // 5 | // Created by liberize on 14-5-19. 6 | // Copyright (c) 2014年 liberize. All rights reserved. 7 | // 8 | 9 | #ifndef __FlameDetection__utils__ 10 | #define __FlameDetection__utils__ 11 | 12 | #include "common.h" 13 | #include 14 | 15 | void getCurTime(string& curTime); 16 | 17 | void calcDensity(const Mat& mask, Mat& density, int ksize = 7); 18 | void getMassCenter(const Mat& mask, Point& center); 19 | void fixRect(const Mat& mask, Rect& rect); 20 | 21 | #endif /* defined(__FlameDetection__utils__) */ 22 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Flame Detection System 2 | 3 | Copyright (c) 2014 liberize 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Flame Detection System 2 | 3 | This project is an imcomplete implemention of a video-based multi-feature flame detection system, and it's my graduation design. 4 | 5 | When I began the study of this subject, I found a lot of articles and very little code on the Internet. So when I finally finished it, I decided to make it open source. 6 | 7 | Note that, this project is not ready for practical application. Due to limited time spent on this project, the code is only partially optimized. However, the response time is totally acceptable when testing on my Mac. 8 | 9 | ## Build Environment 10 | 11 | This project is built with Xcode 5.0.2 on Mac OS X 10.9.3, and it's implemented with OpenCV 2.4.8. 12 | 13 | Because it doesn't use any native interface of a specific platform, it can be easily ported to other platforms, such as windows, linux, android, etc. 14 | 15 | If you want to use the save-video feature, you need to make sure your OpenCV is compiled with FFMPEG support, if not, compile it by yourself. 16 | 17 | ## The Result 18 | 19 | The following two images show the result. 20 | 21 | ![Demo1][Demo1] 22 | ![Demo2][Demo2] 23 | 24 | ## The Process 25 | 26 | First, segment the input image with color detection and motion detection, and extract candidate flame regions. 27 | 28 | 1. Use Gaussian mixture model for background modeling to detect motion pixels. 29 | 2. Use a flame color model based on RGB and HSV color space to detect pixels which have flame-like color. 30 | 3. Take the intersection of the results of the above two steps to get candidate regions. 31 | 4. For the problem of noise and incomplete target, apply serveral denoising and target completion algorithms to the candidate regions. 32 | 5. Divide the candidate region into targets, and use multi-target tracking algorithm to identify the same target in different frames. 33 | 34 | Then, extract some static and dynamic features from the flame. 35 | 36 | 1. Static features are described in three aspects: color, geometry and texture. 37 | 2. Dynamic features are described in two aspects: whole motion and random motion. 38 | 39 | Finally, use a support vector machine for flame recognition, which consists of two parts: training and prediction. 40 | 41 | ## Files and Folders 42 | 43 | * The `FlameDetection` folder contains all the C++ code. 44 | * The `clips` folder contains some video clips for testing, which is mainly downloaded from [here][Video Source]. 45 | * The `samples` folder contains some data samples which can be used as SVM input. 46 | * The `test` folder contains only one script which plot the DFT results with matplotlib. 47 | 48 | ## Performance Testing 49 | 50 | Tested on MacBook Pro MC721CH/A, with processor Intel Core i7 2630QM, clocked at 2GHz, Turbo 2.9GHz and 8GB memory size. 51 | 52 | ### Response Time 53 | 54 | Use `clips/6.avi` to test the response time. 55 | 56 | | Total Frames | Min Process Time | Max Process Time | Average Process Time | 57 | | ------------ | ---------------- | ---------------- | -------------------- | 58 | | 1181 | 0.016595 | 0.032096 | 0.019690 | 59 | 60 | ### Detection Rate 61 | 62 | Use three clips to test the detection rate. 63 | 64 | | Video Files | Total Frames | Detected Frames | Detection Rate | 65 | | ----------- | ------------ | --------------- | -------------- | 66 | | 6.avi | 1181 | 1073 | 0.908552 | 67 | | 2.avi | 419 | 414 | 0.988067 | 68 | | 4.avi | 226 | 226 | 1.000000 | 69 | 70 | ## License 71 | 72 | MIT. 73 | 74 | ## Contact Me 75 | 76 | DO NOT MAIL ME FOR NON-ALGORITHMIC QUESTIONS. 77 | 78 | [Demo1]: https://raw.githubusercontent.com/liberize/flame-detection-system/master/images/2.gif 79 | [Demo2]: https://raw.githubusercontent.com/liberize/flame-detection-system/master/images/6.gif 80 | [Video Source]: http://signal.ee.bilkent.edu.tr/VisiFire/ 81 | -------------------------------------------------------------------------------- /build/Debug/FlameDetection: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liberize/flame-detection-system/4740a3ec7f28886b8ed0adc456a746f2df378d19/build/Debug/FlameDetection -------------------------------------------------------------------------------- /clips/1.avi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liberize/flame-detection-system/4740a3ec7f28886b8ed0adc456a746f2df378d19/clips/1.avi -------------------------------------------------------------------------------- /clips/10.avi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liberize/flame-detection-system/4740a3ec7f28886b8ed0adc456a746f2df378d19/clips/10.avi -------------------------------------------------------------------------------- /clips/11.avi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liberize/flame-detection-system/4740a3ec7f28886b8ed0adc456a746f2df378d19/clips/11.avi -------------------------------------------------------------------------------- /clips/12.avi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liberize/flame-detection-system/4740a3ec7f28886b8ed0adc456a746f2df378d19/clips/12.avi -------------------------------------------------------------------------------- /clips/13.avi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liberize/flame-detection-system/4740a3ec7f28886b8ed0adc456a746f2df378d19/clips/13.avi -------------------------------------------------------------------------------- /clips/14.avi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liberize/flame-detection-system/4740a3ec7f28886b8ed0adc456a746f2df378d19/clips/14.avi -------------------------------------------------------------------------------- /clips/2.avi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liberize/flame-detection-system/4740a3ec7f28886b8ed0adc456a746f2df378d19/clips/2.avi -------------------------------------------------------------------------------- /clips/3.avi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liberize/flame-detection-system/4740a3ec7f28886b8ed0adc456a746f2df378d19/clips/3.avi -------------------------------------------------------------------------------- /clips/4.avi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liberize/flame-detection-system/4740a3ec7f28886b8ed0adc456a746f2df378d19/clips/4.avi -------------------------------------------------------------------------------- /clips/5.avi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liberize/flame-detection-system/4740a3ec7f28886b8ed0adc456a746f2df378d19/clips/5.avi -------------------------------------------------------------------------------- /clips/6.avi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liberize/flame-detection-system/4740a3ec7f28886b8ed0adc456a746f2df378d19/clips/6.avi -------------------------------------------------------------------------------- /clips/7.avi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liberize/flame-detection-system/4740a3ec7f28886b8ed0adc456a746f2df378d19/clips/7.avi -------------------------------------------------------------------------------- /clips/8.avi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liberize/flame-detection-system/4740a3ec7f28886b8ed0adc456a746f2df378d19/clips/8.avi -------------------------------------------------------------------------------- /clips/9.avi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liberize/flame-detection-system/4740a3ec7f28886b8ed0adc456a746f2df378d19/clips/9.avi -------------------------------------------------------------------------------- /images/2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liberize/flame-detection-system/4740a3ec7f28886b8ed0adc456a746f2df378d19/images/2.gif -------------------------------------------------------------------------------- /images/6.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liberize/flame-detection-system/4740a3ec7f28886b8ed0adc456a746f2df378d19/images/6.gif -------------------------------------------------------------------------------- /samples/sample2.txt: -------------------------------------------------------------------------------- 1 | 222.358 19.7769 -0.0469194 2.22559 203.769 17.6278 -0.0214578 0.305047 43.634 12.0841 0.0535901 0.177191 0.204736 0.418293 0.387 0.71512 2.25944 0.00673278 24.6588 0.244382 1 2 | 223.993 23.9725 -0.904108 4.30589 199.411 25.7494 -0.0522108 0.213119 57.0422 18.8062 0.265092 -0.0148913 0.28476 0.546255 0.353956 0.78261 2.3502 0.00499998 34.9202 0.197736 1 3 | 229.063 23.9373 -1.35469 5.79586 204.043 25.1457 0.0394879 0.143746 56.7829 15.6358 0.212932 -0.121938 0.197712 0.454276 0.386888 0.682528 2.34867 0.00503874 27.6701 0.241307 1 4 | 231.79 20.6261 -1.49043 7.95464 209.674 18.8689 -0.0920646 1.46082 47.9354 11.0969 0.151121 -0.042608 0.122681 0.478635 0.348582 0.551847 2.3233 0.00561452 27.1765 0.231632 1 5 | 220.938 23.031 -1.25692 6.00979 200.416 23.7021 -0.136046 0.762925 46.3051 14.6372 0.23153 0.0893953 0.142374 0.442133 0.24852 0.644915 2.30602 0.00555254 31.2399 0.225169 1 6 | 222.97 21.6903 -0.91096 4.86197 201.96 22.2137 -0.0477095 0.423476 47.1612 13.5546 0.182008 0.00644781 0.15419 0.402294 0.502729 0.625205 2.34605 0.0050066 36.8477 0.231264 1 7 | 225.517 20.7964 -0.561113 3.50706 204.5 20.0629 0.114873 0.106026 48.3604 13.6189 0.0279708 -0.0284457 0.216863 0.543869 0.355499 0.679643 2.35817 0.00485827 35.0165 0.199643 1 8 | 221.887 16.9375 -0.387607 2.93282 203.793 15.3526 0.0389375 0.0755551 40.2167 9.10217 0.0151409 -0.0183962 0.226265 0.486687 0.226064 0.886477 1.96977 0.0125448 46.6882 0.118725 1 9 | 209.736 19.611 0.772813 2.93919 197.329 16.5643 0.0713202 0.40958 29.974 14.0219 -0.117519 -0.0834568 0.127487 0.438213 0.412779 0.564713 2.27587 0.00634098 33.737 0.233014 1 10 | 219.085 17.2931 0.169957 2.17946 201.482 13.5686 0.0563787 0.134011 39.9124 12.1346 -0.158055 0.153831 0.14972 0.372521 0.494649 0.611333 2.34496 0.00497554 39.5906 0.188088 1 11 | 214.399 18.2833 0.161675 2.5673 197.375 14.5311 -0.0426767 0.270548 40.656 13.4588 -0.193069 0.116221 0.189406 0.478339 0.569983 0.627654 2.32496 0.00523277 38.6093 0.175968 1 12 | 233.306 17.5499 -0.607392 3.10148 217.2 20.0381 0.164226 -0.107879 42.2118 11.0667 0.109131 0.00682308 0.386769 0.473152 0.525635 0.880829 1.56947 0.0296 53.88 0.171844 1 13 | 207.494 21.0499 0.585211 3.10089 189.689 20.0842 0.0307504 0.213224 50.5618 9.16328 -0.0361551 0.0444886 0.345384 0.455982 0.496821 0.846152 2.35065 0.00493972 29.9042 0.216883 1 14 | 221.611 19.2671 -0.179913 2.21448 204.209 17.6846 0.0773167 0.0157276 41.7607 7.68743 -0.0136652 0.0365758 0.218584 0.385971 0.66163 0.696802 2.1209 0.00850097 37.7982 0.19687 1 15 | 217.327 21.8531 0.119952 2.10251 198.131 20.4607 0.105435 0.118425 49.3567 11.9433 -0.0247471 0.0582321 0.28073 0.550674 0.660776 0.677983 2.37393 0.00450081 40.2071 0.174105 1 16 | 213.229 21.0804 0.446246 2.26457 196.725 18.9814 0.0683547 0.224978 43.6432 10.7989 0.0144167 0.0625758 0.245912 0.471241 0.697426 0.670941 2.36786 0.00463703 29.3205 0.22425 1 17 | 206.422 27.015 0.140909 2.31026 185.057 26.9887 0.0694391 0.12914 60.2692 13.9105 -0.000686008 0.0352958 0.190502 0.51788 0.8707 0.58243 2.39452 0.00417569 36.83 0.19487 1 18 | 216.313 30.7628 -0.47869 2.72952 197.386 33.3978 0.107948 -0.142514 52.4609 21.0218 0.0789549 -0.0145095 0.225354 0.404374 0.386433 0.757355 2.34116 0.00520153 23.5823 0.239387 1 19 | 215.291 29.2801 -0.317659 2.24031 196.098 27.7968 0.142853 -0.00986395 51.4585 15.1078 0.0252103 0.0753514 0.140241 0.434284 0.548257 0.54536 2.3567 0.00480213 26.2808 0.236627 1 20 | 219.256 29.4924 -0.54297 2.80644 198.893 31.0207 0.101106 -0.0111198 56.7541 19.5169 0.0793051 0.0378552 0.190717 0.456385 0.40682 0.674543 2.37861 0.00453863 32.0939 0.222647 1 21 | 213.271 30.0332 -0.502979 2.93783 192.363 30.0559 0.0313456 0.13876 57.9924 16.722 0.0885706 0.0744915 0.152545 0.40094 0.480262 0.588813 2.37372 0.00454638 33.1803 0.211374 1 22 | 208.411 31.2969 -0.220765 2.18238 187.599 30.4546 0.0659948 0.0315157 58.6187 15.0724 -0.000825859 0.0191044 0.181187 0.438235 0.570703 0.617664 2.37964 0.00439055 32.411 0.204887 1 23 | 215.062 26.9945 -0.239667 2.45721 194.784 27.6261 0.0291235 0.175043 55.2369 16.8151 0.127693 0.221195 0.301011 0.549054 0.593939 0.704235 2.36657 0.00472538 29.2857 0.228294 1 24 | 216.134 28.2604 -0.424737 2.84686 196.159 28.5991 0.04881 0.144104 56.1807 14.8943 0.0521873 0.0895525 0.117135 0.403383 0.489665 0.525655 2.3624 0.00478416 27.6122 0.238017 1 25 | 212.784 27.3226 -0.208492 2.77152 191.96 26.9 0.0290161 0.287816 57.8596 14.3219 0.0456884 0.0973195 0.277871 0.617925 0.843003 0.639231 2.37036 0.00462906 28.6231 0.228979 1 26 | 209.196 31.195 -0.365736 2.62264 187.708 30.5958 0.0362628 0.0903563 60.7111 13.2712 0.011655 0.0338929 0.193529 0.443319 0.484293 0.652642 2.33577 0.00525462 23.1809 0.260277 1 27 | 211.239 32.4815 -0.480622 2.43084 187.134 32.171 0.0606013 0.0287532 65.7732 16.7057 0.0436272 0.0443049 0.101252 0.317651 0.348414 0.605095 2.36055 0.00472214 27.9108 0.218699 1 28 | 211.92 30.6268 -0.341561 2.43167 189.201 31.4246 0.0686945 0.053569 62.9587 18.9626 0.0515728 0.0925876 0.234288 0.569002 0.463054 0.672949 2.36063 0.00479921 28.0291 0.225448 1 29 | 212.166 32.4194 -0.486905 2.56842 188.577 33.4513 0.0856867 -0.0155191 63.5886 18.7889 0.0602512 0.0674485 0.195859 0.50383 0.537302 0.603749 2.33535 0.00509751 22.672 0.244997 1 30 | 221.559 19.8063 -0.127411 2.54654 204.152 17.9871 0.0942931 0.190036 42.5413 9.935 0.0161271 0.00835829 0.198816 0.477159 0.373582 0.660392 2.37041 0.00459995 40.4209 0.175928 1 31 | 215.057 29.7847 -0.628162 3.30151 195.606 31.2061 -0.0432877 0.298867 51.368 20.5865 0.197949 0.205333 0.214836 0.417768 0.419567 0.713619 2.35334 0.00487853 37.8154 0.181892 1 32 | 207.789 26.477 -0.113868 3.65047 188.889 26.3085 0.0152325 0.367267 52.8595 16.0873 0.0683739 0.239524 0.140947 0.402503 0.36912 0.612221 2.36845 0.0046718 31.983 0.210817 1 33 | 218.66 24.8925 -0.0727639 2.05339 198.645 24.6918 0.132051 0.114126 53.7351 14.1784 -0.0470565 0.107519 0.178852 0.449389 0.930023 0.5765 2.36596 0.00472713 33.8948 0.233996 1 34 | 202.875 22.7448 0.697157 2.64916 186.612 20.1269 0.0973161 0.249964 47.6062 11.6027 -0.0631009 0.0162969 0.216898 0.520089 0.507583 0.632208 2.35058 0.00499666 25.5419 0.248183 1 35 | 223.589 22.3901 -0.128389 2.00839 204.221 20.3771 0.177445 0.159166 49.0855 12.7975 -0.0104538 0.0834125 0.199 0.490228 0.587687 0.603636 2.36377 0.00484679 30.7211 0.227362 1 36 | 215.022 20.814 0.297377 2.38277 198.572 18.8804 0.0625965 0.236587 43.7707 10.8165 -0.0201092 0.05637 0.100004 0.457828 0.576498 0.500713 2.38419 0.00433729 36.5296 0.195261 1 37 | 225.047 20.7555 -0.220149 2.97389 209.176 21.197 0.140866 0.173234 40.5163 9.99022 0.0434498 0.0602627 0.195551 0.388273 0.556969 0.695759 2.32347 0.00596583 28.652 0.258681 1 38 | 223.951 20.315 -0.250915 3.19217 205.194 18.7333 0.067778 0.634551 45.9939 11.4951 0.0860865 0.136186 0.274211 0.553626 0.504339 0.715203 2.36089 0.00475452 27.2025 0.234464 1 39 | 213.77 22.7765 -0.515599 5.70108 197.509 21.3258 -0.131954 0.96392 41.7965 13.8693 0.169719 0.0124721 0.108767 0.396362 0.581804 0.501896 2.32484 0.0053384 33.3115 0.223361 1 40 | 222.892 24.0852 -0.860348 4.46198 201.049 27.2466 -0.075511 0.230256 52.0135 20.3742 0.383281 0.168137 0.396359 0.470706 0.500262 0.914073 2.13249 0.00836691 31.9339 0.218543 1 41 | 223.972 16.8971 0.263093 2.16734 203.814 14.6657 0.145757 0.198594 45.2242 9.97087 -0.0422394 0.0501618 0.450922 0.641924 0.596877 0.826213 2.28397 0.005841 45.7057 0.161697 1 42 | 219.015 13.6805 0.302394 3.2406 201.476 12.2967 0.0269992 -0.14566 39.7179 7.34081 -0.113894 0.0214785 0.520779 0.585784 0.708333 0.861377 2.17415 0.00766601 36.6256 0.165999 1 43 | 218.201 22.3319 -0.298263 2.41635 201.036 20.8989 -0.00117505 0.132051 43.1647 8.19105 0.000578173 0.00654885 0.228715 0.434967 0.392763 0.752938 2.05449 0.0100831 48.4632 0.134917 1 44 | 211.818 24.1806 -1.21003 6.0537 190.424 24.0166 -0.100408 0.275805 51.63 13.1043 0.104067 -0.0551134 0.217788 0.464737 0.340974 0.748291 2.23055 0.00674396 39.0596 0.155807 1 45 | 226.64 29.7157 -1.85919 7.27559 204.305 28.9238 0.0335492 0.145749 50.5308 14.5299 0.114832 -0.10065 0.251962 0.492795 0.425079 0.724712 2.09766 0.00915685 52.7119 0.161386 1 46 | 219.296 34.7539 -1.31617 4.61009 200.074 35.6515 0.0520921 -0.0430739 49.25 15.8351 0.115547 0.0173988 0.292149 0.491837 0.481081 0.760267 2.17933 0.00736328 44.5562 0.168157 1 47 | 225.177 24.2844 -0.967749 4.63522 203.691 25.1938 0.0677855 0.0920584 53.9651 16.6203 0.211576 -0.0785302 0.327298 0.564009 0.380242 0.811122 2.33548 0.00506908 41.6119 0.161269 1 48 | 228.129 20.8799 -0.438513 3.09768 206.411 21.851 0.092606 -0.0659038 51.3043 17.0761 0.194471 -0.0034824 0.177873 0.438498 0.249263 0.776527 2.30695 0.00557435 39.7839 0.206218 1 49 | 219.885 21.3495 0.198608 2.24951 198.827 20.7896 0.104721 0.376402 52.826 13.0268 -0.0496157 0.0898796 0.304666 0.558495 0.295238 0.845985 2.26524 0.00715486 21.8119 0.308453 1 50 | 223.96 22.3046 -0.696469 4.23335 201.14 20.0941 0.0280249 0.380875 53.5009 14.0774 0.0771421 -0.104053 0.183286 0.514042 0.239907 0.731496 2.34183 0.00524518 31.4754 0.221992 1 51 | 216.896 29.0594 -1.08074 4.74369 196.807 30.8506 -0.0390567 0.121694 51.3196 17.6388 0.195972 -0.00485481 0.142375 0.300994 0.356612 0.674157 2.31381 0.00550305 45.0696 0.181822 1 52 | 219.771 26.5186 -0.876737 3.85411 196.676 28.8672 -0.015079 -0.140369 55.498 19.8803 0.277439 -0.0662111 0.338261 0.534521 0.294329 0.912874 2.26218 0.00624593 42.7769 0.173279 1 53 | 224.987 19.7799 -0.366481 3.22257 205.149 19.9958 0.00625083 0.202897 48.6552 10.9172 0.0645108 0.0556516 0.311345 0.511368 0.540877 0.771034 2.29957 0.00563573 39.3236 0.192715 1 54 | 231.392 19.7846 -1.0279 3.89176 210.476 19.0226 0.138135 -0.026164 47.8728 9.26671 0.0796793 -0.0384656 0.261364 0.441064 0.294091 0.881243 2.23339 0.00688976 36.5827 0.197452 1 55 | 230.385 16.1 -0.159728 2.49837 207.225 15.49 0.141131 0.181619 52.6702 8.89232 0.00764722 0.0346104 0.1111 0.32095 0.244731 0.687272 2.24634 0.00653983 43.6284 0.174872 1 56 | 217.527 19.4476 -0.177894 2.65847 197.762 16.8926 -0.0309957 0.244249 48.6854 11.2291 0.0189045 -0.0292838 0.0718487 0.302624 0.408606 0.51252 2.33295 0.00538748 33.586 0.226512 1 57 | 219.109 18.7933 0.00555394 2.8216 202.056 16.7422 -0.0807905 0.536077 41.1737 12.2581 0.0841208 0.276735 0.0958996 0.361501 0.654291 0.472245 2.34239 0.00511473 31.1834 0.228339 1 58 | 211.019 20.7243 0.585214 2.43385 195.597 17.3344 0.0396482 0.257226 42.2791 11.5916 -0.0638236 -0.00455042 0.179215 0.427207 0.770162 0.593994 2.33402 0.00534797 31.3015 0.232901 1 59 | 214.565 19.4539 0.406149 2.4556 198.082 17.9155 0.0943865 0.16402 44.57 8.69352 -0.0246443 0.0316348 0.187682 0.445086 0.496671 0.659805 2.36375 0.00469616 44.602 0.171698 1 60 | 217.056 29.013 -0.41445 2.39728 162.688 27.1972 0.0465762 0.0356529 102.395 18.8572 0.118598 0.0165036 0.458114 0.568664 0.719809 0.87078 2.20488 0.00698184 28.371 0.220032 0 61 | 221.071 25.9566 -0.4048 2.70111 164.387 25.2943 0.158611 -0.0133707 102.836 16.7991 0.0363155 -0.00040152 0.351302 0.415045 0.63085 0.873768 2.20972 0.00739645 32.7527 0.201305 0 62 | 219.223 21.3647 -0.0296671 2.56404 163.504 20.5748 0.151256 0.0502913 100.518 14.3511 0.00377272 0.0944589 0.27414 0.455592 0.43808 0.826769 1.98843 0.0112889 44.4 0.16964 0 63 | 203.207 20.0072 0.17998 2.59955 151.768 19.6985 -0.0327517 0.0892325 101.28 11.3742 0.00845121 0.0375723 0.576445 0.5857 0.548048 0.952189 1.65616 0.0225694 32.4583 0.187253 0 64 | 221.444 13.0819 0.0265004 3.55217 172.356 12.2695 -0.170838 -0.0585129 87.3111 9.1841 0.201767 -0.00268994 0.269364 0.434783 0.304348 0.924328 1.20412 0.0625 81.875 0.0662959 0 65 | 211.9 25.7552 0.283069 2.16111 157.04 26.69 0.108139 0.0914808 101.34 16.1278 -0.0459992 0.086278 0.366807 0.444336 1 0.854632 1.42566 0.0382653 42.5714 0.176043 0 66 | 205.625 9.44904 0.665987 4.06596 150 9.43133 0.159313 0.560264 106.325 8.95094 -0.445255 -0.0390145 0.359613 0.562687 0.298507 0.935288 1.38265 0.0433673 28.2143 0.201588 0 67 | 206.263 23.7148 0.00223173 3.19698 153.293 22.5874 0.110803 0.291856 103.902 15.9406 0.0702758 0.163757 0.325275 0.450418 0.768739 0.799714 2.17211 0.007456 40.656 0.178117 0 68 | 208.62 29.7964 0.122054 2.36201 154.663 30.2741 0.131207 0.15598 105.021 23.3229 0.0645522 0.336227 0.223911 0.382197 0.55473 0.769241 2.30819 0.00550571 34.3763 0.191476 0 69 | 188 11.0136 -0.106358 1.34697 125.65 12.551 0.00285515 -0.00134663 142.7 29.3362 0.069912 -0.075212 0.774353 0.833333 0.6 0.987492 0.60206 0.25 125 0.0214432 0 70 | 217.89 29.8785 -0.171577 2.37494 164.622 31.7869 0.114238 -0.00764231 99.3832 24.2156 0.163536 0.316959 0.209127 0.373149 0.427487 0.76211 2.23344 0.00669335 47.125 0.133517 0 71 | 222.519 25.9748 -0.2911 2.30124 168.371 27.3446 0.0966399 -0.152767 97.7809 21.5946 0.228676 0.0414111 0.285567 0.426923 0.31115 0.902814 1.98831 0.0117933 81.7742 0.0577198 0 72 | 211.931 17.823 0.108727 3.03128 158.364 17.3672 -0.00671199 0.173437 100.624 15.2343 0.159665 0.0673203 0.281258 0.43988 0.583219 0.768051 1.97689 0.0111863 60.0968 0.147723 0 73 | 212.876 25.6486 0.627304 3.64677 154.678 25.9113 -0.102786 0.122399 110.384 32.4641 0.396429 0.399099 0.324593 0.522284 0.593557 0.762452 2.02367 0.0104875 44.0119 0.207493 0 74 | 201.079 23.4503 0.71533 3.18292 148 24.443 0.0565841 0.201433 103.175 16.1457 -0.12882 -0.0248261 0.271101 0.397922 0.314685 0.931475 1 0.1 18.2 0.234842 0 75 | 221.071 25.9566 -0.4048 2.70111 164.387 25.2943 0.158611 -0.0133707 102.836 16.7991 0.0363155 -0.00040152 0.351302 0.415045 0.63085 0.873768 2.20972 0.00739645 32.7527 0.201305 0 76 | 219.223 21.3647 -0.0296671 2.56404 163.504 20.5748 0.151256 0.0502913 100.518 14.3511 0.00377272 0.0944589 0.27414 0.455592 0.43808 0.826769 1.98843 0.0112889 44.4 0.16964 0 77 | 203.207 20.0072 0.17998 2.59955 151.768 19.6985 -0.0327517 0.0892325 101.28 11.3742 0.00845121 0.0375723 0.576445 0.5857 0.548048 0.952189 1.65616 0.0225694 32.4583 0.187253 0 78 | -------------------------------------------------------------------------------- /samples/sample4.txt: -------------------------------------------------------------------------------- 1 | 215.581 37.0337 -0.288599 2.32427 156.082 39.4886 0.216243 -0.107076 189.425 32.7589 0.182023 0.027165 0.125297 0.425578 0.326034 0.599975 2.35168 0.00496257 28.0735 0.236052 1 2 | 211.914 39.042 -0.23571 2.22025 157.639 42.5966 0.181637 -0.143611 182.23 39.7481 0.167744 -0.0161956 0.0612746 0.343515 0.393312 0.441823 2.37446 0.00454387 36.1088 0.221084 1 3 | 183.416 48.8651 -0.0399394 1.99863 160.247 49.0706 -0.00118495 0.0118966 110.896 37.4889 0.27764 0.288754 0.188079 0.466254 0.183521 0.892746 1.30495 0.0520833 38.75 0.226005 0 4 | 212.992 39.7141 -0.30198 2.29579 157.972 42.7337 0.21105 -0.116249 184.69 39.8078 0.125634 0.0633393 0.101678 0.344067 0.468568 0.539284 2.3688 0.00464258 33.6871 0.221002 1 5 | 190.724 35.535 -0.0293072 2.27956 167.362 35.8951 0.000870275 0.0333109 100.667 21.6085 0.0858942 0.0521077 0.103885 0.316258 0.212209 0.768092 1.6878 0.021262 55.3704 0.116958 0 6 | 207.697 40.2091 -0.260999 2.34801 153.101 41.7304 0.169576 -0.0407989 183.352 41.4298 0.0702713 0.103739 0.0793478 0.319851 0.382106 0.481474 2.36465 0.00474297 36.3041 0.217209 1 7 | 206.556 41.5829 -0.344664 1.68951 188.319 43.0767 0.0385336 -0.0318234 85.2639 21.9779 0.0607855 0.0149178 0.248293 0.466667 0.238095 0.926109 1.18062 0.07 89.4 0.0730839 0 8 | 215.465 37.0203 -0.351209 2.51288 155.911 38.8798 0.256249 -0.0936071 189.292 30.5406 0.162312 0.0547502 0.146702 0.404616 0.456026 0.601482 2.35496 0.00493245 32.1585 0.214418 1 9 | 209.25 36.6503 -0.148644 1.61319 191.806 38.2719 0.0349277 0.0137374 82.8611 18.6401 0.0343339 0.0177 0.211087 0.410468 0.264463 0.868934 0.978838 0.111111 47.3333 0.163558 0 10 | 211.84 35.98 -0.232945 2.48245 150.647 37.2232 0.178249 0.00883049 190.567 35.8931 0.118597 0.0689542 0.0881107 0.373622 0.327016 0.500922 2.37798 0.00448285 36.8909 0.196741 1 11 | 204.812 27.106 -0.341283 2.12767 171.271 27.2104 -0.0135567 0.00963025 112.417 16.4606 0.124661 0.0375708 0.328218 0.602362 0.275591 0.909645 1.41497 0.0384615 11.0769 0.178253 0 12 | 209.001 39.8747 -0.200782 2.3718 151.622 40.9733 0.174421 -0.023815 184.395 39.3704 0.167438 0.0935705 0.111123 0.35775 0.52105 0.563488 2.36608 0.00465014 37.898 0.205129 1 13 | 211.083 37.2288 -0.179746 2.32384 154.725 39.8827 0.172913 -0.0813317 187.252 36.6085 0.0977028 0.146904 0.204788 0.436367 0.502122 0.692441 2.3751 0.0044726 37.4707 0.192781 1 14 | 214.569 35.1835 -0.225211 2.4584 162.26 38.0607 0.143305 -0.0326433 171.47 42.6879 0.0907048 0.0371233 0.174737 0.364242 0.439056 0.661124 2.33598 0.00529802 26.4613 0.236027 1 15 | 217.532 36.5962 -0.271067 2.27554 164.743 41.2084 0.21369 -0.203727 181.092 37.7944 0.164828 0.0170896 0.190742 0.415876 0.508327 0.670286 2.3667 0.00472126 35.0729 0.211285 1 16 | 217.075 35.6848 -0.210334 2.3803 162.334 39.5677 0.296829 -0.250823 180.917 34.4117 0.160478 -0.0305134 0.144912 0.416699 0.310362 0.672415 2.3735 0.00457141 34.5988 0.204241 1 17 | 219.358 35.5744 -0.264061 2.34414 164.881 40.0111 0.260722 -0.21463 181.358 34.1442 0.22158 -0.0375225 0.138259 0.395861 0.344146 0.677976 2.35731 0.00492984 33.9729 0.211542 1 18 | 217.244 36.1018 -0.294189 2.45256 158.072 38.6608 0.288078 -0.194395 189.648 34.057 0.110931 0.00993948 0.158716 0.41424 0.317666 0.695595 2.33879 0.00542088 27.8535 0.248631 1 19 | 217.6 37.7405 -0.385402 2.41464 161.24 39.4483 0.231888 -0.186061 186.086 38.9699 0.177397 -0.11679 0.216966 0.443463 0.597453 0.698895 2.36363 0.00471967 32.377 0.229891 1 20 | 212.402 38.9482 -0.334898 2.52449 151.418 40.9915 0.261449 -0.313779 191.902 36.6866 0.117264 -0.0629605 0.126307 0.304509 0.397838 0.647389 2.35917 0.00476197 32.2418 0.207863 1 21 | 214.306 36.8863 -0.21462 2.22322 155.092 40.4913 0.212913 -0.0688399 188.708 34.6537 0.127298 0.0663584 0.167102 0.349453 0.451652 0.690162 2.35318 0.00492211 31.9934 0.214498 1 22 | 212.425 36.891 -0.192281 2.2456 154.187 39.0025 0.184252 -0.0248328 187.063 35.938 0.119649 0.0656691 0.182524 0.391301 0.352932 0.746188 2.35897 0.00476442 35.7216 0.194714 1 23 | 195.468 35.0154 -0.144199 2.72705 152.872 33.2838 -0.0176924 0.048078 173.213 31.9534 0.441921 0.318765 0.509067 0.561983 1 0.870936 1.44716 0.0357143 65.4286 0.065822 1 24 | 209.872 39.9931 -0.0695695 1.63955 171.513 46.5777 0.034944 0.0136083 138.744 35.6081 0.154104 0.141829 0.310687 0.487988 0.411111 0.825358 1.44716 0.0357143 75.2857 0.108654 1 25 | 215.023 39.1167 -0.276957 2.09084 165.321 46.0069 0.199251 -0.223986 182.549 36.7358 0.148673 0.0104815 0.199619 0.387195 0.407412 0.738815 2.36013 0.00482994 33.122 0.210644 1 26 | 213.265 36.2169 -0.210086 2.26025 154.103 39.7125 0.255788 -0.1776 190.818 32.4844 0.119579 0.045799 0.154059 0.393386 0.374483 0.605254 2.35266 0.00498073 32.086 0.226315 1 27 | 191.535 38.032 -1.20246 4.38837 164.884 37.4291 0.0341009 -0.0705661 109.349 27.5393 0.593549 0.164234 0.339606 0.583508 0.242857 0.958322 0.60206 0.25 65 0.0160976 0 28 | -------------------------------------------------------------------------------- /samples/sample6.txt: -------------------------------------------------------------------------------- 1 | 232.417 26.3559 0.0732037 2.95102 175.561 38.8664 0.0901277 -0.0708152 110.078 48.5394 0.190297 -0.128077 0.284457 0.489858 0.719681 0.748717 2.21699 0.00671875 43.7125 0.171802 1 2 | 230.088 26.6724 -0.16419 2.93398 170.929 39.2682 0.104869 -0.0393485 109.643 44.5633 0.10764 -0.0062816 0.151033 0.38529 0.487179 0.609855 2.24803 0.00620408 36.5486 0.156108 1 3 | 239.885 19.5654 -0.284278 3.61581 175.509 31.759 0.09462 -0.0762985 118.159 40.7805 0.132496 -0.183334 0.341974 0.483183 0.607595 0.773197 2.2262 0.00659667 44.4954 0.146915 1 4 | 227.539 28.666 -0.0100284 2.71621 159.007 36.2376 0.14265 -0.0617927 131.909 44.481 0.199647 -0.0999651 0.33154 0.611849 0.844137 0.703704 2.33786 0.00502478 40.6771 0.172329 1 5 | 232.941 26.8516 0.169701 3.12282 172.193 38.3851 0.0703305 -0.0474644 113.82 49.5389 0.22384 -0.113668 0.296342 0.434717 0.825829 0.722902 2.18771 0.00742382 50.4526 0.166244 1 6 | 232.744 27.11 -0.183431 3.07305 169.147 39.1639 0.0937945 -0.0609003 118.56 52.4543 0.165177 -0.169675 0.321667 0.52375 0.687423 0.736103 2.25751 0.00639757 41.2917 0.176761 1 7 | 225.993 27.2532 -0.482173 3.81522 158.655 36.79 0.11784 0.0217592 127.91 45.0944 0.00238478 0.140723 0.336058 0.501629 0.642887 0.793723 2.23607 0.00686279 28.2811 0.223032 1 8 | 228.729 24.2901 0.814402 3.97819 152.569 25.5818 0.02634 0.00145594 138.451 37.2191 0.478872 0.0738399 0.145263 0.369345 0.375862 0.6858 2.19311 0.00719035 37.5316 0.151368 1 9 | 230.068 28.585 0.0553328 3.43391 158.515 35.8818 0.124607 -0.0109442 132.267 45.561 0.262356 -0.0576246 0.16632 0.468464 0.457143 0.595205 2.29702 0.00585293 31.3786 0.236283 1 10 | 232.587 23.0929 -0.211017 3.50824 165.552 34.6159 0.0926125 0.00401354 120.826 43.4602 0.0650045 0.0392222 0.346936 0.565898 0.73823 0.739859 2.29215 0.00583425 29.1983 0.213719 1 11 | 228.401 31.3391 -0.12721 3.26031 153.301 36.9159 0.138512 -0.0441599 143.169 46.2946 0.273796 -0.0421332 0.36258 0.567851 0.691642 0.735557 2.34902 0.00491777 33.773 0.205325 1 12 | 226.206 30.6061 -0.116689 3.6875 151.885 37.7013 0.131593 0.00273874 140.361 46.3972 0.18148 0.13087 0.180975 0.522105 0.43038 0.60078 2.33089 0.00532407 28.0278 0.232864 1 13 | 220.333 29.9367 -0.10406 4.5472 144.665 30.3173 0.240425 0.226789 141.37 37.1501 0.211532 0.572289 0.272343 0.504032 0.605595 0.733307 2.32643 0.00537387 32.2659 0.205898 1 14 | 222.002 32.092 -0.162421 3.81558 138.165 30.4433 0.16613 -0.0314307 158.381 37.7269 0.365717 0.374309 0.298806 0.518514 0.853709 0.717179 2.33464 0.00521483 27.9163 0.219959 1 15 | 234.314 27.1357 -0.465119 3.48169 148.979 33.2288 0.124895 -0.0417525 158.209 46.0401 0.193137 -0.165441 0.123607 0.511828 0.418919 0.504941 2.32771 0.00523943 33.5629 0.194984 1 16 | 229.066 30.4693 -0.349668 3.09211 148.152 39.475 0.10558 -0.0199138 155.017 51.4425 0.132478 -0.0470828 0.406346 0.582249 0.555285 0.802983 2.31718 0.00560073 27.5309 0.218323 1 17 | 226.591 35.1756 -0.260995 3.17892 143.603 37.0466 0.149126 -0.0877349 160.648 47.8004 0.368106 -0.178774 0.109153 0.49549 0.414468 0.495787 2.3466 0.00499534 30.4095 0.195158 1 18 | 225.621 32.7383 -0.374143 3.15428 143.189 37.7444 0.151614 -0.0165204 162.13 47.9044 0.143665 0.0103868 0.10663 0.412646 0.349183 0.540373 2.32942 0.00513099 23.771 0.240258 1 19 | 231.567 28.3087 -0.266743 2.97489 151.896 37.4962 0.0956598 -0.0426921 150.829 50.9004 0.169107 -0.155705 0.0952793 0.495706 0.308759 0.506882 2.34791 0.00516252 28.6831 0.225626 1 20 | 226.337 32.9278 -0.247285 2.83393 146.23 40.1055 0.125242 -0.0400583 160.104 51.5517 0.181695 -0.0817249 0.100788 0.466279 0.434936 0.489782 2.32496 0.00542542 29.1698 0.231862 1 21 | 232.11 29.0755 -0.251184 2.34123 165.793 46.7021 0.0592912 -0.0321711 132.313 61.3924 0.100897 -0.0921111 0.150497 0.49177 0.397334 0.571685 2.34133 0.00508643 27.8958 0.232526 1 22 | 232.608 26.7891 -0.355129 3.03316 157.042 41.3483 0.0688975 -0.0194197 142.987 54.9239 0.0812661 -0.0445185 0.0964156 0.515693 0.357955 0.471243 2.32501 0.00540884 25.238 0.236315 1 23 | 235.279 24.2259 -0.228265 2.35446 163.442 42.8097 0.0307246 -0.0118855 138.76 61.6087 0.0655136 -0.0532474 0.169569 0.388323 0.592609 0.598132 2.27099 0.00632379 22.6738 0.233376 1 24 | 233.622 27.7545 -0.127379 2.74919 159.654 42.2181 0.0691873 -0.0430227 140.273 56.5033 0.145719 -0.126122 0.125975 0.376953 0.410479 0.557814 2.35924 0.00478557 36.5304 0.185718 1 25 | 231.036 30.9475 -0.156384 2.08504 165.411 48.1722 0.0499589 -0.0246725 132.329 66.3252 0.111474 -0.0896008 0.199738 0.445938 0.680005 0.626164 2.29859 0.00562151 25.8338 0.218374 1 26 | 221.071 25.9566 -0.4048 2.70111 164.387 25.2943 0.158611 -0.0133707 102.836 16.7991 0.0363155 -0.00040152 0.351302 0.415045 0.63085 0.873768 2.20972 0.00739645 32.7527 0.201305 0 27 | 219.223 21.3647 -0.0296671 2.56404 163.504 20.5748 0.151256 0.0502913 100.518 14.3511 0.00377272 0.0944589 0.27414 0.455592 0.43808 0.826769 1.98843 0.0112889 44.4 0.16964 0 28 | 203.207 20.0072 0.17998 2.59955 151.768 19.6985 -0.0327517 0.0892325 101.28 11.3742 0.00845121 0.0375723 0.576445 0.5857 0.548048 0.952189 1.65616 0.0225694 32.4583 0.187253 0 29 | 221.444 13.0819 0.0265004 3.55217 172.356 12.2695 -0.170838 -0.0585129 87.3111 9.1841 0.201767 -0.00268994 0.269364 0.434783 0.304348 0.924328 1.20412 0.0625 81.875 0.0662959 0 30 | 211.9 25.7552 0.283069 2.16111 157.04 26.69 0.108139 0.0914808 101.34 16.1278 -0.0459992 0.086278 0.366807 0.444336 1 0.854632 1.42566 0.0382653 42.5714 0.176043 0 31 | 206.263 23.7148 0.00223173 3.19698 153.293 22.5874 0.110803 0.291856 103.902 15.9406 0.0702758 0.163757 0.325275 0.450418 0.768739 0.799714 2.17211 0.007456 40.656 0.178117 0 32 | 208.62 29.7964 0.122054 2.36201 154.663 30.2741 0.131207 0.15598 105.021 23.3229 0.0645522 0.336227 0.223911 0.382197 0.55473 0.769241 2.30819 0.00550571 34.3763 0.191476 0 33 | 217.89 29.8785 -0.171577 2.37494 164.622 31.7869 0.114238 -0.00764231 99.3832 24.2156 0.163536 0.316959 0.209127 0.373149 0.427487 0.76211 2.23344 0.00669335 47.125 0.133517 0 34 | 222.519 25.9748 -0.2911 2.30124 168.371 27.3446 0.0966399 -0.152767 97.7809 21.5946 0.228676 0.0414111 0.285567 0.426923 0.31115 0.902814 1.98831 0.0117933 81.7742 0.0577198 0 35 | 211.931 17.823 0.108727 3.03128 158.364 17.3672 -0.00671199 0.173437 100.624 15.2343 0.159665 0.0673203 0.281258 0.43988 0.583219 0.768051 1.97689 0.0111863 60.0968 0.147723 0 36 | 212.876 25.6486 0.627304 3.64677 154.678 25.9113 -0.102786 0.122399 110.384 32.4641 0.396429 0.399099 0.324593 0.522284 0.593557 0.762452 2.02367 0.0104875 44.0119 0.207493 0 37 | 215.605 37.223 -0.391415 2.16486 159.132 41.3497 0.109761 -0.157876 147.184 37.0631 0.243624 0.10985 0.448559 0.6375 0.4 0.920246 1.12886 0.078125 99.375 0.0130664 0 38 | 232.417 26.3559 0.0732037 2.95102 175.561 38.8664 0.0901277 -0.0708152 110.078 48.5394 0.190297 -0.128077 0.284457 0.489858 0.719681 0.748717 2.21699 0.00671875 43.7125 0.171802 1 39 | 230.088 26.6724 -0.16419 2.93398 170.929 39.2682 0.104869 -0.0393485 109.643 44.5633 0.10764 -0.0062816 0.151033 0.38529 0.487179 0.609855 2.24803 0.00620408 36.5486 0.156108 1 40 | 226.32 29.0216 -0.154489 2.94004 165.581 34.624 0.17662 -0.036628 117.124 40.3032 0.179956 -0.00630894 0.437828 0.576696 0.713671 0.828431 2.22442 0.00677104 47.431 0.146909 1 41 | 239.885 19.5654 -0.284278 3.61581 175.509 31.759 0.09462 -0.0762985 118.159 40.7805 0.132496 -0.183334 0.341974 0.483183 0.607595 0.773197 2.2262 0.00659667 44.4954 0.146915 1 42 | 228.497 28.4783 -0.518288 4.27367 159.785 31.1506 0.327238 0.137203 127.697 35.2846 0.0110922 0.50247 0.273866 0.53708 0.763824 0.69203 2.30414 0.00557415 33.5702 0.195124 1 43 | 227.539 28.666 -0.0100284 2.71621 159.007 36.2376 0.14265 -0.0617927 131.909 44.481 0.199647 -0.0999651 0.33154 0.611849 0.844137 0.703704 2.33786 0.00502478 40.6771 0.172329 1 44 | 229.806 31.3994 -0.433276 3.26812 172.907 40.5237 0.199159 -0.109172 111.984 44.4718 0.141378 0.0196078 0.291463 0.529263 0.888571 0.701402 2.30998 0.00565222 32.4405 0.20983 1 45 | 226.705 30.3368 -0.188939 2.76958 167.826 42.1215 0.0929997 -0.0256405 118.593 52.6974 0.105707 -0.0365216 0.0814754 0.30524 0.513514 0.500517 2.21588 0.00705258 36.8186 0.15926 1 46 | 232.941 26.8516 0.169701 3.12282 172.193 38.3851 0.0703305 -0.0474644 113.82 49.5389 0.22384 -0.113668 0.296342 0.434717 0.825829 0.722902 2.18771 0.00742382 50.4526 0.166244 1 47 | 232.744 27.11 -0.183431 3.07305 169.147 39.1639 0.0937945 -0.0609003 118.56 52.4543 0.165177 -0.169675 0.321667 0.52375 0.687423 0.736103 2.25751 0.00639757 41.2917 0.176761 1 48 | 236.434 25.2928 -0.126923 3.10262 174.537 38.9221 0.0813425 -0.0539289 117.301 48.509 0.173895 -0.118524 0.305865 0.482246 0.639459 0.718454 2.22603 0.00686193 30.7915 0.202299 1 49 | 239.697 21.7433 -0.166704 2.87889 175.368 36.2045 0.062438 -0.0590169 118.383 48.0968 0.1542 -0.186942 0.356464 0.530986 0.5847 0.787009 2.2192 0.00702268 22.113 0.202553 1 50 | 220.998 30.769 0.148625 3.11737 148.806 35.8777 0.171944 0.0433701 139.665 41.2945 0.238551 0.138903 0.109942 0.371258 0.404867 0.585369 2.27506 0.00607882 39.2335 0.159412 1 51 | 228.026 20.7778 -0.403449 2.18044 147.821 16.8795 -0.000886188 0.107347 137.744 13.8133 0.263251 0.20289 0.496468 0.621212 0.409091 0.945324 0.30103 0.5 225 0.00442478 0 52 | 230.068 28.585 0.0553328 3.43391 158.515 35.8818 0.124607 -0.0109442 132.267 45.561 0.262356 -0.0576246 0.16632 0.468464 0.457143 0.595205 2.29702 0.00585293 31.3786 0.236283 1 53 | 232.587 23.0929 -0.211017 3.50824 165.552 34.6159 0.0926125 0.00401354 120.826 43.4602 0.0650045 0.0392222 0.346936 0.565898 0.73823 0.739859 2.29215 0.00583425 29.1983 0.213719 1 54 | 230.979 28.2867 -0.276008 3.13691 157.834 36.8422 0.142624 -0.111248 140.068 45.5845 0.206019 -0.248641 0.105983 0.402152 0.517451 0.501334 2.33229 0.00529828 28.6523 0.229017 1 55 | 227.619 31.173 -0.37011 3.8739 148.676 30.6022 0.225873 0.0286882 146.45 36.2652 0.366136 0.128294 0.132894 0.413707 0.558594 0.546717 2.32381 0.00532239 31.2561 0.226954 1 56 | 221.316 11.272 -0.13563 2.51739 177.158 11.2496 -0.0207584 0.15469 87.5789 13.7087 0.301631 -0.406132 0.808518 0.8 0.6 1 0.30103 0.5 64 0.0153846 0 57 | 231.064 27.8359 -0.159893 3.34652 146.893 30.7709 0.12504 -0.0235984 156.727 41.2826 0.290872 -0.0896402 0.257358 0.50791 0.777987 0.665392 2.31779 0.00549396 30.2151 0.206003 1 58 | 230.8 22.9273 -1.42725 4.48715 185.35 23.491 -0.0146507 0.142674 85.7 15.4373 0.318617 -0.15125 0.691563 0.632441 0.761905 0.968864 0.60206 0.25 137 0.0122124 0 59 | 227.022 29.8891 -0.0616171 3.28926 143.112 31.1113 0.159874 -0.0162533 156.904 37.9921 0.377563 0.0839734 0.0877408 0.427289 0.423228 0.474985 2.34529 0.00504771 35.3789 0.188203 1 60 | 222.002 32.092 -0.162421 3.81558 138.165 30.4433 0.16613 -0.0314307 158.381 37.7269 0.365717 0.374309 0.298806 0.518514 0.853709 0.717179 2.33464 0.00521483 27.9163 0.219959 1 61 | 229.066 30.4693 -0.349668 3.09211 148.152 39.475 0.10558 -0.0199138 155.017 51.4425 0.132478 -0.0470828 0.406346 0.582249 0.555285 0.802983 2.31718 0.00560073 27.5309 0.218323 1 62 | 226.591 35.1756 -0.260995 3.17892 143.603 37.0466 0.149126 -0.0877349 160.648 47.8004 0.368106 -0.178774 0.109153 0.49549 0.414468 0.495787 2.3466 0.00499534 30.4095 0.195158 1 63 | 225.621 32.7383 -0.374143 3.15428 143.189 37.7444 0.151614 -0.0165204 162.13 47.9044 0.143665 0.0103868 0.10663 0.412646 0.349183 0.540373 2.32942 0.00513099 23.771 0.240258 1 64 | 224.143 33.8655 -0.232707 3.52376 143.711 35.9875 0.192922 -0.0433195 154.437 46.3762 0.276582 -0.049671 0.191377 0.496907 0.442927 0.62186 2.36456 0.00471041 33.606 0.19966 1 65 | 234.468 27.5011 -0.381462 3.25174 153.885 38.725 0.0948339 -0.0628145 152.123 52.115 0.171603 -0.194702 0.271171 0.555904 0.567057 0.662461 2.34834 0.00498296 28.8792 0.215707 1 66 | 228.782 30.9118 -0.388655 2.89279 156.81 45.6933 0.0779585 -0.0230383 140.715 59.444 0.0818594 -0.0395343 0.246761 0.545023 0.504466 0.681612 2.33563 0.00549506 26.2003 0.243758 1 67 | 226.995 32.1925 -0.330256 2.95931 149.835 42.6795 0.113848 -0.0282368 150.787 54.4707 0.118657 -0.0499472 0.20826 0.467068 0.470879 0.66793 2.33458 0.00551097 26.1628 0.23305 1 68 | 223.403 32.5387 -0.142689 3.20837 146.66 39.4659 0.138521 0.011982 150.81 48.9669 0.139989 0.0949761 0.175677 0.512493 0.470736 0.568849 2.34727 0.00500648 30.0445 0.214038 1 69 | 232.66 29.7474 -0.113697 2.35032 166.445 46.2153 0.0533098 -0.032234 132.185 63.1988 0.128137 -0.105453 0.224438 0.533569 0.685241 0.616968 2.34774 0.00496454 26.9416 0.219703 1 70 | 233.553 27.1849 -0.257537 2.31289 164.135 45.9195 0.0449566 -0.024208 134.07 63.3744 0.0872611 -0.0880632 0.109155 0.379387 0.412601 0.486503 2.32539 0.00524945 29.3125 0.212019 1 71 | 233.232 28.2575 -0.104213 2.04934 172.305 48.5417 0.0509246 -0.0294631 118.189 63.5382 0.10061 -0.0860731 0.10627 0.38591 0.548587 0.513409 2.24859 0.00673469 21.8286 0.256655 1 72 | 232.495 27.0275 -0.191768 2.24027 170.38 49.2579 0.0418763 -0.0189799 119.403 63.9244 0.0640076 -0.0459482 0.124831 0.385234 0.653813 0.507656 2.23864 0.00677283 21.0548 0.243957 1 73 | 231.52 29.3092 -0.112481 2.20463 160.35 45.5535 0.0453246 -0.0174562 140.538 64.6065 0.101667 -0.0748601 0.111899 0.32434 0.495122 0.574091 2.25811 0.00644267 25.232 0.185034 1 74 | 232.949 28.8733 -0.236788 2.47816 160.37 44.6006 0.0604789 -0.0248313 141.049 61.3303 0.103429 -0.0820671 0.311801 0.505573 0.768732 0.733022 2.29246 0.00628409 32.7452 0.217806 1 75 | 225.218 34.0474 -0.363109 2.70069 150.627 46.7253 0.0873471 -0.0195975 149.43 59.3348 0.0829797 -0.00536646 0.180493 0.372347 0.554439 0.644663 2.16699 0.00811076 25.488 0.19776 1 76 | 224.521 32.1418 -0.205307 3.16049 144.174 35.8545 0.169878 0.00250972 157.955 45.0163 0.196239 0.0465633 0.156245 0.446974 0.563988 0.592661 2.32472 0.00530783 35.1674 0.202322 1 77 | 225.185 29.7498 -0.165779 3.86255 141.038 31.7331 0.182028 0.0587317 154.439 39.2606 0.243947 0.262795 0.353454 0.488216 0.68685 0.806137 2.15873 0.00784444 35.22 0.196626 1 78 | 214.772 33.1876 -0.082557 2.5266 137.089 34.0205 0.148452 0.136361 148.418 40.6472 0.0614247 0.23849 0.397238 0.482085 0.72651 0.868168 1.73801 0.0188889 51.7 0.154723 1 79 | 206.963 32.2159 -0.242429 2.51773 114.817 27.4542 0.0267226 0.0243459 185.756 37.2992 -0.0579631 0.217594 0.219529 0.37727 0.346154 0.8369 1.72152 0.0200195 59.625 0.150923 1 80 | 207.533 28.4385 0.18305 2.08328 126.083 28.3257 -0.0226013 0.00210906 165.117 41.7225 0.0489698 -0.0181407 0.332061 0.461743 0.358249 0.927734 1.59458 0.0260771 52.8095 0.0832946 1 81 | 212.77 35.4144 0.104977 2.07506 130.397 36.2472 0.069722 0.00828229 169.079 47.924 0.168177 0.00233399 0.137315 0.33924 0.268966 0.760363 1.93787 0.0127811 43.8 0.125506 1 82 | 209.957 35.9054 0.0329904 2.20329 136.229 41.4223 0.0928373 0.0550371 149.829 46.0303 0.0632463 0.113099 0.311415 0.445361 0.416146 0.844268 1.91649 0.0132283 61.4483 0.0808109 1 83 | 237.133 23.7784 0.585574 2.60297 183.476 49.9171 0.0126407 -0.00757586 101.762 70.3631 0.0777011 -0.0247873 0.583226 0.614926 0.717676 0.948896 1.82042 0.0157049 69.5405 0.0573923 1 84 | 220.8 32.9472 -0.0841849 2.70934 149.35 38.397 0.147658 -0.0129172 138.05 43.2764 0.226252 0.0848911 0.220924 0.443205 0.550976 0.748088 1.80368 0.0166568 47.0244 0.103598 1 85 | 217.056 29.013 -0.41445 2.39728 162.688 27.1972 0.0465762 0.0356529 102.395 18.8572 0.118598 0.0165036 0.458114 0.568664 0.719809 0.87078 2.20488 0.00698184 28.371 0.220032 0 86 | 221.071 25.9566 -0.4048 2.70111 164.387 25.2943 0.158611 -0.0133707 102.836 16.7991 0.0363155 -0.00040152 0.351302 0.415045 0.63085 0.873768 2.20972 0.00739645 32.7527 0.201305 0 87 | 219.223 21.3647 -0.0296671 2.56404 163.504 20.5748 0.151256 0.0502913 100.518 14.3511 0.00377272 0.0944589 0.27414 0.455592 0.43808 0.826769 1.98843 0.0112889 44.4 0.16964 0 88 | 203.207 20.0072 0.17998 2.59955 151.768 19.6985 -0.0327517 0.0892325 101.28 11.3742 0.00845121 0.0375723 0.576445 0.5857 0.548048 0.952189 1.65616 0.0225694 32.4583 0.187253 0 89 | 221.444 13.0819 0.0265004 3.55217 172.356 12.2695 -0.170838 -0.0585129 87.3111 9.1841 0.201767 -0.00268994 0.269364 0.434783 0.304348 0.924328 1.20412 0.0625 81.875 0.0662959 0 90 | 211.9 25.7552 0.283069 2.16111 157.04 26.69 0.108139 0.0914808 101.34 16.1278 -0.0459992 0.086278 0.366807 0.444336 1 0.854632 1.42566 0.0382653 42.5714 0.176043 0 91 | 205.625 9.44904 0.665987 4.06596 150 9.43133 0.159313 0.560264 106.325 8.95094 -0.445255 -0.0390145 0.359613 0.562687 0.298507 0.935288 1.38265 0.0433673 28.2143 0.201588 0 92 | 206.263 23.7148 0.00223173 3.19698 153.293 22.5874 0.110803 0.291856 103.902 15.9406 0.0702758 0.163757 0.325275 0.450418 0.768739 0.799714 2.17211 0.007456 40.656 0.178117 0 93 | 208.62 29.7964 0.122054 2.36201 154.663 30.2741 0.131207 0.15598 105.021 23.3229 0.0645522 0.336227 0.223911 0.382197 0.55473 0.769241 2.30819 0.00550571 34.3763 0.191476 0 94 | 188 11.0136 -0.106358 1.34697 125.65 12.551 0.00285515 -0.00134663 142.7 29.3362 0.069912 -0.075212 0.774353 0.833333 0.6 0.987492 0.60206 0.25 125 0.0214432 0 95 | 217.89 29.8785 -0.171577 2.37494 164.622 31.7869 0.114238 -0.00764231 99.3832 24.2156 0.163536 0.316959 0.209127 0.373149 0.427487 0.76211 2.23344 0.00669335 47.125 0.133517 0 96 | 222.519 25.9748 -0.2911 2.30124 168.371 27.3446 0.0966399 -0.152767 97.7809 21.5946 0.228676 0.0414111 0.285567 0.426923 0.31115 0.902814 1.98831 0.0117933 81.7742 0.0577198 0 97 | 211.931 17.823 0.108727 3.03128 158.364 17.3672 -0.00671199 0.173437 100.624 15.2343 0.159665 0.0673203 0.281258 0.43988 0.583219 0.768051 1.97689 0.0111863 60.0968 0.147723 0 98 | 212.876 25.6486 0.627304 3.64677 154.678 25.9113 -0.102786 0.122399 110.384 32.4641 0.396429 0.399099 0.324593 0.522284 0.593557 0.762452 2.02367 0.0104875 44.0119 0.207493 0 99 | 201.079 23.4503 0.71533 3.18292 148 24.443 0.0565841 0.201433 103.175 16.1457 -0.12882 -0.0248261 0.271101 0.397922 0.314685 0.931475 1 0.1 18.2 0.234842 0 100 | -------------------------------------------------------------------------------- /test/plot.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding: utf-8 3 | import numpy as np 4 | import matplotlib.pyplot as plt 5 | 6 | 7 | def plot(vals): 8 | l = len(vals) 9 | x = np.arange(0, l) 10 | y = vals 11 | z = map(abs, np.fft.fft(vals)) 12 | f, (ax1, ax2) = plt.subplots(2, 1) 13 | # original 14 | ax1.plot(x, y, 'o-') 15 | ax1.grid() 16 | ax1.set_xlabel("n") 17 | ax1.set_ylabel("Area") 18 | ax1.set_title("Time Domain") 19 | ax1.set_xlim(0, np.max(x)) 20 | ax1.xaxis.set_ticks([i * l / 8 for i in range(8)]) 21 | # after fft 22 | z[0] = 0 23 | ax2.plot(x, z, 'o-') 24 | ax2.grid() 25 | ax2.set_xlabel("n") 26 | ax2.set_ylabel("Amplitude") 27 | ax2.set_title("Frequency Domain") 28 | ax2.set_xlim(0, np.max(x)) 29 | ax2.xaxis.set_ticks([i * l / 8 for i in range(8)]) 30 | # show result 31 | f.tight_layout() 32 | plt.show() 33 | --------------------------------------------------------------------------------