├── ImgLOC ├── ImgLoc │ ├── bahh.snk │ ├── Aforge │ │ ├── Point.cs │ │ ├── Range.cs │ │ ├── IntRange.cs │ │ ├── DoublePoint.cs │ │ ├── DoubleRange.cs │ │ ├── PolishExpression.cs │ │ ├── Delegates.cs │ │ ├── EventArgs.cs │ │ ├── Exceptions.cs │ │ ├── ThreadSafeRandom.cs │ │ ├── SystemTools.cs │ │ ├── Parallel.cs │ │ └── IntPoint.cs │ ├── imaging │ │ ├── Drawing.cs │ │ ├── Image.cs │ │ ├── ColorConverter.cs │ │ ├── IntegralImage.cs │ │ ├── Interpolation.cs │ │ ├── MemoryManager.cs │ │ ├── TemplateMatch.cs │ │ ├── ICornersDetector.cs │ │ ├── ITemplateMatching.cs │ │ ├── ExhaustiveTemplateMatching.cs │ │ ├── Exceptions.cs │ │ └── ProMacMatch.cs │ ├── app.config │ ├── packages.config │ ├── Properties │ │ ├── Settings.settings │ │ ├── Settings.Designer.cs │ │ └── AssemblyInfo.cs │ ├── README.TXT │ ├── ImgLoc.csproj │ └── ImgLoc.cs ├── ImgLoc.sln ├── .gitattributes ├── .gitignore └── README.md ├── OpencvDLL ├── opencv_core220.dll ├── opencv_imgproc220.dll └── license.txt ├── ImageSearchDLL ├── ImageSearchDLL │ ├── ImageSearchDLL.def │ ├── ImageSearchDLL │ │ ├── util.cpp │ │ ├── stdafx.cpp │ │ ├── ImageSearchDLL.cpp │ │ ├── util.h │ │ ├── stdafx.h │ │ ├── ReadMe.txt │ │ └── ImageSearchDLL.vcproj │ ├── How to compile.txt │ ├── ImageSearchDLL.sln │ └── license.txt ├── Readme.txt ├── ImageSearch.au3 └── license.txt ├── README.md └── LICENSE /ImgLOC/ImgLoc/bahh.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MyBotRun/Libraries/HEAD/ImgLOC/ImgLoc/bahh.snk -------------------------------------------------------------------------------- /ImgLOC/ImgLoc/Aforge/Point.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MyBotRun/Libraries/HEAD/ImgLOC/ImgLoc/Aforge/Point.cs -------------------------------------------------------------------------------- /ImgLOC/ImgLoc/Aforge/Range.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MyBotRun/Libraries/HEAD/ImgLOC/ImgLoc/Aforge/Range.cs -------------------------------------------------------------------------------- /OpencvDLL/opencv_core220.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MyBotRun/Libraries/HEAD/OpencvDLL/opencv_core220.dll -------------------------------------------------------------------------------- /ImgLOC/ImgLoc/Aforge/IntRange.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MyBotRun/Libraries/HEAD/ImgLOC/ImgLoc/Aforge/IntRange.cs -------------------------------------------------------------------------------- /ImgLOC/ImgLoc/imaging/Drawing.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MyBotRun/Libraries/HEAD/ImgLOC/ImgLoc/imaging/Drawing.cs -------------------------------------------------------------------------------- /ImgLOC/ImgLoc/imaging/Image.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MyBotRun/Libraries/HEAD/ImgLOC/ImgLoc/imaging/Image.cs -------------------------------------------------------------------------------- /OpencvDLL/opencv_imgproc220.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MyBotRun/Libraries/HEAD/OpencvDLL/opencv_imgproc220.dll -------------------------------------------------------------------------------- /ImgLOC/ImgLoc/Aforge/DoublePoint.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MyBotRun/Libraries/HEAD/ImgLOC/ImgLoc/Aforge/DoublePoint.cs -------------------------------------------------------------------------------- /ImgLOC/ImgLoc/Aforge/DoubleRange.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MyBotRun/Libraries/HEAD/ImgLOC/ImgLoc/Aforge/DoubleRange.cs -------------------------------------------------------------------------------- /ImageSearchDLL/ImageSearchDLL/ImageSearchDLL.def: -------------------------------------------------------------------------------- 1 | LIBRARY "ImageSearchDLL" 2 | 3 | EXPORTS 4 | 5 | ImageSearch 6 | ImageTest 7 | -------------------------------------------------------------------------------- /ImgLOC/ImgLoc/imaging/ColorConverter.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MyBotRun/Libraries/HEAD/ImgLOC/ImgLoc/imaging/ColorConverter.cs -------------------------------------------------------------------------------- /ImgLOC/ImgLoc/imaging/IntegralImage.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MyBotRun/Libraries/HEAD/ImgLOC/ImgLoc/imaging/IntegralImage.cs -------------------------------------------------------------------------------- /ImgLOC/ImgLoc/imaging/Interpolation.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MyBotRun/Libraries/HEAD/ImgLOC/ImgLoc/imaging/Interpolation.cs -------------------------------------------------------------------------------- /ImgLOC/ImgLoc/imaging/MemoryManager.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MyBotRun/Libraries/HEAD/ImgLOC/ImgLoc/imaging/MemoryManager.cs -------------------------------------------------------------------------------- /ImgLOC/ImgLoc/imaging/TemplateMatch.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MyBotRun/Libraries/HEAD/ImgLOC/ImgLoc/imaging/TemplateMatch.cs -------------------------------------------------------------------------------- /ImgLOC/ImgLoc/Aforge/PolishExpression.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MyBotRun/Libraries/HEAD/ImgLOC/ImgLoc/Aforge/PolishExpression.cs -------------------------------------------------------------------------------- /ImgLOC/ImgLoc/imaging/ICornersDetector.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MyBotRun/Libraries/HEAD/ImgLOC/ImgLoc/imaging/ICornersDetector.cs -------------------------------------------------------------------------------- /ImgLOC/ImgLoc/imaging/ITemplateMatching.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MyBotRun/Libraries/HEAD/ImgLOC/ImgLoc/imaging/ITemplateMatching.cs -------------------------------------------------------------------------------- /ImgLOC/ImgLoc/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /ImgLOC/ImgLoc/imaging/ExhaustiveTemplateMatching.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MyBotRun/Libraries/HEAD/ImgLOC/ImgLoc/imaging/ExhaustiveTemplateMatching.cs -------------------------------------------------------------------------------- /ImageSearchDLL/ImageSearchDLL/ImageSearchDLL/util.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MyBotRun/Libraries/HEAD/ImageSearchDLL/ImageSearchDLL/ImageSearchDLL/util.cpp -------------------------------------------------------------------------------- /ImgLOC/ImgLoc/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /ImageSearchDLL/ImageSearchDLL/How to compile.txt: -------------------------------------------------------------------------------- 1 | This DLL was built using 2 | . Microsoft Visual C++ 2005 Express (a free compiler) 3 | . Visual C++ 2005 Express SP1 4 | . Windows Server 2003 R2 Platform SDK 5 | -------------------------------------------------------------------------------- /ImgLOC/ImgLoc/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /ImageSearchDLL/ImageSearchDLL/ImageSearchDLL/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // ImageSearchDLL.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /ImgLOC/ImgLoc/Aforge/Delegates.cs: -------------------------------------------------------------------------------- 1 | // AForge Core Library 2 | // AForge.NET framework 3 | // http://www.aforgenet.com/framework/ 4 | // 5 | // Copyright © AForge.NET, 2007-2011 6 | // contacts@aforgenet.com 7 | // 8 | 9 | namespace AForge 10 | { 11 | using System; 12 | 13 | /// 14 | /// A delegate which is used by events notifying abount sent/received message. 15 | /// 16 | /// 17 | /// Event sender. 18 | /// Event arguments containing details about the transferred message. 19 | /// 20 | public delegate void MessageTransferHandler( object sender, CommunicationBufferEventArgs eventArgs ); 21 | } 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MyBot 2 | A Free Clash of Clans bot - https://mybot.run 3 | 4 | How to Start Bot - https://mybot.run/forums/showthread.php?tid=4 5 | 6 | How to Report Bug/Help - https://mybot.run/forums/showthread.php?tid=211 7 | 8 | MyBot autoit code is open sourced under GNU GENERAL PUBLIC LICENSE v3 9 | http://www.gnu.org/licenses/gpl-3.0.txt 10 | 11 | Mybot use non-GPL 3rd party libraries for extension : 12 | - OpenCV - BSD license - repository : https://github.com/Itseez/opencv 13 | - ImageSearch - GNU license - repository : https://github.com/MyBotRun/Libraries 14 | - Functional library CGBfunctions.dll - Proprietary library from de Developer Didipe 2015 15 | 16 | 17 | https://github.com/MyBotRun/MyBot/wiki 18 | -------------------------------------------------------------------------------- /ImageSearchDLL/ImageSearchDLL/ImageSearchDLL/ImageSearchDLL.cpp: -------------------------------------------------------------------------------- 1 | // ImageSearchDLL.cpp : Defines the entry point for the DLL application. 2 | // 3 | 4 | #include "stdafx.h" 5 | #include 6 | #include "util.h" 7 | #include 8 | #include 9 | 10 | 11 | #ifdef _MANAGED 12 | #pragma managed(push, off) 13 | #endif 14 | 15 | BOOL APIENTRY DllMain( HMODULE hModule, 16 | DWORD ul_reason_for_call, 17 | LPVOID lpReserved 18 | ) 19 | { 20 | return TRUE; 21 | } 22 | 23 | #ifdef _MANAGED 24 | #pragma managed(pop) 25 | #endif 26 | 27 | 28 | void _tmain() 29 | { 30 | int z; 31 | HBITMAP hbmp = LoadPicture("c:\\pic.bmp",0,0,z,0,0); 32 | char *answer=""; 33 | answer = ImageSearch(0,0,1024,768,"c:\\pic.bmp"); 34 | return; 35 | } -------------------------------------------------------------------------------- /ImageSearchDLL/ImageSearchDLL/ImageSearchDLL.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 9.00 3 | # Visual C++ Express 2005 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ImageSearchDLL", "ImageSearchDLL\ImageSearchDLL.vcproj", "{665FCE36-CFC7-4E16-A978-72E983DE24E5}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | Release|Win32 = Release|Win32 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {665FCE36-CFC7-4E16-A978-72E983DE24E5}.Debug|Win32.ActiveCfg = Release|Win32 13 | {665FCE36-CFC7-4E16-A978-72E983DE24E5}.Debug|Win32.Build.0 = Release|Win32 14 | {665FCE36-CFC7-4E16-A978-72E983DE24E5}.Release|Win32.ActiveCfg = Release|Win32 15 | {665FCE36-CFC7-4E16-A978-72E983DE24E5}.Release|Win32.Build.0 = Release|Win32 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /ImageSearchDLL/ImageSearchDLL/ImageSearchDLL/util.h: -------------------------------------------------------------------------------- 1 | /* 2 | AutoHotkey 3 | 4 | Copyright 2003-2007 Chris Mallett (support@autohotkey.com) 5 | 6 | This program is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU General Public License 8 | as published by the Free Software Foundation; either version 2 9 | of the License, or (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | */ 16 | 17 | 18 | #ifndef util_h 19 | #define util_h 20 | 21 | #include "stdafx.h" // pre-compiled headers 22 | //#include "defines.h" 23 | 24 | HBITMAP LoadPicture(char *aFilespec, int aWidth, int aHeight, int &aImageType, int aIconNumber 25 | , bool aUseGDIPlusIfAvailable); 26 | 27 | char* WINAPI ImageSearch(int aLeft, int aTop, int aRight, int aBottom, char *aImageFile); 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /ImgLOC/ImgLoc/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace ImgLoc.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /ImgLOC/ImgLoc.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Express 14 for Windows Desktop 4 | VisualStudioVersion = 14.0.24720.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImgLoc", "ImgLoc\ImgLoc.csproj", "{C32D19C8-D1A7-413F-B1C5-63B33729C929}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Debug|x86 = Debug|x86 12 | Release|Any CPU = Release|Any CPU 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {C32D19C8-D1A7-413F-B1C5-63B33729C929}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 17 | {C32D19C8-D1A7-413F-B1C5-63B33729C929}.Debug|Any CPU.Build.0 = Debug|Any CPU 18 | {C32D19C8-D1A7-413F-B1C5-63B33729C929}.Debug|x86.ActiveCfg = Debug|Any CPU 19 | {C32D19C8-D1A7-413F-B1C5-63B33729C929}.Debug|x86.Build.0 = Debug|Any CPU 20 | {C32D19C8-D1A7-413F-B1C5-63B33729C929}.Release|Any CPU.ActiveCfg = Release|Any CPU 21 | {C32D19C8-D1A7-413F-B1C5-63B33729C929}.Release|Any CPU.Build.0 = Release|Any CPU 22 | {C32D19C8-D1A7-413F-B1C5-63B33729C929}.Release|x86.ActiveCfg = Release|x86 23 | {C32D19C8-D1A7-413F-B1C5-63B33729C929}.Release|x86.Build.0 = Release|x86 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /ImageSearchDLL/ImageSearchDLL/ImageSearchDLL/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | // Modify the following defines if you have to target a platform prior to the ones specified below. 9 | // Refer to MSDN for the latest info on corresponding values for different platforms. 10 | #ifndef WINVER // Allow use of features specific to Windows XP or later. 11 | #define WINVER 0x0501 // Change this to the appropriate value to target other versions of Windows. 12 | #endif 13 | 14 | #ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later. 15 | #define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows. 16 | #endif 17 | 18 | #ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later. 19 | #define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later. 20 | #endif 21 | 22 | #ifndef _WIN32_IE // Allow use of features specific to IE 6.0 or later. 23 | #define _WIN32_IE 0x0600 // Change this to the appropriate value to target other versions of IE. 24 | #endif 25 | 26 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 27 | // Windows Header Files: 28 | #include 29 | #include 30 | #include 31 | 32 | 33 | 34 | // TODO: reference additional headers your program requires here 35 | -------------------------------------------------------------------------------- /ImgLOC/ImgLoc/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("ImgLoc")] 9 | [assembly: AssemblyDescription("Customized DLL for Image Detection")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("MyBot.run")] 12 | [assembly: AssemblyProduct("@trlopes customized DLL for MyBotRun")] 13 | [assembly: AssemblyCopyright("Copyright © 2016")] 14 | [assembly: AssemblyTrademark("AForge.NET © 2008-2012")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | 18 | // Setting ComVisible to false makes the types in this assembly not visible 19 | // to COM components. If you need to access a type in this assembly from 20 | // COM, set the ComVisible attribute to true on that type. 21 | [assembly: ComVisible(true)] 22 | 23 | // The following GUID is for the ID of the typelib if this project is exposed to COM 24 | [assembly: Guid("c32d19c8-d1a7-413f-b1c5-63b33729c929")] 25 | 26 | // Version information for an assembly consists of the following four values: 27 | // 28 | // Major Version 29 | // Minor Version 30 | // Build Number 31 | // Revision 32 | // 33 | // You can specify all the values or you can default the Build and Revision Numbers 34 | // by using the '*' as shown below: 35 | // [assembly: AssemblyVersion("1.0.*")] 36 | [assembly: AssemblyVersion("1.0.0.5")] 37 | [assembly: AssemblyFileVersion("1.0.0.5")] 38 | -------------------------------------------------------------------------------- /ImageSearchDLL/ImageSearchDLL/ImageSearchDLL/ReadMe.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | DYNAMIC LINK LIBRARY : ImageSearchDLL Project Overview 3 | ======================================================================== 4 | 5 | AppWizard has created this ImageSearchDLL DLL for you. 6 | 7 | This file contains a summary of what you will find in each of the files that 8 | make up your ImageSearchDLL application. 9 | 10 | 11 | ImageSearchDLL.vcproj 12 | This is the main project file for VC++ projects generated using an Application Wizard. 13 | It contains information about the version of Visual C++ that generated the file, and 14 | information about the platforms, configurations, and project features selected with the 15 | Application Wizard. 16 | 17 | ImageSearchDLL.cpp 18 | This is the main DLL source file. 19 | 20 | When created, this DLL does not export any symbols. As a result, it 21 | will not produce a .lib file when it is built. If you wish this project 22 | to be a project dependency of some other project, you will either need to 23 | add code to export some symbols from the DLL so that an export library 24 | will be produced, or you can set the Ignore Input Library property to Yes 25 | on the General propert page of the Linker folder in the project's Property 26 | Pages dialog box. 27 | 28 | ///////////////////////////////////////////////////////////////////////////// 29 | Other standard files: 30 | 31 | StdAfx.h, StdAfx.cpp 32 | These files are used to build a precompiled header (PCH) file 33 | named ImageSearchDLL.pch and a precompiled types file named StdAfx.obj. 34 | 35 | ///////////////////////////////////////////////////////////////////////////// 36 | Other notes: 37 | 38 | AppWizard uses "TODO:" comments to indicate parts of the source code you 39 | should add to or customize. 40 | 41 | ///////////////////////////////////////////////////////////////////////////// 42 | -------------------------------------------------------------------------------- /ImageSearchDLL/Readme.txt: -------------------------------------------------------------------------------- 1 | ImageSearch for AutoIT 2 | ======================== 3 | 4 | A DLL library to allow search for an image within the desktop. Also included 5 | are a AU3 library wrapper, and a sample AU3 program to get you going. All the 6 | code here is licensed under GPLv2, as it based on the AutoHotKey. See 7 | License.txt for info. 8 | 9 | The DLL was built from a need to do searching a for an image within the desktop. 10 | I support an ERP application which uses plenty of Java Applets, and needed scripting 11 | automation for mass upload of data. The only way to detect that a record has 12 | been properly updated was to check for a "success" image. The PixelSearch feature 13 | was useful, but a pain to program for this purpose. At first I found an image 14 | library from www.mjtnet.com which did the job, but was slow (and of uncertain copyright). 15 | 16 | AutoHotKey had the function, but I'm a fan of AutoIT, and too lazy to learn a 17 | new scripting syntax. Seeing that AutoHotKey was opensourced, I took the chance 18 | to strip out the necessary code and compile it into a DLL using VC++ 2005 19 | express. The whole exercise was particularly challenging since I've never 20 | done VC++ before, being more a Java person. 21 | 22 | Anyway, here it is. The source code is awful, since I just needed something 23 | working, and just cut and pasted all the necessary parts together. Hope it 24 | works for you, since the redistribution of VC++ express applications seems 25 | to be quite challenging, and I could have got it wrong. 26 | 27 | 28 | Instructions 29 | ================ 30 | . Copy ImageSearchDLL.dll to the windows directory (or any path reachable directory) 31 | . Copy ImageSearch.au3 to \AutoIt3\include\ directory 32 | . Give the ImageSearchDemo.au3 a spin. Good luck! 33 | 34 | 35 | Credits 36 | =============== 37 | . AutoHotKey for the source code - Which this DLL is based on 38 | . Aurelian Maga and Chris Mallett for the original code 39 | . The folks at AutoHotKey forum for instructions on how to install and compile AHK with VC++ 40 | 41 | 42 | ________________________________ 43 | Live long and prosper, 44 | kangkeng 2008 45 | -------------------------------------------------------------------------------- /OpencvDLL/license.txt: -------------------------------------------------------------------------------- 1 | By downloading, copying, installing or using the software you agree to this license. 2 | If you do not agree to this license, do not download, install, 3 | copy or use the software. 4 | 5 | 6 | License Agreement 7 | For Open Source Computer Vision Library 8 | (3-clause BSD License) 9 | 10 | Copyright (C) 2000-2015, Intel Corporation, all rights reserved. 11 | Copyright (C) 2009-2011, Willow Garage Inc., all rights reserved. 12 | Copyright (C) 2009-2015, NVIDIA Corporation, all rights reserved. 13 | Copyright (C) 2010-2013, Advanced Micro Devices, Inc., all rights reserved. 14 | Copyright (C) 2015, OpenCV Foundation, all rights reserved. 15 | Copyright (C) 2015, Itseez Inc., all rights reserved. 16 | Third party copyrights are property of their respective owners. 17 | 18 | Redistribution and use in source and binary forms, with or without modification, 19 | are permitted provided that the following conditions are met: 20 | 21 | * Redistributions of source code must retain the above copyright notice, 22 | this list of conditions and the following disclaimer. 23 | 24 | * Redistributions in binary form must reproduce the above copyright notice, 25 | this list of conditions and the following disclaimer in the documentation 26 | and/or other materials provided with the distribution. 27 | 28 | * Neither the names of the copyright holders nor the names of the contributors 29 | may be used to endorse or promote products derived from this software 30 | without specific prior written permission. 31 | 32 | This software is provided by the copyright holders and contributors "as is" and 33 | any express or implied warranties, including, but not limited to, the implied 34 | warranties of merchantability and fitness for a particular purpose are disclaimed. 35 | In no event shall copyright holders or contributors be liable for any direct, 36 | indirect, incidental, special, exemplary, or consequential damages 37 | (including, but not limited to, procurement of substitute goods or services; 38 | loss of use, data, or profits; or business interruption) however caused 39 | and on any theory of liability, whether in contract, strict liability, 40 | or tort (including negligence or otherwise) arising in any way out of 41 | the use of this software, even if advised of the possibility of such damage. -------------------------------------------------------------------------------- /ImgLOC/.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /ImgLOC/ImgLoc/Aforge/EventArgs.cs: -------------------------------------------------------------------------------- 1 | // AForge Core Library 2 | // AForge.NET framework 3 | // http://www.aforgenet.com/framework/ 4 | // 5 | // Copyright © AForge.NET, 2007-2011 6 | // contacts@aforgenet.com 7 | // 8 | 9 | namespace AForge 10 | { 11 | using System; 12 | 13 | /// 14 | /// Event arguments holding a buffer sent or received during some communication process. 15 | /// 16 | public class CommunicationBufferEventArgs : EventArgs 17 | { 18 | private readonly byte[] message; 19 | private readonly int index; 20 | private readonly int length; 21 | 22 | /// 23 | /// Length of the transfered message. 24 | /// 25 | public int MessageLength 26 | { 27 | get { return length; } 28 | } 29 | 30 | /// 31 | /// Initializes a new instance of the class. 32 | /// 33 | /// 34 | /// Message being transfered during communication process. 35 | /// 36 | public CommunicationBufferEventArgs( byte[] message ) 37 | { 38 | this.message = message; 39 | this.index = 0; 40 | this.length = message.Length; 41 | } 42 | 43 | /// 44 | /// Initializes a new instance of the class. 45 | /// 46 | /// 47 | /// Buffer containing the message being transferred during communication process. 48 | /// Starting index of the message within the buffer. 49 | /// Length of the message within the buffer. 50 | /// 51 | public CommunicationBufferEventArgs( byte[] buffer, int index, int length ) 52 | { 53 | this.message = buffer; 54 | this.index = index; 55 | this.length = length; 56 | } 57 | 58 | /// 59 | /// Get the transfered message. 60 | /// 61 | /// 62 | /// Returns copy of the transfered message. 63 | /// 64 | public byte[] GetMessage( ) 65 | { 66 | byte[] ret = new byte[length]; 67 | Array.Copy( message, index, ret, 0, length ); 68 | return ret; 69 | } 70 | 71 | /// 72 | /// Get the transferred message as string. 73 | /// 74 | /// 75 | /// Returns string encoding the transferred message. 76 | /// 77 | public string GetMessageString( ) 78 | { 79 | return BitConverter.ToString( message, index, length ); 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /ImgLOC/ImgLoc/Aforge/Exceptions.cs: -------------------------------------------------------------------------------- 1 | // AForge Core Library 2 | // AForge.NET framework 3 | // http://www.aforgenet.com/framework/ 4 | // 5 | // Copyright © Andrew Kirillov, 2007-2009 6 | // andrew.kirillov@aforgenet.com 7 | // 8 | 9 | namespace AForge 10 | { 11 | using System; 12 | 13 | /// 14 | /// Connection failed exception. 15 | /// 16 | /// 17 | /// The exception is thrown in the case if connection to device 18 | /// has failed. 19 | /// 20 | /// 21 | public class ConnectionFailedException : Exception 22 | { 23 | /// 24 | /// Initializes a new instance of the class. 25 | /// 26 | /// 27 | /// Exception's message. 28 | /// 29 | public ConnectionFailedException( string message ) : 30 | base( message ) { } 31 | } 32 | 33 | /// 34 | /// Connection lost exception. 35 | /// 36 | /// 37 | /// The exception is thrown in the case if connection to device 38 | /// is lost. When the exception is caught, user may need to reconnect to the device. 39 | /// 40 | /// 41 | public class ConnectionLostException : Exception 42 | { 43 | /// 44 | /// Initializes a new instance of the class. 45 | /// 46 | /// 47 | /// Exception's message. 48 | /// 49 | public ConnectionLostException( string message ) : 50 | base( message ) { } 51 | } 52 | 53 | /// 54 | /// Not connected exception. 55 | /// 56 | /// 57 | /// The exception is thrown in the case if connection to device 58 | /// is not established, but user requests for its services. 59 | /// 60 | /// 61 | public class NotConnectedException : Exception 62 | { 63 | /// 64 | /// Initializes a new instance of the class. 65 | /// 66 | /// 67 | /// Exception's message. 68 | /// 69 | public NotConnectedException( string message ) : 70 | base( message ) { } 71 | } 72 | 73 | /// 74 | /// Device busy exception. 75 | /// 76 | /// 77 | /// The exception is thrown in the case if access to certain device 78 | /// is not available due to the fact that it is currently busy handling other request/connection. 79 | /// 80 | /// 81 | public class DeviceBusyException : Exception 82 | { 83 | /// 84 | /// Initializes a new instance of the class. 85 | /// 86 | /// 87 | /// Exception's message. 88 | /// 89 | public DeviceBusyException( string message ) : 90 | base( message ) { } 91 | } 92 | 93 | /// 94 | /// Device error exception. 95 | /// 96 | /// 97 | /// The exception is thrown in the case if some error happens with a device, which 98 | /// may need to be reported to user. 99 | /// 100 | public class DeviceErrorException : Exception 101 | { 102 | /// 103 | /// Initializes a new instance of the class. 104 | /// 105 | /// 106 | /// Exception's message. 107 | /// 108 | public DeviceErrorException( string message ) : 109 | base( message ) { } 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /ImgLOC/ImgLoc/imaging/Exceptions.cs: -------------------------------------------------------------------------------- 1 | // AForge Image Processing Library 2 | // AForge.NET framework 3 | // http://www.aforgenet.com/framework/ 4 | // 5 | // Copyright © AForge.NET, 2005-2011 6 | // contacts@aforgenet.com 7 | // 8 | 9 | namespace AForge.Imaging 10 | { 11 | using System; 12 | 13 | /// 14 | /// Unsupported image format exception. 15 | /// 16 | /// 17 | /// The unsupported image format exception is thrown in the case when 18 | /// user passes an image of certain format to an image processing routine, which does 19 | /// not support the format. Check documentation of the image processing routine 20 | /// to discover which formats are supported by the routine. 21 | /// 22 | /// 23 | public class UnsupportedImageFormatException : ArgumentException 24 | { 25 | /// 26 | /// Initializes a new instance of the class. 27 | /// 28 | public UnsupportedImageFormatException( ) { } 29 | 30 | /// 31 | /// Initializes a new instance of the class. 32 | /// 33 | /// 34 | /// Message providing some additional information. 35 | /// 36 | public UnsupportedImageFormatException( string message ) : 37 | base( message ) { } 38 | 39 | /// 40 | /// Initializes a new instance of the class. 41 | /// 42 | /// 43 | /// Message providing some additional information. 44 | /// Name of the invalid parameter. 45 | /// 46 | public UnsupportedImageFormatException( string message, string paramName ) : 47 | base( message, paramName ) { } 48 | } 49 | 50 | /// 51 | /// Invalid image properties exception. 52 | /// 53 | /// 54 | /// The invalid image properties exception is thrown in the case when 55 | /// user provides an image with certain properties, which are treated as invalid by 56 | /// particular image processing routine. Another case when this exception is 57 | /// thrown is the case when user tries to access some properties of an image (or 58 | /// of a recently processed image by some routine), which are not valid for that image. 59 | /// 60 | /// 61 | public class InvalidImagePropertiesException : ArgumentException 62 | { 63 | /// 64 | /// Initializes a new instance of the class. 65 | /// 66 | public InvalidImagePropertiesException( ) { } 67 | 68 | /// 69 | /// Initializes a new instance of the class. 70 | /// 71 | /// 72 | /// Message providing some additional information. 73 | /// 74 | public InvalidImagePropertiesException( string message ) : 75 | base( message ) { } 76 | 77 | /// 78 | /// Initializes a new instance of the class. 79 | /// 80 | /// 81 | /// Message providing some additional information. 82 | /// Name of the invalid parameter. 83 | /// 84 | public InvalidImagePropertiesException( string message, string paramName ) : 85 | base( message, paramName ) { } 86 | } 87 | 88 | // Some common exception messages 89 | internal static class ExceptionMessage 90 | { 91 | public const string ColorHistogramException = "Cannot access color histogram since the last processed image was grayscale."; 92 | public const string GrayHistogramException = "Cannot access gray histogram since the last processed image was color."; 93 | } 94 | } -------------------------------------------------------------------------------- /ImgLOC/ImgLoc/README.TXT: -------------------------------------------------------------------------------- 1 | 2 | 3 | ImgLoc V2 Available Functions 4 | 5 | Name: SearchTile : Returns string in format "#Positions|X1|Y1|X2|Y2|Xn|Yn" 6 | Arguments: 7 | 1. $sendHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) Type: IntPtr (handle) Description: SourceImage from memmory. 8 | 2. $FFile = PATH TO FILE (.bmp/.png) Type: string Description: Tile imge to search in SourceImage 9 | 3. $Tolerance = 0.XX Type: float Description: tolerance to be used in image compare 10 | Usage: $res = DllCall($LibDir & "\ImgLoc.dll", "str", "SearchTile", "handle", $sendHBitmap, "str", $FFile , "float", $Tolerance) 11 | 12 | NOTE: Will Always search Inside COCDIamond and CocArea 13 | ------- 14 | 15 | Name: SearchInSource: Returns string in format "#Positions|X1|Y1|X2|Y2|Xn|Yn" 16 | Arguments: 17 | 1. $OFile = PATH TO FILE (.bmp/.png) Type: string Description: SourceImage from file. 18 | 2. $FFile = PATH TO FILE (.bmp/.png) Type: string Description: Tile imge to search in SourceImage 19 | 3. $Tolerance = 0.XX Type: float Description: tolerance to be used in image compare 20 | Usage: $res = DllCall($LibDir & "\ImgLoc.dll", "str", "SearchInSource", "str", $OFile, "str", $FFile , "float", $Tolerance) 21 | NOTE: Will Always search Inside COCDIamond and CocArea 22 | ------- 23 | 24 | Name: SearchArea: Returns string in format "#Positions|X1|Y1|X2|Y2|Xn|Yn" 25 | Arguments: 26 | 1. $sendHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) Type: IntPtr (handle) Description: SourceImage from memmory. 27 | 2. $FFile = PATH TO FILE (.bmp/.png) Type: string Description: Tile imge to search in SourceImage 28 | 3. $Tolerance = 0.XX Type: float Description: tolerance to be used in image compare 29 | 4. $X = 100 Type: Int Description: X Start Position for Search Area Defenition 30 | 5. $Y = 100 Type: Int Description: Y Start Position for Search Area Defenition 31 | 6. $W = 250 Type: Int Description: Search Area WIDTH 32 | 7. $H = 250 Type: Int Description: Search Area HEIGTH 33 | Usage: $res = DllCall($LibDir & "\ImgLoc.dll", "str", "SearchArea", "str", $OFile, "str", $FFile , "float", $Tolerance, "int", $X, "int", $Y, "int", $W, "int", $W ) 34 | NOTE: Will Always search Inside COCDIamond And (COCAREA is defined by SearchArea sepcified in the given coordinates) 35 | 36 | 37 | Current Values for COCDiamond and COCAREA 38 | 39 | CocDiamond: Polygon defined with the following coordinates: topP -> rightP -> BottomP -> LeftP -> TopP 40 | 41 | TopP = (430, 70) 42 | LeftP = (67, 333) 43 | RightP = (787, 335); 44 | BottomP = (430, 605); 45 | 46 | COCArea: Rectangle defined with the following size: (area delimited by the vertices of the building area) 47 | X: 70 48 | Y: 70 49 | WIDHT: 720 50 | HEIGHT: 540 51 | --------------------------------------------------- 52 | 53 | 54 | 27-01-2016 55 | 56 | IMGLocV3 57 | 58 | Forget SearchArea Function 59 | 60 | Only Function is SearchTile & SearchInSource with the following arguments 61 | 62 | SearchTile will also work as a search area... 63 | 64 | Name: SearchTile : Returns string in format "#Positions|X1|Y1|X2|Y2|Xn|Yn" 65 | Arguments: 66 | 1. $sendHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) Type: IntPtr (handle) Description: SourceImage from memmory. 67 | 2. $FFile = PATH TO FILE (.bmp/.png) Type: string Description: Tile imge to search in SourceImage 68 | 3. $Tolerance = 0.XX Type: float Description: tolerance to be used in image compare 69 | 4. $SearchArea = "70|70|720|540" Type: string Description: rectangle in format x|y|Width|Height 70 | 5. $CodDiamond = "430,70|787,335|430,605|67,333" Type: string Description: 4 points that form a poligon top +left + bottom + right in the format x,y|x1,y1|xn,yn... 71 | 72 | Usage: $res = DllCall($LibDir & "\ImgLoc.dll", "str", "SearchTile", "handle", $sendHBitmap, "str", $FFile , "float", $Tolerance, "string",$DefaultCocSearchArea "string",$DefaultCocDiamond ) 73 | 74 | NOTE: Will Always search Inside COCDIamond and SearchArea (points must be inside intersection) 75 | 76 | 77 | 78 | $DefaultCocDiamond (DEFAULT No GRass ) "430,70|787,335|430,605|67,333" 79 | $ExtendedCocDiamond (With Grass ) "430,25|840,335|430,645|15,333" 80 | 81 | $DefaultCocSearchArea (Deafault) "70|70|720|540" 82 | $ExtendedCocSearchArea (Extended) "15|25|825|625" 83 | -------------------------------------------------------------------------------- /ImgLOC/.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | build/ 21 | bld/ 22 | [Bb]in/ 23 | [Oo]bj/ 24 | 25 | # Visual Studio 2015 cache/options directory 26 | .vs/ 27 | 28 | # MSTest test Results 29 | [Tt]est[Rr]esult*/ 30 | [Bb]uild[Ll]og.* 31 | 32 | # NUNIT 33 | *.VisualState.xml 34 | TestResult.xml 35 | 36 | # Build Results of an ATL Project 37 | [Dd]ebugPS/ 38 | [Rr]eleasePS/ 39 | dlldata.c 40 | 41 | # DNX 42 | project.lock.json 43 | artifacts/ 44 | 45 | *_i.c 46 | *_p.c 47 | *_i.h 48 | *.ilk 49 | *.meta 50 | *.obj 51 | *.pch 52 | *.pdb 53 | *.pgc 54 | *.pgd 55 | *.rsp 56 | *.sbr 57 | *.tlb 58 | *.tli 59 | *.tlh 60 | *.tmp 61 | *.tmp_proj 62 | *.log 63 | *.vspscc 64 | *.vssscc 65 | .builds 66 | *.pidb 67 | *.svclog 68 | *.scc 69 | 70 | # Chutzpah Test files 71 | _Chutzpah* 72 | 73 | # Visual C++ cache files 74 | ipch/ 75 | *.aps 76 | *.ncb 77 | *.opensdf 78 | *.sdf 79 | *.cachefile 80 | 81 | # Visual Studio profiler 82 | *.psess 83 | *.vsp 84 | *.vspx 85 | 86 | # TFS 2012 Local Workspace 87 | $tf/ 88 | 89 | # Guidance Automation Toolkit 90 | *.gpState 91 | 92 | # ReSharper is a .NET coding add-in 93 | _ReSharper*/ 94 | *.[Rr]e[Ss]harper 95 | *.DotSettings.user 96 | 97 | # JustCode is a .NET coding add-in 98 | .JustCode 99 | 100 | # TeamCity is a build add-in 101 | _TeamCity* 102 | 103 | # DotCover is a Code Coverage Tool 104 | *.dotCover 105 | 106 | # NCrunch 107 | _NCrunch_* 108 | .*crunch*.local.xml 109 | 110 | # MightyMoose 111 | *.mm.* 112 | AutoTest.Net/ 113 | 114 | # Web workbench (sass) 115 | .sass-cache/ 116 | 117 | # Installshield output folder 118 | [Ee]xpress/ 119 | 120 | # DocProject is a documentation generator add-in 121 | DocProject/buildhelp/ 122 | DocProject/Help/*.HxT 123 | DocProject/Help/*.HxC 124 | DocProject/Help/*.hhc 125 | DocProject/Help/*.hhk 126 | DocProject/Help/*.hhp 127 | DocProject/Help/Html2 128 | DocProject/Help/html 129 | 130 | # Click-Once directory 131 | publish/ 132 | 133 | # Publish Web Output 134 | *.[Pp]ublish.xml 135 | *.azurePubxml 136 | ## TODO: Comment the next line if you want to checkin your 137 | ## web deploy settings but do note that will include unencrypted 138 | ## passwords 139 | #*.pubxml 140 | 141 | *.publishproj 142 | 143 | # NuGet Packages 144 | *.nupkg 145 | # The packages folder can be ignored because of Package Restore 146 | **/packages/* 147 | # except build/, which is used as an MSBuild target. 148 | !**/packages/build/ 149 | # Uncomment if necessary however generally it will be regenerated when needed 150 | #!**/packages/repositories.config 151 | 152 | # Windows Azure Build Output 153 | csx/ 154 | *.build.csdef 155 | 156 | # Windows Store app package directory 157 | AppPackages/ 158 | 159 | # Visual Studio cache files 160 | # files ending in .cache can be ignored 161 | *.[Cc]ache 162 | # but keep track of directories ending in .cache 163 | !*.[Cc]ache/ 164 | 165 | # Others 166 | ClientBin/ 167 | [Ss]tyle[Cc]op.* 168 | ~$* 169 | *~ 170 | *.dbmdl 171 | *.dbproj.schemaview 172 | *.pfx 173 | *.publishsettings 174 | node_modules/ 175 | orleans.codegen.cs 176 | 177 | # RIA/Silverlight projects 178 | Generated_Code/ 179 | 180 | # Backup & report files from converting an old project file 181 | # to a newer Visual Studio version. Backup files are not needed, 182 | # because we have git ;-) 183 | _UpgradeReport_Files/ 184 | Backup*/ 185 | UpgradeLog*.XML 186 | UpgradeLog*.htm 187 | 188 | # SQL Server files 189 | *.mdf 190 | *.ldf 191 | 192 | # Business Intelligence projects 193 | *.rdl.data 194 | *.bim.layout 195 | *.bim_*.settings 196 | 197 | # Microsoft Fakes 198 | FakesAssemblies/ 199 | 200 | # Node.js Tools for Visual Studio 201 | .ntvs_analysis.dat 202 | 203 | # Visual Studio 6 build log 204 | *.plg 205 | 206 | # Visual Studio 6 workspace options file 207 | *.opt 208 | 209 | # LightSwitch generated files 210 | GeneratedArtifacts/ 211 | _Pvt_Extensions/ 212 | ModelManifest.xml 213 | -------------------------------------------------------------------------------- /ImgLOC/README.md: -------------------------------------------------------------------------------- 1 | 2 | ----------------------------------------------------------------------------- Version 5 3 | ImgLoc V5 Available Functions 4 | 5 | Name: MBRSearchImage : Returns string in format "#Positions|X1|Y1|X2|Y2|Xn|Yn" 6 | Arguments: 7 | 1. $sendHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) Type: IntPtr (handle) Description: SourceImage from memmory. 8 | 2. $FFile = PATH TO FILE (.bmp/.png) Type: string Description: Tile imge to search in SourceImage 9 | 3. $Tolerance = 0.XX Type: float Description: tolerance to be used in image compare 10 | Usage: $res = DllCall($LibDir & "\ImgLoc.dll", "str", "SearchTile", "handle", $sendHBitmap, "str", $FFile , "float", $Tolerance) 11 | 12 | Name: SearchTile : Returns string in format "#Positions|X1|Y1|X2|Y2|Xn|Yn" 13 | Name: SearchInSource: Returns string in format "#Positions|X1|Y1|X2|Y2|Xn|Yn" 14 | Arguments: 15 | 1. $sendHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) Type: IntPtr (handle) Description: SourceImage from memmory. 16 | (1. For SearchInSource the 1st argument is the file path); 17 | 2. $FFile = PATH TO FILE (.bmp/.png) Type: string Description: Tile imge to search in SourceImage 18 | 3. $Tolerance = 0.XX Type: float Description: tolerance to be used in image compare 19 | 4. $SearchArea = "70|70|720|540" Type: string Description: rectangle in format x|y|Width|Height 20 | 5. $CodDiamond = "430,70|787,335|430,605|67,333" Type: string Description: 4 points that form a poligon top +left + bottom + right in the format x,y|x1,y1|xn,yn... 21 | 22 | Usage: $res = DllCall($LibDir & "\ImgLoc.dll", "str", "SearchTile", "handle", $sendHBitmap, "str", $FFile , "float", $Tolerance, "str",$DefaultCocSearchArea "str",$DefaultCocDiamond ) 23 | 24 | ----------------------------------------------------------------------------- Version 2 25 | ImgLoc V2 Available Functions 26 | 27 | Name: SearchTile : Returns string in format "#Positions|X1|Y1|X2|Y2|Xn|Yn" 28 | Arguments: 29 | 1. $sendHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) Type: IntPtr (handle) Description: SourceImage from memmory. 30 | 2. $FFile = PATH TO FILE (.bmp/.png) Type: string Description: Tile imge to search in SourceImage 31 | 3. $Tolerance = 0.XX Type: float Description: tolerance to be used in image compare 32 | Usage: $res = DllCall($LibDir & "\ImgLoc.dll", "str", "SearchTile", "handle", $sendHBitmap, "str", $FFile , "float", $Tolerance) 33 | 34 | NOTE: Will Always search Inside COCDIamond and CocArea 35 | ------- 36 | 37 | Name: SearchInSource: Returns string in format "#Positions|X1|Y1|X2|Y2|Xn|Yn" 38 | Arguments: 39 | 1. $OFile = PATH TO FILE (.bmp/.png) Type: string Description: SourceImage from file. 40 | 2. $FFile = PATH TO FILE (.bmp/.png) Type: string Description: Tile imge to search in SourceImage 41 | 3. $Tolerance = 0.XX Type: float Description: tolerance to be used in image compare 42 | Usage: $res = DllCall($LibDir & "\ImgLoc.dll", "str", "SearchInSource", "str", $OFile, "str", $FFile , "float", $Tolerance) 43 | NOTE: Will Always search Inside COCDIamond and CocArea 44 | ------- 45 | 46 | Name: SearchArea: Returns string in format "#Positions|X1|Y1|X2|Y2|Xn|Yn" 47 | Arguments: 48 | 1. $sendHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) Type: IntPtr (handle) Description: SourceImage from memmory. 49 | 2. $FFile = PATH TO FILE (.bmp/.png) Type: string Description: Tile imge to search in SourceImage 50 | 3. $Tolerance = 0.XX Type: float Description: tolerance to be used in image compare 51 | 4. $X = 100 Type: Int Description: X Start Position for Search Area Defenition 52 | 5. $Y = 100 Type: Int Description: Y Start Position for Search Area Defenition 53 | 6. $W = 250 Type: Int Description: Search Area WIDTH 54 | 7. $H = 250 Type: Int Description: Search Area HEIGTH 55 | Usage: $res = DllCall($LibDir & "\ImgLoc.dll", "str", "SearchArea", "str", $OFile, "str", $FFile , "float", $Tolerance, "int", $X, "int", $Y, "int", $W, "int", $W ) 56 | NOTE: Will Always search Inside COCDIamond And (COCAREA is defined by SearchArea sepcified in the given coordinates) 57 | 58 | 59 | Current Values for COCDiamond and COCAREA 60 | 61 | CocDiamond: Polygon defined with the following coordinates: topP -> rightP -> BottomP -> LeftP -> TopP 62 | 63 | TopP = (430, 70) 64 | LeftP = (67, 333) 65 | RightP = (787, 335); 66 | BottomP = (430, 605); 67 | 68 | COCArea: Rectangle defined with the following size: (area delimited by the vertices of the building area) 69 | X: 70 70 | Y: 70 71 | WIDHT: 720 72 | HEIGHT: 540 73 | 74 | 75 | TODO: Make availabe the possibility to define your own COCDiamond. 76 | 77 | -------------------------------------------------------------------------------- /ImgLOC/ImgLoc/Aforge/ThreadSafeRandom.cs: -------------------------------------------------------------------------------- 1 | // AForge Core Library 2 | // AForge.NET framework 3 | // http://www.aforgenet.com/framework/ 4 | // 5 | // Copyright © AForge.NET, 2011 6 | // contacts@aforgenet.com 7 | // 8 | 9 | namespace AForge 10 | { 11 | using System; 12 | 13 | /// 14 | /// Thread safe version of the class. 15 | /// 16 | /// 17 | /// The class inherits the and overrides 18 | /// its random numbers generation methods providing thread safety by guarding call 19 | /// to the base class with a lock. See documentation to for 20 | /// additional information about the base class. 21 | /// 22 | public sealed class ThreadSafeRandom : Random 23 | { 24 | private object sync = new object( ); 25 | 26 | /// 27 | /// Initializes a new instance of the class. 28 | /// 29 | /// 30 | /// See for more information. 31 | /// 32 | public ThreadSafeRandom( ) 33 | : base( ) 34 | { 35 | } 36 | 37 | /// 38 | /// Initializes a new instance of the class. 39 | /// 40 | /// 41 | /// A number used to calculate a starting value for the pseudo-random number sequence. 42 | /// If a negative number is specified, the absolute value of the number is used. 43 | /// 44 | /// 45 | /// See for more information. 46 | /// 47 | public ThreadSafeRandom( int seed ) 48 | : base( seed ) 49 | { 50 | } 51 | 52 | /// 53 | /// Returns a nonnegative random number. 54 | /// 55 | /// 56 | /// Returns a 32-bit signed integer greater than or equal to zero and less than 57 | /// . 58 | /// 59 | /// See for more information. 60 | /// 61 | public override int Next( ) 62 | { 63 | lock ( sync ) return base.Next( ); 64 | } 65 | 66 | /// 67 | /// Returns a nonnegative random number less than the specified maximum. 68 | /// 69 | /// 70 | /// The exclusive upper bound of the random number to be generated. 71 | /// must be greater than or equal to zero. 72 | /// 73 | /// Returns a 32-bit signed integer greater than or equal to zero, and less than ; 74 | /// that is, the range of return values ordinarily includes zero but not . 75 | /// 76 | /// See for more information. 77 | /// 78 | public override int Next( int maxValue ) 79 | { 80 | lock ( sync ) return base.Next( maxValue ); 81 | } 82 | 83 | /// 84 | /// Returns a random number within a specified range. 85 | /// 86 | /// 87 | /// The inclusive lower bound of the random number returned. 88 | /// The exclusive upper bound of the random number returned. 89 | /// must be greater than or equal to . 90 | /// 91 | /// Returns a 32-bit signed integer greater than or equal to and less 92 | /// than ; that is, the range of return values includes 93 | /// but not . 94 | /// 95 | /// See for more information. 96 | /// 97 | public override int Next( int minValue, int maxValue ) 98 | { 99 | lock ( sync ) return base.Next( minValue, maxValue ); 100 | } 101 | 102 | /// 103 | /// Fills the elements of a specified array of bytes with random numbers. 104 | /// 105 | /// 106 | /// An array of bytes to contain random numbers. 107 | /// 108 | /// See for more information. 109 | /// 110 | public override void NextBytes( byte[] buffer ) 111 | { 112 | lock ( sync ) base.NextBytes( buffer ); 113 | } 114 | 115 | /// 116 | /// Returns a random number between 0.0 and 1.0. 117 | /// 118 | /// 119 | /// Returns a double-precision floating point number greater than or equal to 0.0, and less than 1.0. 120 | /// 121 | /// See for more information. 122 | /// 123 | public override double NextDouble( ) 124 | { 125 | lock ( sync ) return base.NextDouble( ); 126 | } 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /ImageSearchDLL/ImageSearchDLL/ImageSearchDLL/ImageSearchDLL.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 14 | 15 | 16 | 17 | 18 | 25 | 28 | 31 | 34 | 37 | 40 | 52 | 55 | 58 | 61 | 70 | 73 | 76 | 79 | 82 | 85 | 88 | 91 | 94 | 95 | 103 | 106 | 109 | 112 | 115 | 118 | 127 | 130 | 133 | 136 | 146 | 149 | 152 | 155 | 158 | 161 | 164 | 167 | 170 | 171 | 172 | 173 | 174 | 175 | 180 | 183 | 184 | 187 | 190 | 194 | 195 | 198 | 202 | 203 | 204 | 207 | 208 | 209 | 214 | 217 | 218 | 221 | 222 | 223 | 228 | 229 | 232 | 233 | 234 | 235 | 236 | 237 | -------------------------------------------------------------------------------- /ImgLOC/ImgLoc/Aforge/SystemTools.cs: -------------------------------------------------------------------------------- 1 | // AForge Core Library 2 | // AForge.NET framework 3 | // http://www.aforgenet.com/framework/ 4 | // 5 | // Copyright © AForge.NET, 2007-2011 6 | // contacts@aforgenet.com 7 | // 8 | 9 | namespace AForge 10 | { 11 | using System; 12 | using System.Runtime.InteropServices; 13 | 14 | /// 15 | /// Set of systems tools. 16 | /// 17 | /// 18 | /// The class is a container of different system tools, which are used 19 | /// across the framework. Some of these tools are platform specific, so their 20 | /// implementation is different on different platform, like .NET and Mono. 21 | /// 22 | /// 23 | public static class SystemTools 24 | { 25 | /// 26 | /// Copy block of unmanaged memory. 27 | /// 28 | /// 29 | /// Destination pointer. 30 | /// Source pointer. 31 | /// Memory block's length to copy. 32 | /// 33 | /// Return's value of - pointer to destination. 34 | /// 35 | /// This function is required because of the fact that .NET does 36 | /// not provide any way to copy unmanaged blocks, but provides only methods to 37 | /// copy from unmanaged memory to managed memory and vise versa. 38 | /// 39 | public static IntPtr CopyUnmanagedMemory( IntPtr dst, IntPtr src, int count ) 40 | { 41 | unsafe 42 | { 43 | CopyUnmanagedMemory( (byte*) dst.ToPointer( ), (byte*) src.ToPointer( ), count ); 44 | } 45 | return dst; 46 | } 47 | 48 | /// 49 | /// Copy block of unmanaged memory. 50 | /// 51 | /// 52 | /// Destination pointer. 53 | /// Source pointer. 54 | /// Memory block's length to copy. 55 | /// 56 | /// Return's value of - pointer to destination. 57 | /// 58 | /// This function is required because of the fact that .NET does 59 | /// not provide any way to copy unmanaged blocks, but provides only methods to 60 | /// copy from unmanaged memory to managed memory and vise versa. 61 | /// 62 | public static unsafe byte* CopyUnmanagedMemory( byte* dst, byte* src, int count ) 63 | { 64 | #if !MONO 65 | return memcpy( dst, src, count ); 66 | #else 67 | int countUint = count >> 2; 68 | int countByte = count & 3; 69 | 70 | uint* dstUint = (uint*) dst; 71 | uint* srcUint = (uint*) src; 72 | 73 | while ( countUint-- != 0 ) 74 | { 75 | *dstUint++ = *srcUint++; 76 | } 77 | 78 | byte* dstByte = (byte*) dstUint; 79 | byte* srcByte = (byte*) srcUint; 80 | 81 | while ( countByte-- != 0 ) 82 | { 83 | *dstByte++ = *srcByte++; 84 | } 85 | return dst; 86 | #endif 87 | } 88 | 89 | /// 90 | /// Fill memory region with specified value. 91 | /// 92 | /// 93 | /// Destination pointer. 94 | /// Filler byte's value. 95 | /// Memory block's length to fill. 96 | /// 97 | /// Return's value of - pointer to destination. 98 | /// 99 | public static IntPtr SetUnmanagedMemory( IntPtr dst, int filler, int count ) 100 | { 101 | unsafe 102 | { 103 | SetUnmanagedMemory( (byte*) dst.ToPointer( ), filler, count ); 104 | } 105 | return dst; 106 | } 107 | 108 | /// 109 | /// Fill memory region with specified value. 110 | /// 111 | /// 112 | /// Destination pointer. 113 | /// Filler byte's value. 114 | /// Memory block's length to fill. 115 | /// 116 | /// Return's value of - pointer to destination. 117 | /// 118 | public static unsafe byte* SetUnmanagedMemory( byte* dst, int filler, int count ) 119 | { 120 | #if !MONO 121 | return memset( dst, filler, count ); 122 | #else 123 | int countUint = count >> 2; 124 | int countByte = count & 3; 125 | 126 | byte fillerByte = (byte) filler; 127 | uint fiilerUint = (uint) filler | ( (uint) filler << 8 ) | 128 | ( (uint) filler << 16 );// | 129 | //( (uint) filler << 24 ); 130 | 131 | uint* dstUint = (uint*) dst; 132 | 133 | while ( countUint-- != 0 ) 134 | { 135 | *dstUint++ = fiilerUint; 136 | } 137 | 138 | byte* dstByte = (byte*) dstUint; 139 | 140 | while ( countByte-- != 0 ) 141 | { 142 | *dstByte++ = fillerByte; 143 | } 144 | return dst; 145 | #endif 146 | } 147 | 148 | 149 | #if !MONO 150 | // Win32 memory copy function 151 | [DllImport( "ntdll.dll", CallingConvention = CallingConvention.Cdecl )] 152 | private static unsafe extern byte* memcpy( 153 | byte* dst, 154 | byte* src, 155 | int count ); 156 | // Win32 memory set function 157 | [DllImport( "ntdll.dll", CallingConvention = CallingConvention.Cdecl )] 158 | private static unsafe extern byte* memset( 159 | byte* dst, 160 | int filler, 161 | int count ); 162 | #endif 163 | } 164 | } 165 | -------------------------------------------------------------------------------- /ImageSearchDLL/ImageSearch.au3: -------------------------------------------------------------------------------- 1 | #include-once 2 | ; ------------------------------------------------------------------------------ 3 | ; 4 | ; AutoIt Version: 3.0 5 | ; Language: English 6 | ; Description: Functions that assist with Image Search 7 | ; Require that the ImageSearchDLL.dll be loadable 8 | ; 9 | ; ------------------------------------------------------------------------------ 10 | 11 | ;=============================================================================== 12 | ; 13 | ; Description: Find the position of an image on the desktop 14 | ; Syntax: _ImageSearchArea, _ImageSearch 15 | ; Parameter(s): 16 | ; $findImage - the image file location or HBitmap to locate on the 17 | ; desktop or in the Specified HBitmap 18 | ; $tolerance - 0 for no tolerance (0-255). Needed when colors of 19 | ; image differ from desktop. e.g GIF 20 | ; $resultPosition - Set where the returned x,y location of the image is. 21 | ; 1 for centre of image, 0 for top left of image 22 | ; $x $y - Return the x and y location of the image 23 | ; 24 | ; $HBMP - optional hbitmap to search in. sending 0 will search the desktop. 25 | ; 26 | ; Return Value(s): On Success - Returns 1 27 | ; On Failure - Returns 0 28 | ; 29 | ; Note: Use _ImageSearch to search the entire desktop, _ImageSearchArea to specify 30 | ; a desktop region to search 31 | ; 32 | ;=============================================================================== 33 | Func _ImageSearch($findImage,$resultPosition,ByRef $x, ByRef $y,$tolerance, $HBMP=0) 34 | return _ImageSearchArea($findImage,$resultPosition,0,0,@DesktopWidth,@DesktopHeight,$x,$y,$tolerance,$HBMP) 35 | EndFunc 36 | 37 | Func _ImageSearchArea($findImage,$resultPosition,$x1,$y1,$right,$bottom,ByRef $x, ByRef $y, $tolerance,$HBMP=0) 38 | ;MsgBox(0,"asd","" & $x1 & " " & $y1 & " " & $right & " " & $bottom) 39 | 40 | If IsString($findImage) Then 41 | if $tolerance>0 then $findImage = "*" & $tolerance & " " & $findImage 42 | If $HBMP = 0 Then 43 | $result = DllCall("ImageSearchDLL.dll","str","ImageSearch","int",$x1,"int",$y1,"int",$right,"int",$bottom,"str",$findImage) 44 | Else 45 | $result = DllCall("ImageSearchDLL.dll","str","ImageSearchEx","int",$x1,"int",$y1,"int",$right,"int",$bottom,"str",$findImage,"ptr",$HBMP) 46 | EndIf 47 | Else 48 | $result = DllCall("ImageSearchDLL.dll","str","ImageSearchExt","int",$x1,"int",$y1,"int",$right,"int",$bottom, "int",$tolerance, "ptr",$findImage,"ptr",$HBMP) 49 | EndIf 50 | 51 | ; If error exit 52 | if $result[0]="0" then return 0 53 | 54 | ; Otherwise get the x,y location of the match and the size of the image to 55 | ; compute the centre of search 56 | $array = StringSplit($result[0],"|") 57 | 58 | $x=Int(Number($array[2])) 59 | $y=Int(Number($array[3])) 60 | if $resultPosition=1 then 61 | $x=$x + Int(Number($array[4])/2) 62 | $y=$y + Int(Number($array[5])/2) 63 | endif 64 | return 1 65 | EndFunc 66 | 67 | ;=============================================================================== 68 | ; 69 | ; Description: Wait for a specified number of seconds for an image to appear 70 | ; 71 | ; Syntax: _WaitForImageSearch, _WaitForImagesSearch 72 | ; Parameter(s): 73 | ; $waitSecs - seconds to try and find the image 74 | ; $findImage - the image to locate on the desktop 75 | ; $tolerance - 0 for no tolerance (0-255). Needed when colors of 76 | ; image differ from desktop. e.g GIF 77 | ; $resultPosition - Set where the returned x,y location of the image is. 78 | ; 1 for centre of image, 0 for top left of image 79 | ; $x $y - Return the x and y location of the image 80 | ; 81 | ; Return Value(s): On Success - Returns 1 82 | ; On Failure - Returns 0 83 | ; 84 | ; 85 | ;=============================================================================== 86 | Func _WaitForImageSearch($findImage,$waitSecs,$resultPosition,ByRef $x, ByRef $y,$tolerance,$HBMP=0) 87 | $waitSecs = $waitSecs * 1000 88 | $startTime=TimerInit() 89 | While TimerDiff($startTime) < $waitSecs 90 | sleep(100) 91 | $result=_ImageSearch($findImage,$resultPosition,$x, $y,$tolerance,$HBMP) 92 | if $result > 0 Then 93 | return 1 94 | EndIf 95 | WEnd 96 | return 0 97 | EndFunc 98 | 99 | ;=============================================================================== 100 | ; 101 | ; Description: Wait for a specified number of seconds for any of a set of 102 | ; images to appear 103 | ; 104 | ; Syntax: _WaitForImagesSearch 105 | ; Parameter(s): 106 | ; $waitSecs - seconds to try and find the image 107 | ; $findImage - the ARRAY of images to locate on the desktop 108 | ; - ARRAY[0] is set to the number of images to loop through 109 | ; ARRAY[1] is the first image 110 | ; $tolerance - 0 for no tolerance (0-255). Needed when colors of 111 | ; image differ from desktop. e.g GIF 112 | ; $resultPosition - Set where the returned x,y location of the image is. 113 | ; 1 for centre of image, 0 for top left of image 114 | ; $x $y - Return the x and y location of the image 115 | ; 116 | ; Return Value(s): On Success - Returns the index of the successful find 117 | ; On Failure - Returns 0 118 | ; 119 | ; 120 | ;=============================================================================== 121 | Func _WaitForImagesSearch($findImage,$waitSecs,$resultPosition,ByRef $x, ByRef $y,$tolerance,$HBMP=0) 122 | $waitSecs = $waitSecs * 1000 123 | $startTime=TimerInit() 124 | While TimerDiff($startTime) < $waitSecs 125 | for $i = 1 to $findImage[0] 126 | sleep(100) 127 | $result=_ImageSearch($findImage[$i],$resultPosition,$x, $y,$tolerance,$HBMP) 128 | if $result > 0 Then 129 | return $i 130 | EndIf 131 | Next 132 | WEnd 133 | return 0 134 | EndFunc 135 | 136 | -------------------------------------------------------------------------------- /ImgLOC/ImgLoc/ImgLoc.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {C32D19C8-D1A7-413F-B1C5-63B33729C929} 8 | Library 9 | Properties 10 | ImgLoc 11 | ImgLoc 12 | v4.0 13 | 512 14 | 15 | 16 | 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | true 25 | 26 | 27 | pdbonly 28 | true 29 | bin\Release\ 30 | DEBUG;TRACE 31 | prompt 32 | 4 33 | true 34 | x86 35 | true 36 | On 37 | 38 | 39 | true 40 | bin\x86\Debug\ 41 | DEBUG;TRACE 42 | true 43 | full 44 | x86 45 | prompt 46 | ManagedMinimumRules.ruleset 47 | 48 | 49 | bin\x86\Release\ 50 | DEBUG;TRACE 51 | true 52 | true 53 | pdbonly 54 | x86 55 | prompt 56 | ManagedMinimumRules.ruleset 57 | true 58 | Auto 59 | true 60 | default 61 | 62 | 63 | true 64 | 65 | 66 | bahh.snk 67 | 68 | 69 | 70 | ..\packages\UnmanagedExports.1.2.7\lib\net\RGiesecke.DllExport.Metadata.dll 71 | False 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | PreserveNewest 113 | 114 | 115 | True 116 | True 117 | Settings.settings 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | SettingsSingleFileGenerator 126 | Settings.Designer.cs 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 141 | -------------------------------------------------------------------------------- /ImgLOC/ImgLoc/Aforge/Parallel.cs: -------------------------------------------------------------------------------- 1 | // AForge Core Library 2 | // AForge.NET framework 3 | // http://www.aforgenet.com/framework/ 4 | // 5 | // Copyright © Andrew Kirillov, 2007-2009 6 | // andrew.kirillov@aforgenet.com 7 | // 8 | // Copyright © Israel Lot, 2008 9 | // israel.lot@gmail.com 10 | // 11 | 12 | namespace AForge 13 | { 14 | using System; 15 | using System.Threading; 16 | 17 | /// 18 | /// The class provides support for parallel computations, paralleling loop's iterations. 19 | /// 20 | /// 21 | /// The class allows to parallel loop's iteration computing them in separate threads, 22 | /// what allows their simultaneous execution on multiple CPUs/cores. 23 | /// 24 | /// 25 | public sealed class Parallel 26 | { 27 | /// 28 | /// Delegate defining for-loop's body. 29 | /// 30 | /// 31 | /// Loop's index. 32 | /// 33 | public delegate void ForLoopBody( int index ); 34 | 35 | // number of threads for parallel computations 36 | private static int threadsCount = System.Environment.ProcessorCount; 37 | // object used for synchronization 38 | private static object sync = new Object( ); 39 | 40 | // single instance of the class to implement singleton pattern 41 | private static volatile Parallel instance = null; 42 | // background threads for parallel computation 43 | private Thread[] threads = null; 44 | 45 | // events to signal about job availability and thread availability 46 | private AutoResetEvent[] jobAvailable = null; 47 | private ManualResetEvent[] threadIdle = null; 48 | 49 | // loop's body and its current and stop index 50 | private int currentIndex; 51 | private int stopIndex; 52 | private ForLoopBody loopBody; 53 | 54 | /// 55 | /// Number of threads used for parallel computations. 56 | /// 57 | /// 58 | /// The property sets how many worker threads are created for paralleling 59 | /// loops' computations. 60 | /// 61 | /// By default the property is set to number of CPU's in the system 62 | /// (see ). 63 | /// 64 | /// 65 | public static int ThreadsCount 66 | { 67 | get { return threadsCount; } 68 | set 69 | { 70 | lock ( sync ) 71 | { 72 | threadsCount = System.Math.Max( 1, value ); 73 | } 74 | } 75 | } 76 | 77 | /// 78 | /// Executes a for-loop in which iterations may run in parallel. 79 | /// 80 | /// 81 | /// Loop's start index. 82 | /// Loop's stop index. 83 | /// Loop's body. 84 | /// 85 | /// The method is used to parallel for-loop running its iterations in 86 | /// different threads. The start and stop parameters define loop's 87 | /// starting and ending loop's indexes. The number of iterations is equal to stop - start. 88 | /// 89 | /// 90 | /// Sample usage: 91 | /// 92 | /// Parallel.For( 0, 20, delegate( int i ) 93 | /// // which is equivalent to 94 | /// // for ( int i = 0; i < 20; i++ ) 95 | /// { 96 | /// System.Diagnostics.Debug.WriteLine( "Iteration: " + i ); 97 | /// // ... 98 | /// } ); 99 | /// 100 | /// 101 | /// 102 | public static void For( int start, int stop, ForLoopBody loopBody ) 103 | { 104 | lock ( sync ) 105 | { 106 | // get instance of parallel computation manager 107 | Parallel instance = Instance; 108 | 109 | instance.currentIndex = start - 1; 110 | instance.stopIndex = stop; 111 | instance.loopBody = loopBody; 112 | 113 | // signal about available job for all threads and mark them busy 114 | for ( int i = 0; i < threadsCount; i++ ) 115 | { 116 | instance.threadIdle[i].Reset( ); 117 | instance.jobAvailable[i].Set( ); 118 | } 119 | 120 | // wait until all threads become idle 121 | for ( int i = 0; i < threadsCount; i++ ) 122 | { 123 | instance.threadIdle[i].WaitOne( ); 124 | } 125 | 126 | instance.loopBody = null; 127 | } 128 | } 129 | 130 | // Private constructor to avoid class instantiation 131 | private Parallel( ) { } 132 | 133 | // Get instace of the Parallel class 134 | private static Parallel Instance 135 | { 136 | get 137 | { 138 | if ( instance == null ) 139 | { 140 | instance = new Parallel( ); 141 | instance.Initialize( ); 142 | } 143 | else 144 | { 145 | if ( instance.threads.Length != threadsCount ) 146 | { 147 | // terminate old threads 148 | instance.Terminate( ); 149 | // reinitialize 150 | instance.Initialize( ); 151 | 152 | // TODO: change reinitialization to reuse already created objects 153 | } 154 | } 155 | return instance; 156 | } 157 | } 158 | 159 | // Initialize Parallel class's instance creating required number of threads 160 | // and synchronization objects 161 | private void Initialize( ) 162 | { 163 | // array of events, which signal about available job 164 | jobAvailable = new AutoResetEvent[threadsCount]; 165 | // array of events, which signal about available thread 166 | threadIdle = new ManualResetEvent[threadsCount]; 167 | // array of threads 168 | threads = new Thread[threadsCount]; 169 | 170 | for ( int i = 0; i < threadsCount; i++ ) 171 | { 172 | jobAvailable[i] = new AutoResetEvent( false ); 173 | threadIdle[i] = new ManualResetEvent( true ); 174 | 175 | threads[i] = new Thread( new ParameterizedThreadStart( WorkerThread ) ); 176 | threads[i].Name = "AForge.Parallel"; 177 | threads[i].IsBackground = true; 178 | threads[i].Start( i ); 179 | } 180 | } 181 | 182 | // Terminate all worker threads used for parallel computations and close all 183 | // synchronization objects 184 | private void Terminate( ) 185 | { 186 | // finish thread by setting null loop body and signaling about available work 187 | loopBody = null; 188 | for ( int i = 0, threadsCount = threads.Length ; i < threadsCount; i++ ) 189 | { 190 | jobAvailable[i].Set( ); 191 | // wait for thread termination 192 | threads[i].Join( ); 193 | 194 | // close events 195 | jobAvailable[i].Close( ); 196 | threadIdle[i].Close( ); 197 | } 198 | 199 | // clean all array references 200 | jobAvailable = null; 201 | threadIdle = null; 202 | threads = null; 203 | } 204 | 205 | // Worker thread performing parallel computations in loop 206 | private void WorkerThread( object index ) 207 | { 208 | int threadIndex = (int) index; 209 | int localIndex = 0; 210 | 211 | while ( true ) 212 | { 213 | // wait until there is job to do 214 | jobAvailable[threadIndex].WaitOne( ); 215 | 216 | // exit on null body 217 | if ( loopBody == null ) 218 | break; 219 | 220 | while ( true ) 221 | { 222 | // get local index incrementing global loop's current index 223 | localIndex = Interlocked.Increment( ref currentIndex ); 224 | 225 | if ( localIndex >= stopIndex ) 226 | break; 227 | 228 | // run loop's body 229 | loopBody( localIndex ); 230 | } 231 | 232 | // signal about thread availability 233 | threadIdle[threadIndex].Set( ); 234 | } 235 | } 236 | } 237 | } 238 | -------------------------------------------------------------------------------- /ImgLOC/ImgLoc/ImgLoc.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Drawing; 4 | using System.Drawing.Imaging; 5 | using AForge.Imaging; 6 | using System.Runtime.InteropServices; 7 | using RGiesecke.DllExport; 8 | 9 | 10 | namespace ImgLoc 11 | { 12 | [ComVisible(true)] 13 | public class ImgLoc 14 | { 15 | 16 | /* 17 | [DllExport("SearchTile", CallingConvention = CallingConvention.StdCall)] 18 | // [return: MarshalAs(UnmanagedType.LPStr)] 19 | public static string SearchTileInImage(IntPtr source, string tile, float similarity) 20 | { 21 | try 22 | { 23 | //float sim = float.Parse(similarity); 24 | Bitmap bitmap1 = System.Drawing.Image.FromHbitmap(source); 25 | Bitmap bitmap2 = (Bitmap)System.Drawing.Image.FromFile(tile); 26 | Bitmap image = ImgLoc.ConvertToFormat((System.Drawing.Image)bitmap1, PixelFormat.Format24bppRgb); 27 | Bitmap template = ImgLoc.ConvertToFormat((System.Drawing.Image)bitmap2, PixelFormat.Format24bppRgb); 28 | Rectangle r = new Rectangle(70, 70, 720, 540); 29 | TemplateMatch[] templateMatchArray = new ExhaustiveTemplateMatching(similarity).ProcessImage(image, template,r); 30 | string str = templateMatchArray.Length.ToString(); 31 | foreach (TemplateMatch templateMatch in templateMatchArray) 32 | str = str + "|" + (templateMatch.Rectangle.X + template.Width / 2).ToString() + "|" + (templateMatch.Rectangle.Y + template.Height / 2).ToString(); 33 | 34 | bitmap1.Dispose(); 35 | bitmap2.Dispose(); 36 | image.Dispose(); 37 | template.Dispose(); 38 | return str; 39 | } 40 | catch 41 | { 42 | return "-1"; 43 | } 44 | } 45 | */ 46 | [DllExport("SearchTile", CallingConvention = CallingConvention.StdCall)] 47 | // [return: MarshalAs(UnmanagedType.LPStr)] 48 | public static string SearchTileInImage(IntPtr source, string tile, float similarity, string cocarea = "70|70|720|540",string cocDiamondpoints = "430,70|787,335|430,605|67,333") 49 | { 50 | try 51 | { 52 | string[] pointlist = cocDiamondpoints.Split('|'); 53 | PointF topP = new PointF(float.Parse(pointlist[0].Split(',')[0]), float.Parse(pointlist[0].Split(',')[1])); 54 | PointF RightP = new PointF(float.Parse(pointlist[1].Split(',')[0]), float.Parse(pointlist[1].Split(',')[1])); 55 | PointF BottomP = new PointF(float.Parse(pointlist[2].Split(',')[0]), float.Parse(pointlist[2].Split(',')[1])); 56 | PointF LeftP = new PointF(float.Parse(pointlist[3].Split(',')[0]), float.Parse(pointlist[3].Split(',')[1])); 57 | List m_Points = new List(); 58 | m_Points.Add(topP); 59 | m_Points.Add(RightP); 60 | m_Points.Add(BottomP); 61 | m_Points.Add(LeftP); 62 | m_Points.Add(topP); 63 | 64 | 65 | string[] rectarea = cocarea.Split('|'); 66 | Rectangle r = new Rectangle(int.Parse(rectarea[0]), int.Parse(rectarea[1]), int.Parse(rectarea[2]), int.Parse(rectarea[3])); 67 | 68 | 69 | 70 | Bitmap bitmap1 = System.Drawing.Image.FromHbitmap(source); 71 | Bitmap bitmap2 = (Bitmap)System.Drawing.Image.FromFile(tile); 72 | Bitmap image = ImgLoc.ConvertToFormat((System.Drawing.Image)bitmap1, PixelFormat.Format24bppRgb); 73 | Bitmap template = ImgLoc.ConvertToFormat((System.Drawing.Image)bitmap2, PixelFormat.Format24bppRgb); 74 | 75 | TemplateMatch[] templateMatchArray = new ExhaustiveTemplateMatching(similarity).ProcessImage(image, template, r,m_Points); 76 | string str = templateMatchArray.Length.ToString(); 77 | foreach (TemplateMatch templateMatch in templateMatchArray) 78 | str = str + "|" + (templateMatch.Rectangle.X + template.Width / 2).ToString() + "|" + (templateMatch.Rectangle.Y + template.Height / 2).ToString(); 79 | 80 | bitmap1.Dispose(); 81 | bitmap2.Dispose(); 82 | image.Dispose(); 83 | template.Dispose(); 84 | return str; 85 | } 86 | catch 87 | { 88 | return "-1"; 89 | } 90 | } 91 | 92 | [DllExport("SearchInSource", CallingConvention = CallingConvention.StdCall)] 93 | // [return: MarshalAs(UnmanagedType.LPStr)] 94 | public static string SearchSourceInImage(string source, string tile, float similarity,string cocarea= "70|70|720|540", string cocDiamondpoints = "430,70|787,335|430,605|67,333") 95 | { 96 | try 97 | { 98 | string[] pointlist = cocDiamondpoints.Split('|'); 99 | PointF topP = new PointF(float.Parse(pointlist[0].Split(',')[0]), float.Parse(pointlist[0].Split(',')[1])); 100 | PointF RightP = new PointF(float.Parse(pointlist[1].Split(',')[0]), float.Parse(pointlist[1].Split(',')[1])); 101 | PointF BottomP = new PointF(float.Parse(pointlist[2].Split(',')[0]), float.Parse(pointlist[2].Split(',')[1])); 102 | PointF LeftP = new PointF(float.Parse(pointlist[3].Split(',')[0]), float.Parse(pointlist[3].Split(',')[1])); 103 | List m_Points = new List(); 104 | m_Points.Add(topP); 105 | m_Points.Add(RightP); 106 | m_Points.Add(BottomP); 107 | m_Points.Add(LeftP); 108 | m_Points.Add(topP); 109 | 110 | 111 | string[] rectarea = cocarea.Split('|'); 112 | Rectangle r = new Rectangle(int.Parse(rectarea[0]), int.Parse(rectarea[1]), int.Parse(rectarea[2]), int.Parse(rectarea[3])); 113 | 114 | Bitmap bitmap1 = (Bitmap)System.Drawing.Image.FromFile(source); 115 | Bitmap bitmap2 = (Bitmap)System.Drawing.Image.FromFile(tile); 116 | Bitmap image = ImgLoc.ConvertToFormat((System.Drawing.Image)bitmap1, PixelFormat.Format24bppRgb); 117 | Bitmap template = ImgLoc.ConvertToFormat((System.Drawing.Image)bitmap2, PixelFormat.Format24bppRgb); 118 | //Rectangle r = new Rectangle(70, 70, 720, 540); 119 | TemplateMatch[] templateMatchArray = new ExhaustiveTemplateMatching(similarity).ProcessImage(image, template, r, m_Points); 120 | 121 | string str = templateMatchArray.Length.ToString(); 122 | foreach (TemplateMatch templateMatch in templateMatchArray) 123 | str = str + "|" + (templateMatch.Rectangle.X + template.Width / 2).ToString() + "|" + (templateMatch.Rectangle.Y + template.Height / 2).ToString(); 124 | bitmap1.Dispose(); 125 | bitmap2.Dispose(); 126 | image.Dispose(); 127 | template.Dispose(); 128 | return str; 129 | } 130 | catch 131 | { 132 | return "-1"; 133 | } 134 | } 135 | 136 | [DllExport("MBRSearchImage", CallingConvention = CallingConvention.StdCall)] 137 | // [return: MarshalAs(UnmanagedType.LPStr)] 138 | // Pointer without any Rectangle and Polygon 139 | public static string SearchInImage(IntPtr source, string tile, float similarity) 140 | { 141 | try 142 | { 143 | Bitmap bitmap1 = System.Drawing.Image.FromHbitmap(source); 144 | Bitmap bitmap2 = (Bitmap)System.Drawing.Image.FromFile(tile); 145 | Bitmap image = ImgLoc.ConvertToFormat((System.Drawing.Image)bitmap1, PixelFormat.Format24bppRgb); 146 | Bitmap template = ImgLoc.ConvertToFormat((System.Drawing.Image)bitmap2, PixelFormat.Format24bppRgb); 147 | 148 | TemplateMatch[] templateMatchArray = new ProMacTemplateMatching(similarity).ProcessImage(image, template); 149 | string str = templateMatchArray.Length.ToString(); 150 | foreach (TemplateMatch templateMatch in templateMatchArray) 151 | str = str + "|" + (templateMatch.Rectangle.X + template.Width / 2).ToString() + "|" + (templateMatch.Rectangle.Y + template.Height / 2).ToString(); 152 | 153 | bitmap1.Dispose(); 154 | bitmap2.Dispose(); 155 | image.Dispose(); 156 | template.Dispose(); 157 | return str; 158 | } 159 | catch 160 | { 161 | return "-1"; 162 | } 163 | } 164 | 165 | public static Bitmap ConvertToFormat(System.Drawing.Image image, PixelFormat format) 166 | { 167 | Bitmap bitmap = new Bitmap(image.Width, image.Height, format); 168 | using (Graphics graphics = Graphics.FromImage(bitmap)) 169 | graphics.DrawImage(image, new Rectangle(0, 0, bitmap.Width, bitmap.Height)); 170 | return bitmap; 171 | } 172 | } 173 | } 174 | -------------------------------------------------------------------------------- /ImgLOC/ImgLoc/Aforge/IntPoint.cs: -------------------------------------------------------------------------------- 1 | // AForge Core Library 2 | // AForge.NET framework 3 | // http://www.aforgenet.com/framework/ 4 | // 5 | // Copyright © AForge.NET, 2007-2011 6 | // contacts@aforgenet.com 7 | // 8 | 9 | namespace AForge 10 | { 11 | using System; 12 | using System.ComponentModel; 13 | 14 | /// 15 | /// Structure for representing a pair of coordinates of integer type. 16 | /// 17 | /// 18 | /// The structure is used to store a pair of integer coordinates. 19 | /// 20 | /// Sample usage: 21 | /// 22 | /// // assigning coordinates in the constructor 23 | /// IntPoint p1 = new IntPoint( 10, 20 ); 24 | /// // creating a point and assigning coordinates later 25 | /// IntPoint p2; 26 | /// p2.X = 30; 27 | /// p2.Y = 40; 28 | /// // calculating distance between two points 29 | /// float distance = p1.DistanceTo( p2 ); 30 | /// 31 | /// 32 | /// 33 | [Serializable] 34 | public struct IntPoint 35 | { 36 | /// 37 | /// X coordinate. 38 | /// 39 | /// 40 | public int X; 41 | 42 | /// 43 | /// Y coordinate. 44 | /// 45 | /// 46 | public int Y; 47 | 48 | /// 49 | /// Initializes a new instance of the structure. 50 | /// 51 | /// 52 | /// X axis coordinate. 53 | /// Y axis coordinate. 54 | /// 55 | public IntPoint( int x, int y ) 56 | { 57 | this.X = x; 58 | this.Y = y; 59 | } 60 | 61 | /// 62 | /// Calculate Euclidean distance between two points. 63 | /// 64 | /// 65 | /// Point to calculate distance to. 66 | /// 67 | /// Returns Euclidean distance between this point and 68 | /// points. 69 | /// 70 | public float DistanceTo( IntPoint anotherPoint ) 71 | { 72 | int dx = X - anotherPoint.X; 73 | int dy = Y - anotherPoint.Y; 74 | 75 | return (float) System.Math.Sqrt( dx * dx + dy * dy ); 76 | } 77 | 78 | /// 79 | /// Calculate squared Euclidean distance between two points. 80 | /// 81 | /// 82 | /// Point to calculate distance to. 83 | /// 84 | /// Returns squared Euclidean distance between this point and 85 | /// points. 86 | /// 87 | public float SquaredDistanceTo( Point anotherPoint ) 88 | { 89 | float dx = X - anotherPoint.X; 90 | float dy = Y - anotherPoint.Y; 91 | 92 | return dx * dx + dy * dy; 93 | } 94 | 95 | /// 96 | /// Addition operator - adds values of two points. 97 | /// 98 | /// 99 | /// First point for addition. 100 | /// Second point for addition. 101 | /// 102 | /// Returns new point which coordinates equal to sum of corresponding 103 | /// coordinates of specified points. 104 | /// 105 | public static IntPoint operator +( IntPoint point1, IntPoint point2 ) 106 | { 107 | return new IntPoint( point1.X + point2.X, point1.Y + point2.Y ); 108 | } 109 | 110 | /// 111 | /// Addition operator - adds values of two points. 112 | /// 113 | /// 114 | /// First point for addition. 115 | /// Second point for addition. 116 | /// 117 | /// Returns new point which coordinates equal to sum of corresponding 118 | /// coordinates of specified points. 119 | /// 120 | public static IntPoint Add( IntPoint point1, IntPoint point2 ) 121 | { 122 | return new IntPoint( point1.X + point2.X, point1.Y + point2.Y ); 123 | } 124 | 125 | /// 126 | /// Subtraction operator - subtracts values of two points. 127 | /// 128 | /// 129 | /// Point to subtract from. 130 | /// Point to subtract. 131 | /// 132 | /// Returns new point which coordinates equal to difference of corresponding 133 | /// coordinates of specified points. 134 | /// 135 | public static IntPoint operator -( IntPoint point1, IntPoint point2 ) 136 | { 137 | return new IntPoint( point1.X - point2.X, point1.Y - point2.Y ); 138 | } 139 | 140 | /// 141 | /// Subtraction operator - subtracts values of two points. 142 | /// 143 | /// 144 | /// Point to subtract from. 145 | /// Point to subtract. 146 | /// 147 | /// Returns new point which coordinates equal to difference of corresponding 148 | /// coordinates of specified points. 149 | /// 150 | public static IntPoint Subtract( IntPoint point1, IntPoint point2 ) 151 | { 152 | return new IntPoint( point1.X - point2.X, point1.Y - point2.Y ); 153 | } 154 | 155 | /// 156 | /// Addition operator - adds scalar to the specified point. 157 | /// 158 | /// 159 | /// Point to increase coordinates of. 160 | /// Value to add to coordinates of the specified point. 161 | /// 162 | /// Returns new point which coordinates equal to coordinates of 163 | /// the specified point increased by specified value. 164 | /// 165 | public static IntPoint operator +( IntPoint point, int valueToAdd ) 166 | { 167 | return new IntPoint( point.X + valueToAdd, point.Y + valueToAdd ); 168 | } 169 | 170 | /// 171 | /// Addition operator - adds scalar to the specified point. 172 | /// 173 | /// 174 | /// Point to increase coordinates of. 175 | /// Value to add to coordinates of the specified point. 176 | /// 177 | /// Returns new point which coordinates equal to coordinates of 178 | /// the specified point increased by specified value. 179 | /// 180 | public static IntPoint Add( IntPoint point, int valueToAdd ) 181 | { 182 | return new IntPoint( point.X + valueToAdd, point.Y + valueToAdd ); 183 | } 184 | 185 | /// 186 | /// Subtraction operator - subtracts scalar from the specified point. 187 | /// 188 | /// 189 | /// Point to decrease coordinates of. 190 | /// Value to subtract from coordinates of the specified point. 191 | /// 192 | /// Returns new point which coordinates equal to coordinates of 193 | /// the specified point decreased by specified value. 194 | /// 195 | public static IntPoint operator -( IntPoint point, int valueToSubtract ) 196 | { 197 | return new IntPoint( point.X - valueToSubtract, point.Y - valueToSubtract ); 198 | } 199 | 200 | /// 201 | /// Subtraction operator - subtracts scalar from the specified point. 202 | /// 203 | /// 204 | /// Point to decrease coordinates of. 205 | /// Value to subtract from coordinates of the specified point. 206 | /// 207 | /// Returns new point which coordinates equal to coordinates of 208 | /// the specified point decreased by specified value. 209 | /// 210 | public static IntPoint Subtract( IntPoint point, int valueToSubtract ) 211 | { 212 | return new IntPoint( point.X - valueToSubtract, point.Y - valueToSubtract ); 213 | } 214 | 215 | /// 216 | /// Multiplication operator - multiplies coordinates of the specified point by scalar value. 217 | /// 218 | /// 219 | /// Point to multiply coordinates of. 220 | /// Multiplication factor. 221 | /// 222 | /// Returns new point which coordinates equal to coordinates of 223 | /// the specified point multiplied by specified value. 224 | /// 225 | public static IntPoint operator *( IntPoint point, int factor ) 226 | { 227 | return new IntPoint( point.X * factor, point.Y * factor ); 228 | } 229 | 230 | /// 231 | /// Multiplication operator - multiplies coordinates of the specified point by scalar value. 232 | /// 233 | /// 234 | /// Point to multiply coordinates of. 235 | /// Multiplication factor. 236 | /// 237 | /// Returns new point which coordinates equal to coordinates of 238 | /// the specified point multiplied by specified value. 239 | /// 240 | public static IntPoint Multiply( IntPoint point, int factor ) 241 | { 242 | return new IntPoint( point.X * factor, point.Y * factor ); 243 | } 244 | 245 | /// 246 | /// Division operator - divides coordinates of the specified point by scalar value. 247 | /// 248 | /// 249 | /// Point to divide coordinates of. 250 | /// Division factor. 251 | /// 252 | /// Returns new point which coordinates equal to coordinates of 253 | /// the specified point divided by specified value. 254 | /// 255 | public static IntPoint operator /( IntPoint point, int factor ) 256 | { 257 | return new IntPoint( point.X / factor, point.Y / factor ); 258 | } 259 | 260 | /// 261 | /// Division operator - divides coordinates of the specified point by scalar value. 262 | /// 263 | /// 264 | /// Point to divide coordinates of. 265 | /// Division factor. 266 | /// 267 | /// Returns new point which coordinates equal to coordinates of 268 | /// the specified point divided by specified value. 269 | /// 270 | public static IntPoint Divide( IntPoint point, int factor ) 271 | { 272 | return new IntPoint( point.X / factor, point.Y / factor ); 273 | } 274 | 275 | /// 276 | /// Equality operator - checks if two points have equal coordinates. 277 | /// 278 | /// 279 | /// First point to check. 280 | /// Second point to check. 281 | /// 282 | /// Returns if coordinates of specified 283 | /// points are equal. 284 | /// 285 | public static bool operator ==( IntPoint point1, IntPoint point2 ) 286 | { 287 | return ( ( point1.X == point2.X ) && ( point1.Y == point2.Y ) ); 288 | } 289 | 290 | /// 291 | /// Inequality operator - checks if two points have different coordinates. 292 | /// 293 | /// 294 | /// First point to check. 295 | /// Second point to check. 296 | /// 297 | /// Returns if coordinates of specified 298 | /// points are not equal. 299 | /// 300 | public static bool operator !=( IntPoint point1, IntPoint point2 ) 301 | { 302 | return ( ( point1.X != point2.X ) || ( point1.Y != point2.Y ) ); 303 | } 304 | 305 | /// 306 | /// Check if this instance of equal to the specified one. 307 | /// 308 | /// 309 | /// Another point to check equalty to. 310 | /// 311 | /// Return if objects are equal. 312 | /// 313 | public override bool Equals( object obj ) 314 | { 315 | return ( obj is IntPoint ) ? ( this == (IntPoint) obj ) : false; 316 | } 317 | 318 | /// 319 | /// Get hash code for this instance. 320 | /// 321 | /// 322 | /// Returns the hash code for this instance. 323 | /// 324 | public override int GetHashCode( ) 325 | { 326 | return X.GetHashCode( ) + Y.GetHashCode( ); 327 | } 328 | 329 | /// 330 | /// Implicit conversion to . 331 | /// 332 | /// 333 | /// Integer point to convert to single precision point. 334 | /// 335 | /// Returns new single precision point which coordinates are implicitly converted 336 | /// to floats from coordinates of the specified integer point. 337 | /// 338 | public static implicit operator Point( IntPoint point ) 339 | { 340 | return new Point( point.X, point.Y ); 341 | } 342 | 343 | /// 344 | /// Implicit conversion to . 345 | /// 346 | /// 347 | /// Integer point to convert to double precision point. 348 | /// 349 | /// Returns new double precision point which coordinates are implicitly converted 350 | /// to doubles from coordinates of the specified integer point. 351 | /// 352 | public static implicit operator DoublePoint( IntPoint point ) 353 | { 354 | return new DoublePoint( point.X, point.Y ); 355 | } 356 | 357 | /// 358 | /// Get string representation of the class. 359 | /// 360 | /// 361 | /// Returns string, which contains values of the point in readable form. 362 | /// 363 | public override string ToString( ) 364 | { 365 | return string.Format( System.Globalization.CultureInfo.InvariantCulture, "{0}, {1}", X, Y ); 366 | } 367 | 368 | /// 369 | /// Calculate Euclidean norm of the vector comprised of the point's 370 | /// coordinates - distance from (0, 0) in other words. 371 | /// 372 | /// 373 | /// Returns point's distance from (0, 0) point. 374 | /// 375 | public float EuclideanNorm( ) 376 | { 377 | return (float) System.Math.Sqrt( X * X + Y * Y ); 378 | } 379 | } 380 | } 381 | -------------------------------------------------------------------------------- /ImageSearchDLL/license.txt: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc. 5 | 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Library General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | 283 | 284 | 285 | THE "BSD" LICENCE 286 | ----------------- 287 | 288 | Redistribution and use in source and binary forms, with or without 289 | modification, are permitted provided that the following conditions are met: 290 | 291 | * Redistributions of source code must retain the above copyright notice, 292 | this list of conditions and the following disclaimer. 293 | 294 | * Redistributions in binary form must reproduce the above copyright 295 | notice, this list of conditions and the following disclaimer in the 296 | documentation and/or other materials provided with the distribution. 297 | 298 | * Neither the name of the University of Cambridge nor the name of Google 299 | Inc. nor the names of their contributors may be used to endorse or 300 | promote products derived from this software without specific prior 301 | written permission. 302 | 303 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 304 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 305 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 306 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 307 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 308 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 309 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 310 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 311 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 312 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 313 | POSSIBILITY OF SUCH DAMAGE. 314 | 315 | End 316 | -------------------------------------------------------------------------------- /ImgLOC/ImgLoc/imaging/ProMacMatch.cs: -------------------------------------------------------------------------------- 1 | // AForge Image Processing Library 2 | // AForge.NET framework 3 | // http://www.aforgenet.com/framework/ 4 | // 5 | // Copyright © Andrew Kirillov, 2005-2009 6 | // andrew.kirillov@aforgenet.com 7 | // 8 | 9 | namespace AForge.Imaging 10 | { 11 | using System; 12 | using System.Drawing; 13 | using System.Drawing.Imaging; 14 | using System.Collections.Generic; 15 | 16 | /// 17 | /// Exhaustive template matching. 18 | /// 19 | /// 20 | /// The class implements exhaustive template matching algorithm, 21 | /// which performs complete scan of source image, comparing each pixel with corresponding 22 | /// pixel of template. 23 | /// 24 | /// The class processes only grayscale 8 bpp and color 24 bpp images. 25 | /// 26 | /// Sample usage: 27 | /// 28 | /// // create template matching algorithm's instance 29 | /// ExhaustiveTemplateMatching tm = new ExhaustiveTemplateMatching( 0.9f ); 30 | /// // find all matchings with specified above similarity 31 | /// TemplateMatch[] matchings = tm.ProcessImage( sourceImage, templateImage ); 32 | /// // highlight found matchings 33 | /// BitmapData data = sourceImage.LockBits( 34 | /// new Rectangle( 0, 0, sourceImage.Width, sourceImage.Height ), 35 | /// ImageLockMode.ReadWrite, sourceImage.PixelFormat ); 36 | /// foreach ( TemplateMatch m in matchings ) 37 | /// { 38 | /// Drawing.Rectangle( data, m.Rectangle, Color.White ); 39 | /// // do something else with matching 40 | /// } 41 | /// sourceImage.UnlockBits( data ); 42 | /// 43 | /// 44 | /// The class also can be used to get similarity level between two image of the same 45 | /// size, which can be useful to get information about how different/similar are images: 46 | /// 47 | /// // create template matching algorithm's instance 48 | /// // use zero similarity to make sure algorithm will provide anything 49 | /// ExhaustiveTemplateMatching tm = new ExhaustiveTemplateMatching( 0 ); 50 | /// // compare two images 51 | /// TemplateMatch[] matchings = tm.ProcessImage( image1, image2 ); 52 | /// // check similarity level 53 | /// if ( matchings[0].Similarity > 0.95f ) 54 | /// { 55 | /// // do something with quite similar images 56 | /// } 57 | /// 58 | /// 59 | /// 60 | /// 61 | public class ProMacTemplateMatching : ITemplateMatching 62 | { 63 | private float similarityThreshold = 0.9f; 64 | 65 | /// 66 | /// Similarity threshold, [0..1]. 67 | /// 68 | /// 69 | /// The property sets the minimal acceptable similarity between template 70 | /// and potential found candidate. If similarity is lower than this value, 71 | /// then object is not treated as matching with template. 72 | /// 73 | /// 74 | /// Default value is set to 0.9. 75 | /// 76 | /// 77 | public float SimilarityThreshold 78 | { 79 | get { return similarityThreshold; } 80 | set { similarityThreshold = Math.Min(1, Math.Max(0, value)); } 81 | } 82 | 83 | /// 84 | /// Initializes a new instance of the class. 85 | /// 86 | /// 87 | public ProMacTemplateMatching() { } 88 | 89 | /// 90 | /// Initializes a new instance of the class. 91 | /// 92 | /// 93 | /// Similarity threshold. 94 | /// 95 | public ProMacTemplateMatching(float similarityThreshold) 96 | { 97 | this.similarityThreshold = similarityThreshold; 98 | } 99 | 100 | /// 101 | /// Process image looking for matchings with specified template. 102 | /// 103 | /// 104 | /// Source image to process. 105 | /// Template image to search for. 106 | /// 107 | /// Returns array of found template matches. The array is sorted by similarity 108 | /// of found matches in descending order. 109 | /// 110 | /// The source image has incorrect pixel format. 111 | /// Template image is bigger than source image. 112 | /// 113 | public TemplateMatch[] ProcessImage(Bitmap image, Bitmap template) 114 | { 115 | return ProcessImage(image, template, new Rectangle(0, 0, image.Width, image.Height)); 116 | } 117 | 118 | /// 119 | /// Process image looking for matchings with specified template. 120 | /// 121 | /// 122 | /// Source image to process. 123 | /// Template image to search for. 124 | /// Rectangle in source image to search template for. 125 | /// 126 | /// Returns array of found template matches. The array is sorted by similarity 127 | /// of found matches in descending order. 128 | /// 129 | /// The source image has incorrect pixel format. 130 | /// Template image is bigger than source image. 131 | /// 132 | public TemplateMatch[] ProcessImage(Bitmap image, Bitmap template, Rectangle searchZone) 133 | { 134 | // check image format 135 | if ( 136 | ((image.PixelFormat != PixelFormat.Format8bppIndexed) && 137 | (image.PixelFormat != PixelFormat.Format24bppRgb)) || 138 | (image.PixelFormat != template.PixelFormat)) 139 | { 140 | throw new UnsupportedImageFormatException("Unsupported pixel format of the source or template image."); 141 | } 142 | 143 | // check template's size 144 | if ((template.Width > image.Width) || (template.Height > image.Height)) 145 | { 146 | throw new InvalidImagePropertiesException("Template's size should be smaller or equal to source image's size."); 147 | } 148 | 149 | // lock source and template images 150 | BitmapData imageData = image.LockBits( 151 | new Rectangle(0, 0, image.Width, image.Height), 152 | ImageLockMode.ReadOnly, image.PixelFormat); 153 | BitmapData templateData = template.LockBits( 154 | new Rectangle(0, 0, template.Width, template.Height), 155 | ImageLockMode.ReadOnly, template.PixelFormat); 156 | 157 | TemplateMatch[] matchings; 158 | 159 | try 160 | { 161 | // process the image 162 | matchings = ProcessImage( 163 | new UnmanagedImage(imageData), 164 | new UnmanagedImage(templateData), 165 | searchZone); 166 | } 167 | finally 168 | { 169 | // unlock images 170 | image.UnlockBits(imageData); 171 | template.UnlockBits(templateData); 172 | } 173 | 174 | return matchings; 175 | } 176 | 177 | /// 178 | /// Process image looking for matchings with specified template. 179 | /// 180 | /// 181 | /// Source image data to process. 182 | /// Template image to search for. 183 | /// 184 | /// Returns array of found template matches. The array is sorted by similarity 185 | /// of found matches in descending order. 186 | /// 187 | /// The source image has incorrect pixel format. 188 | /// Template image is bigger than source image. 189 | /// 190 | public TemplateMatch[] ProcessImage(BitmapData imageData, BitmapData templateData) 191 | { 192 | return ProcessImage(new UnmanagedImage(imageData), new UnmanagedImage(templateData), 193 | new Rectangle(0, 0, imageData.Width, imageData.Height)); 194 | } 195 | 196 | /// 197 | /// Process image looking for matchings with specified template. 198 | /// 199 | /// 200 | /// Source image data to process. 201 | /// Template image to search for. 202 | /// Rectangle in source image to search template for. 203 | /// 204 | /// Returns array of found template matches. The array is sorted by similarity 205 | /// of found matches in descending order. 206 | /// 207 | /// The source image has incorrect pixel format. 208 | /// Template image is bigger than source image. 209 | /// 210 | public TemplateMatch[] ProcessImage(BitmapData imageData, BitmapData templateData, Rectangle searchZone) 211 | { 212 | return ProcessImage(new UnmanagedImage(imageData), new UnmanagedImage(templateData), searchZone); 213 | } 214 | 215 | /// 216 | /// Process image looking for matchings with specified template. 217 | /// 218 | /// 219 | /// Unmanaged source image to process. 220 | /// Unmanaged template image to search for. 221 | /// 222 | /// Returns array of found template matches. The array is sorted by similarity 223 | /// of found matches in descending order. 224 | /// 225 | /// The source image has incorrect pixel format. 226 | /// Template image is bigger than source image. 227 | /// 228 | public TemplateMatch[] ProcessImage(UnmanagedImage image, UnmanagedImage template) 229 | { 230 | return ProcessImage(image, template, new Rectangle(0, 0, image.Width, image.Height)); 231 | } 232 | 233 | /// 234 | /// Process image looking for matchings with specified template. 235 | /// 236 | /// 237 | /// Unmanaged source image to process. 238 | /// Unmanaged template image to search for. 239 | /// Rectangle in source image to search template for. 240 | /// 241 | /// Returns array of found template matches. The array is sorted by similarity 242 | /// of found matches in descending order. 243 | /// 244 | /// The source image has incorrect pixel format. 245 | /// Template image is bigger than search zone. 246 | /// 247 | public TemplateMatch[] ProcessImage(UnmanagedImage image, UnmanagedImage template, Rectangle searchZone) 248 | { 249 | // check image format 250 | if ( 251 | ((image.PixelFormat != PixelFormat.Format8bppIndexed) && 252 | (image.PixelFormat != PixelFormat.Format24bppRgb)) || 253 | (image.PixelFormat != template.PixelFormat)) 254 | { 255 | throw new UnsupportedImageFormatException("Unsupported pixel format of the source or template image."); 256 | } 257 | 258 | // clip search zone 259 | Rectangle zone = searchZone; 260 | zone.Intersect(new Rectangle(0, 0, image.Width, image.Height)); 261 | 262 | // search zone's starting point 263 | int startX = zone.X; 264 | int startY = zone.Y; 265 | 266 | // get source and template image size 267 | int sourceWidth = zone.Width; 268 | int sourceHeight = zone.Height; 269 | int templateWidth = template.Width; 270 | int templateHeight = template.Height; 271 | 272 | // check template's size 273 | if ((templateWidth > sourceWidth) || (templateHeight > sourceHeight)) 274 | { 275 | throw new InvalidImagePropertiesException("Template's size should be smaller or equal to search zone."); 276 | } 277 | 278 | int pixelSize = (image.PixelFormat == PixelFormat.Format8bppIndexed) ? 1 : 3; 279 | int sourceStride = image.Stride; 280 | 281 | // similarity map. its size is increased by 4 from each side to increase 282 | // performance of non-maximum suppresion 283 | int mapWidth = sourceWidth - templateWidth + 1; 284 | int mapHeight = sourceHeight - templateHeight + 1; 285 | int[,] map = new int[mapHeight + 4, mapWidth + 4]; 286 | 287 | // maximum possible difference with template 288 | int maxDiff = templateWidth * templateHeight * pixelSize * 255; 289 | 290 | // integer similarity threshold 291 | int threshold = (int)(similarityThreshold * maxDiff); 292 | 293 | // width of template in bytes 294 | int templateWidthInBytes = templateWidth * pixelSize; 295 | 296 | // do the job 297 | unsafe 298 | { 299 | byte* baseSrc = (byte*)image.ImageData.ToPointer(); 300 | byte* baseTpl = (byte*)template.ImageData.ToPointer(); 301 | 302 | int sourceOffset = image.Stride - templateWidth * pixelSize; 303 | int templateOffset = template.Stride - templateWidth * pixelSize; 304 | 305 | // for each row of the source image 306 | for (int y = 0; y < mapHeight; y++) 307 | { 308 | // for each pixel of the source image 309 | for (int x = 0; x < mapWidth; x++) 310 | { 311 | byte* src = baseSrc + sourceStride * (y + startY) + pixelSize * (x + startX); 312 | byte* tpl = baseTpl; 313 | 314 | // compare template with source image starting from current X,Y 315 | int dif = 0; 316 | 317 | // for each row of the template 318 | for (int i = 0; i < templateHeight; i++) 319 | { 320 | // for each pixel of the template 321 | for (int j = 0; j < templateWidthInBytes; j++, src++, tpl++) 322 | { 323 | int d = *src - *tpl; 324 | if (d > 0) 325 | { 326 | dif += d; 327 | } 328 | else 329 | { 330 | dif -= d; 331 | } 332 | } 333 | src += sourceOffset; 334 | tpl += templateOffset; 335 | } 336 | 337 | // templates similarity 338 | int sim = maxDiff - dif; 339 | 340 | if (sim >= threshold) 341 | map[y + 2, x + 2] = sim; 342 | } 343 | } 344 | } 345 | 346 | // collect interesting points - only those points, which are local maximums 347 | List matchingsList = new List(); 348 | 349 | // for each row 350 | for (int y = 2, maxY = mapHeight + 2; y < maxY; y++) 351 | { 352 | // for each pixel 353 | for (int x = 2, maxX = mapWidth + 2; x < maxX; x++) 354 | { 355 | int currentValue = map[y, x]; 356 | 357 | // for each windows' row 358 | for (int i = -2; (currentValue != 0) && (i <= 2); i++) 359 | { 360 | // for each windows' pixel 361 | for (int j = -2; j <= 2; j++) 362 | { 363 | if (map[y + i, x + j] > currentValue) 364 | { 365 | currentValue = 0; 366 | break; 367 | } 368 | } 369 | } 370 | 371 | // check if this point is really interesting 372 | if (currentValue != 0) 373 | { 374 | matchingsList.Add(new TemplateMatch( 375 | new Rectangle(x - 2 + startX, y - 2 + startY, templateWidth, templateHeight), 376 | (float)currentValue / maxDiff)); 377 | } 378 | } 379 | } 380 | 381 | // convert list to array 382 | TemplateMatch[] matchings = new TemplateMatch[matchingsList.Count]; 383 | matchingsList.CopyTo(matchings); 384 | // sort in descending order 385 | Array.Sort(matchings, new MatchingsSorter()); 386 | 387 | return matchings; 388 | } 389 | 390 | // Sorter of found matchings 391 | private class MatchingsSorter : System.Collections.IComparer 392 | { 393 | public int Compare(Object x, Object y) 394 | { 395 | float diff = ((TemplateMatch)y).Similarity - ((TemplateMatch)x).Similarity; 396 | 397 | return (diff > 0) ? 1 : (diff < 0) ? -1 : 0; 398 | } 399 | } 400 | } 401 | } -------------------------------------------------------------------------------- /ImageSearchDLL/ImageSearchDLL/license.txt: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc. 5 | 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Library General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | 283 | ------------ 284 | PCRE LICENCE 285 | ------------ 286 | 287 | PCRE is a library of functions to support regular expressions whose syntax 288 | and semantics are as close as possible to those of the Perl 5 language. 289 | 290 | Release 6 of PCRE is distributed under the terms of the "BSD" licence, as 291 | specified below. The documentation for PCRE, supplied in the "doc" 292 | directory, is distributed under the same terms as the software itself. 293 | 294 | The basic library functions are written in C and are freestanding. Also 295 | included in the distribution is a set of C++ wrapper functions. 296 | 297 | 298 | THE BASIC LIBRARY FUNCTIONS 299 | --------------------------- 300 | 301 | Written by: Philip Hazel 302 | Email local part: ph10 303 | Email domain: cam.ac.uk 304 | 305 | University of Cambridge Computing Service, 306 | Cambridge, England. Phone: +44 1223 334714. 307 | 308 | Copyright (c) 1997-2006 University of Cambridge 309 | All rights reserved. 310 | 311 | 312 | THE C++ WRAPPER FUNCTIONS 313 | ------------------------- 314 | 315 | Contributed by: Google Inc. 316 | 317 | Copyright (c) 2006, Google Inc. 318 | All rights reserved. 319 | 320 | 321 | THE "BSD" LICENCE 322 | ----------------- 323 | 324 | Redistribution and use in source and binary forms, with or without 325 | modification, are permitted provided that the following conditions are met: 326 | 327 | * Redistributions of source code must retain the above copyright notice, 328 | this list of conditions and the following disclaimer. 329 | 330 | * Redistributions in binary form must reproduce the above copyright 331 | notice, this list of conditions and the following disclaimer in the 332 | documentation and/or other materials provided with the distribution. 333 | 334 | * Neither the name of the University of Cambridge nor the name of Google 335 | Inc. nor the names of their contributors may be used to endorse or 336 | promote products derived from this software without specific prior 337 | written permission. 338 | 339 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 340 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 341 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 342 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 343 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 344 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 345 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 346 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 347 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 348 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 349 | POSSIBILITY OF SUCH DAMAGE. 350 | 351 | End 352 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | {one line to give the program's name and a brief idea of what it does.} 635 | Copyright (C) {year} {name of author} 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | {project} Copyright (C) {year} {fullname} 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | 676 | --------------------------------------------------------------------------------