diff --git a/.vs/OverwatchCV/v14/.suo b/.vs/OverwatchCV/v14/.suo new file mode 100644 index 0000000..1c82bdf Binary files /dev/null and b/.vs/OverwatchCV/v14/.suo differ diff --git a/OverwatchCV.VC.db b/OverwatchCV.VC.db new file mode 100644 index 0000000..54c055e Binary files /dev/null and b/OverwatchCV.VC.db differ diff --git a/OverwatchCV.sln b/OverwatchCV.sln new file mode 100644 index 0000000..57dfa25 --- /dev/null +++ b/OverwatchCV.sln @@ -0,0 +1,28 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.25123.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OverwatchCV", "OverwatchCV\OverwatchCV.vcxproj", "{F50CF48A-2984-43CC-A9E4-E07B6C943912}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {F50CF48A-2984-43CC-A9E4-E07B6C943912}.Debug|x64.ActiveCfg = Debug|x64 + {F50CF48A-2984-43CC-A9E4-E07B6C943912}.Debug|x64.Build.0 = Debug|x64 + {F50CF48A-2984-43CC-A9E4-E07B6C943912}.Debug|x86.ActiveCfg = Debug|Win32 + {F50CF48A-2984-43CC-A9E4-E07B6C943912}.Debug|x86.Build.0 = Debug|Win32 + {F50CF48A-2984-43CC-A9E4-E07B6C943912}.Release|x64.ActiveCfg = Release|x64 + {F50CF48A-2984-43CC-A9E4-E07B6C943912}.Release|x64.Build.0 = Release|x64 + {F50CF48A-2984-43CC-A9E4-E07B6C943912}.Release|x86.ActiveCfg = Release|Win32 + {F50CF48A-2984-43CC-A9E4-E07B6C943912}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/OverwatchCV/OverwatchCV.cpp b/OverwatchCV/OverwatchCV.cpp new file mode 100644 index 0000000..9422880 --- /dev/null +++ b/OverwatchCV/OverwatchCV.cpp @@ -0,0 +1,156 @@ +// OverwatchCV.cpp : Defines the entry point for the console application. +// + +#include "stdafx.h" +#include "opencv2/core/core.hpp" +#include "opencv2/imgproc/imgproc.hpp" +#include +#include +#include +#include +#include +#include + +using namespace std; +using namespace cv; + +Mat hwnd2mat(HWND hwnd) { + + HDC hwindowDC, hwindowCompatibleDC; + + int height, width, srcheight, srcwidth; + HBITMAP hbwindow; + Mat src; + BITMAPINFOHEADER bi; + + hwindowDC = GetDC(hwnd); + hwindowCompatibleDC = CreateCompatibleDC(hwindowDC); + SetStretchBltMode(hwindowCompatibleDC, COLORONCOLOR); + + RECT windowsize; // get the height and width of the screen + GetClientRect(hwnd, &windowsize); + + srcheight = windowsize.bottom / 2; + srcwidth = windowsize.right / 2; + height = windowsize.bottom / 4; //change this to whatever size you want to resize to + width = windowsize.right / 4; + int startX = windowsize.right / 4; + int startY = windowsize.bottom / 4; + + src.create(height, width, CV_8UC4); + + // create a bitmap + hbwindow = CreateCompatibleBitmap(hwindowDC, width, height); + bi.biSize = sizeof(BITMAPINFOHEADER); //http://msdn.microsoft.com/en-us/library/windows/window/dd183402%28v=vs.85%29.aspx + bi.biWidth = width; + bi.biHeight = -height; //this is the line that makes it draw upside down or not + bi.biPlanes = 1; + bi.biBitCount = 32; + bi.biCompression = BI_RGB; + bi.biSizeImage = 0; + bi.biXPelsPerMeter = 0; + bi.biYPelsPerMeter = 0; + bi.biClrUsed = 0; + bi.biClrImportant = 0; + + // use the previously created device context with the bitmap + SelectObject(hwindowCompatibleDC, hbwindow); + // copy from the window device context to the bitmap device context + StretchBlt(hwindowCompatibleDC, 0, 0, width, height, hwindowDC, startX, startY, srcwidth, srcheight, SRCCOPY); //change SRCCOPY to NOTSRCCOPY for wacky colors ! + GetDIBits(hwindowCompatibleDC, hbwindow, 0, height, src.data, (BITMAPINFO *)&bi, DIB_RGB_COLORS); //copy from hwindowCompatibleDC to hbwindow + + DeleteObject(hbwindow); DeleteDC(hwindowCompatibleDC); ReleaseDC(hwnd, hwindowDC); + + return src; +} + +int main() +{ + /* + Mat img = hwnd2mat(GetDesktopWindow()); + if (img.empty()) + { + cout << "Error : Image cannot be loaded....." << endl; + return -1; + } + */ + + namedWindow("Control", CV_WINDOW_AUTOSIZE); + + for(;;) { + double t = (double)getTickCount(); + Mat img = hwnd2mat(GetDesktopWindow()); + Mat imgHSV; + Mat1b mask1, mask2; + + cvtColor(img, imgHSV, COLOR_BGR2HSV); //Convert the captured frame from BGR to HSV + + inRange(imgHSV, Scalar(0, 70, 50), Scalar(10, 255, 255), mask1); + inRange(imgHSV, Scalar(170, 70, 50), Scalar(180, 255, 255), mask2); + Mat1b mask = mask1 | mask2; + + + //Mat bwImage; + //Mat convertedImage; + vector> contours; + vector hierarchy; + + //cvtColor(img, bwImage, CV_RGB2GRAY); + //bwImage.convertTo(convertedImage, CV_8UC1); + findContours(mask, contours, hierarchy, RETR_TREE, CHAIN_APPROX_SIMPLE, Point(0, 0)); + + //cout << "Found: " << contours.size() << endl; + + vector contourAreas; + for (int i = 0; i < contours.size(); i++) { + double area = contourArea(contours[i]); + contourAreas.push_back(area); + + + Point2f center; + float radius; + + cout << "Found: " << contours[i].size() << endl; + minEnclosingCircle(contours[i], center, radius); + circle(img, center, radius, Scalar(0, 0, 255), 2); + } + + //double maxArea = *max_element(contourAreas.begin(), contourAreas.end()); + double maxAreaIndex = distance(contourAreas.begin(), max_element(contourAreas.begin(), contourAreas.end())); + + Point2f center; + float radius; + + + + minEnclosingCircle(contours[maxAreaIndex], center, radius); + circle(img, center, radius, Scalar(0, 0, 255), 2); + + cout << "Center: " << center << " Radius: " << radius << endl; + + imshow("Thresholded Image", mask); //show the thresholded image + imshow("Original", img); //show the original image + //imshow("Original", imgHSV); //show the original image + /* + imshow("MYWINDOW", img); + + */ + + // The following code computes the execution time in seconds and outputs to consoled should be around 0.01 + t = ((double)getTickCount() - t) / getTickFrequency(); + + int time_in_seconds = t / 1000; + + //cout << t << endl; + + // Update every 1 millisecond :) + waitKey(1); + } + + + waitKey(0); + + cvvDestroyWindow("MYWINDOW"); + + return 0; +} \ No newline at end of file diff --git a/OverwatchCV/OverwatchCV.vcxproj b/OverwatchCV/OverwatchCV.vcxproj new file mode 100644 index 0000000..4383c90 --- /dev/null +++ b/OverwatchCV/OverwatchCV.vcxproj @@ -0,0 +1,171 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {F50CF48A-2984-43CC-A9E4-E07B6C943912} + Win32Proj + OverwatchCV + 8.1 + + + + Application + true + v140 + Unicode + + + Application + false + v140 + true + Unicode + + + Application + true + v140 + Unicode + + + Application + false + v140 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + $(IncludePath) + $(LibraryPath) + + + true + + + false + + + false + + + + Use + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + C:\Users\GreenTurtle\Downloads\opencv\build\include\opencv2;%(AdditionalIncludeDirectories) + + + Console + true + C:\Users\GreenTurtle\Downloads\opencv\build\x64\vc14\lib;%(AdditionalLibraryDirectories) + opencv_world310.lib;opencv_world310d.lib;%(AdditionalDependencies) + + + + + Use + Level3 + Disabled + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + C:\Users\GreenTurtle\Downloads\opencv\build\include;%(AdditionalIncludeDirectories) + + + Console + true + C:\Users\GreenTurtle\Downloads\opencv\build\x64\vc14\lib;%(AdditionalLibraryDirectories) + opencv_world310d.lib;%(AdditionalDependencies) + + + + + Level3 + Use + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + Use + MaxSpeed + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + + + + + Create + Create + Create + Create + + + + + + \ No newline at end of file diff --git a/OverwatchCV/OverwatchCV.vcxproj.filters b/OverwatchCV/OverwatchCV.vcxproj.filters new file mode 100644 index 0000000..1815fb3 --- /dev/null +++ b/OverwatchCV/OverwatchCV.vcxproj.filters @@ -0,0 +1,36 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + + + + Header Files + + + Header Files + + + + + Source Files + + + Source Files + + + \ No newline at end of file diff --git a/OverwatchCV/ReadMe.txt b/OverwatchCV/ReadMe.txt new file mode 100644 index 0000000..37e44b6 --- /dev/null +++ b/OverwatchCV/ReadMe.txt @@ -0,0 +1,40 @@ +======================================================================== + CONSOLE APPLICATION : OverwatchCV Project Overview +======================================================================== + +AppWizard has created this OverwatchCV application for you. + +This file contains a summary of what you will find in each of the files that +make up your OverwatchCV application. + + +OverwatchCV.vcxproj + This is the main project file for VC++ projects generated using an Application Wizard. + It contains information about the version of Visual C++ that generated the file, and + information about the platforms, configurations, and project features selected with the + Application Wizard. + +OverwatchCV.vcxproj.filters + This is the filters file for VC++ projects generated using an Application Wizard. + It contains information about the association between the files in your project + and the filters. This association is used in the IDE to show grouping of files with + similar extensions under a specific node (for e.g. ".cpp" files are associated with the + "Source Files" filter). + +OverwatchCV.cpp + This is the main application source file. + +///////////////////////////////////////////////////////////////////////////// +Other standard files: + +StdAfx.h, StdAfx.cpp + These files are used to build a precompiled header (PCH) file + named OverwatchCV.pch and a precompiled types file named StdAfx.obj. + +///////////////////////////////////////////////////////////////////////////// +Other notes: + +AppWizard uses "TODO:" comments to indicate parts of the source code you +should add to or customize. + +///////////////////////////////////////////////////////////////////////////// diff --git a/OverwatchCV/stdafx.cpp b/OverwatchCV/stdafx.cpp new file mode 100644 index 0000000..0e125f4 --- /dev/null +++ b/OverwatchCV/stdafx.cpp @@ -0,0 +1,8 @@ +// stdafx.cpp : source file that includes just the standard includes +// OverwatchCV.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + +// TODO: reference any additional headers you need in STDAFX.H +// and not in this file diff --git a/OverwatchCV/stdafx.h b/OverwatchCV/stdafx.h new file mode 100644 index 0000000..b005a83 --- /dev/null +++ b/OverwatchCV/stdafx.h @@ -0,0 +1,15 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +// + +#pragma once + +#include "targetver.h" + +#include +#include + + + +// TODO: reference additional headers your program requires here diff --git a/OverwatchCV/targetver.h b/OverwatchCV/targetver.h new file mode 100644 index 0000000..87c0086 --- /dev/null +++ b/OverwatchCV/targetver.h @@ -0,0 +1,8 @@ +#pragma once + +// Including SDKDDKVer.h defines the highest available Windows platform. + +// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and +// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. + +#include diff --git a/OverwatchCV/x64/Debug/OverwatchCV.log b/OverwatchCV/x64/Debug/OverwatchCV.log new file mode 100644 index 0000000..d31925a --- /dev/null +++ b/OverwatchCV/x64/Debug/OverwatchCV.log @@ -0,0 +1,7 @@ + OverwatchCV.cpp +c:\users\greenturtle\documents\visual studio 2015\projects\overwatchcv\overwatchcv\overwatchcv.cpp(115): warning C4244: 'argument': conversion from 'float' to 'int', possible loss of data +c:\users\greenturtle\documents\visual studio 2015\projects\overwatchcv\overwatchcv\overwatchcv.cpp(119): warning C4244: 'initializing': conversion from '__int64' to 'double', possible loss of data +c:\users\greenturtle\documents\visual studio 2015\projects\overwatchcv\overwatchcv\overwatchcv.cpp(126): warning C4244: 'argument': conversion from 'double' to 'unsigned __int64', possible loss of data +c:\users\greenturtle\documents\visual studio 2015\projects\overwatchcv\overwatchcv\overwatchcv.cpp(127): warning C4244: 'argument': conversion from 'float' to 'int', possible loss of data +c:\users\greenturtle\documents\visual studio 2015\projects\overwatchcv\overwatchcv\overwatchcv.cpp(142): warning C4244: 'initializing': conversion from 'double' to 'int', possible loss of data + OverwatchCV.vcxproj -> C:\Users\GreenTurtle\Documents\Visual Studio 2015\Projects\OverwatchCV\x64\Debug\OverwatchCV.exe diff --git a/OverwatchCV/x64/Debug/OverwatchCV.obj b/OverwatchCV/x64/Debug/OverwatchCV.obj new file mode 100644 index 0000000..68bd832 Binary files /dev/null and b/OverwatchCV/x64/Debug/OverwatchCV.obj differ diff --git a/OverwatchCV/x64/Debug/OverwatchCV.pch b/OverwatchCV/x64/Debug/OverwatchCV.pch new file mode 100644 index 0000000..3b9a821 Binary files /dev/null and b/OverwatchCV/x64/Debug/OverwatchCV.pch differ diff --git a/OverwatchCV/x64/Debug/OverwatchCV.tlog/CL.command.1.tlog b/OverwatchCV/x64/Debug/OverwatchCV.tlog/CL.command.1.tlog new file mode 100644 index 0000000..30cca31 Binary files /dev/null and b/OverwatchCV/x64/Debug/OverwatchCV.tlog/CL.command.1.tlog differ diff --git a/OverwatchCV/x64/Debug/OverwatchCV.tlog/CL.read.1.tlog b/OverwatchCV/x64/Debug/OverwatchCV.tlog/CL.read.1.tlog new file mode 100644 index 0000000..44e4bea Binary files /dev/null and b/OverwatchCV/x64/Debug/OverwatchCV.tlog/CL.read.1.tlog differ diff --git a/OverwatchCV/x64/Debug/OverwatchCV.tlog/CL.write.1.tlog b/OverwatchCV/x64/Debug/OverwatchCV.tlog/CL.write.1.tlog new file mode 100644 index 0000000..e506335 Binary files /dev/null and b/OverwatchCV/x64/Debug/OverwatchCV.tlog/CL.write.1.tlog differ diff --git a/OverwatchCV/x64/Debug/OverwatchCV.tlog/OverwatchCV.lastbuildstate b/OverwatchCV/x64/Debug/OverwatchCV.tlog/OverwatchCV.lastbuildstate new file mode 100644 index 0000000..26ba376 --- /dev/null +++ b/OverwatchCV/x64/Debug/OverwatchCV.tlog/OverwatchCV.lastbuildstate @@ -0,0 +1,2 @@ +#TargetFrameworkVersion=v4.0:PlatformToolSet=v140:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=8.1 +Debug|x64|C:\Users\GreenTurtle\Documents\Visual Studio 2015\Projects\OverwatchCV\| diff --git a/OverwatchCV/x64/Debug/OverwatchCV.tlog/link.command.1.tlog b/OverwatchCV/x64/Debug/OverwatchCV.tlog/link.command.1.tlog new file mode 100644 index 0000000..3a4d0d2 Binary files /dev/null and b/OverwatchCV/x64/Debug/OverwatchCV.tlog/link.command.1.tlog differ diff --git a/OverwatchCV/x64/Debug/OverwatchCV.tlog/link.read.1.tlog b/OverwatchCV/x64/Debug/OverwatchCV.tlog/link.read.1.tlog new file mode 100644 index 0000000..4f5abd8 Binary files /dev/null and b/OverwatchCV/x64/Debug/OverwatchCV.tlog/link.read.1.tlog differ diff --git a/OverwatchCV/x64/Debug/OverwatchCV.tlog/link.write.1.tlog b/OverwatchCV/x64/Debug/OverwatchCV.tlog/link.write.1.tlog new file mode 100644 index 0000000..6f3cac5 Binary files /dev/null and b/OverwatchCV/x64/Debug/OverwatchCV.tlog/link.write.1.tlog differ diff --git a/OverwatchCV/x64/Debug/opencv_ffmpeg310_64.dll b/OverwatchCV/x64/Debug/opencv_ffmpeg310_64.dll new file mode 100644 index 0000000..040198c Binary files /dev/null and b/OverwatchCV/x64/Debug/opencv_ffmpeg310_64.dll differ diff --git a/OverwatchCV/x64/Debug/opencv_world310.dll b/OverwatchCV/x64/Debug/opencv_world310.dll new file mode 100644 index 0000000..317a474 Binary files /dev/null and b/OverwatchCV/x64/Debug/opencv_world310.dll differ diff --git a/OverwatchCV/x64/Debug/opencv_world310d.dll b/OverwatchCV/x64/Debug/opencv_world310d.dll new file mode 100644 index 0000000..80213c2 Binary files /dev/null and b/OverwatchCV/x64/Debug/opencv_world310d.dll differ diff --git a/OverwatchCV/x64/Debug/stdafx.obj b/OverwatchCV/x64/Debug/stdafx.obj new file mode 100644 index 0000000..d0df2fe Binary files /dev/null and b/OverwatchCV/x64/Debug/stdafx.obj differ diff --git a/OverwatchCV/x64/Debug/vc140.idb b/OverwatchCV/x64/Debug/vc140.idb new file mode 100644 index 0000000..4770e2d Binary files /dev/null and b/OverwatchCV/x64/Debug/vc140.idb differ diff --git a/OverwatchCV/x64/Debug/vc140.pdb b/OverwatchCV/x64/Debug/vc140.pdb new file mode 100644 index 0000000..c2a7970 Binary files /dev/null and b/OverwatchCV/x64/Debug/vc140.pdb differ diff --git a/ipch/OVERWATCHCV-3ef7d86e/OVERWATCHCV-5e7a82d8.ipch b/ipch/OVERWATCHCV-3ef7d86e/OVERWATCHCV-5e7a82d8.ipch new file mode 100644 index 0000000..c696afa Binary files /dev/null and b/ipch/OVERWATCHCV-3ef7d86e/OVERWATCHCV-5e7a82d8.ipch differ diff --git a/ipch/OVERWATCHCV-3ef7d86e/OVERWATCHCV-ce52fb6.ipch b/ipch/OVERWATCHCV-3ef7d86e/OVERWATCHCV-ce52fb6.ipch new file mode 100644 index 0000000..8fa6f3f Binary files /dev/null and b/ipch/OVERWATCHCV-3ef7d86e/OVERWATCHCV-ce52fb6.ipch differ diff --git a/x64/Debug/OverWatch.jpg b/x64/Debug/OverWatch.jpg new file mode 100644 index 0000000..dbaa487 Binary files /dev/null and b/x64/Debug/OverWatch.jpg differ diff --git a/x64/Debug/OverwatchCV.exe b/x64/Debug/OverwatchCV.exe new file mode 100644 index 0000000..fb3c36f Binary files /dev/null and b/x64/Debug/OverwatchCV.exe differ diff --git a/x64/Debug/OverwatchCV.ilk b/x64/Debug/OverwatchCV.ilk new file mode 100644 index 0000000..dd9ec9d Binary files /dev/null and b/x64/Debug/OverwatchCV.ilk differ diff --git a/x64/Debug/OverwatchCV.pdb b/x64/Debug/OverwatchCV.pdb new file mode 100644 index 0000000..f02dc39 Binary files /dev/null and b/x64/Debug/OverwatchCV.pdb differ diff --git a/x64/Debug/opencv_ffmpeg310_64.dll b/x64/Debug/opencv_ffmpeg310_64.dll new file mode 100644 index 0000000..040198c Binary files /dev/null and b/x64/Debug/opencv_ffmpeg310_64.dll differ diff --git a/x64/Debug/opencv_world310.dll b/x64/Debug/opencv_world310.dll new file mode 100644 index 0000000..317a474 Binary files /dev/null and b/x64/Debug/opencv_world310.dll differ diff --git a/x64/Debug/opencv_world310d.dll b/x64/Debug/opencv_world310d.dll new file mode 100644 index 0000000..80213c2 Binary files /dev/null and b/x64/Debug/opencv_world310d.dll differ