-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v0.1.1 - version release (internal) (#18)
* initial commit * feature: added mouse controller * feature: video input buffer (initial commit/not tested) * cmake installer - initial commit * cmake installer - added CMakeLists files * added build script and cmake files for build * create cmake.yml for github action * buld script - we donot need the build (cmake files) dir * fixes - header filled up for Controller; Common controller status; initial commit for event processor * event generator - created common controller state to use in event generator * [feature] event processor - process input, generate event, and execute * [feature] face detector - added face detector and tracking using OpenCV * [bugfix] generator - the relative mouse postition calculation has issue with float conversion * [feature] added mouse engine for mouse movement * renamed FaceDetactor library to Detector * added UML class diagram (unfinished) * create license under GPLv3 * cmake - updated CMakeLists and added build.sh * cmake.yml - updated to use build.sh script * cmake - opencv dependency qt5 install * cmake - added only required opencv lib build * cmake - updated to include third_party dir in local build (failing) * cmake - build updated to include third_party library * cmake - modified build.bat for complete build * updated build.sh for complete build * cmake - comment is creting issue in cmake command * cmake - build.sh cmake build dir seems to be one dir top * readme update * added usage description * cmake.yml - convert to windows build * build.bat - updated to install required software * cmake.yml - remove call command * cmake.yml - added dev option * build.bat - remove comment from cmake command * build.bat - separeted opencv build for dev option * build.bat - fixed script (multiline command) * build.bat - removed Visual Studiog generator part from cmake * build.bat - error catching not working * build.bat - ommit catch error after choco install for now * updated readme * cmake.yml - use setup-msbuild action * updated readme * cmake.yml - ommit version specification * cmake.yml - debug pwd * cmake.yml - working dir issue * cmake.yml - build.bat file not running * cmake.yml - build.bat not running * build.bat - updated cursorControl dir for cmake build * version update - v0.1.1
- Loading branch information
Showing
29 changed files
with
2,233 additions
and
368 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
name: CMake | ||
|
||
on: | ||
push: | ||
branches: [ dev ] | ||
pull_request: | ||
branches: [ dev ] | ||
|
||
env: | ||
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) | ||
BUILD_TYPE: Debug | ||
|
||
jobs: | ||
build: | ||
# The CMake configure and build commands are platform agnostic and should work equally | ||
# well on Windows or Mac. You can convert this to a matrix build if you need | ||
# cross-platform coverage. | ||
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix | ||
runs-on: windows-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: microsoft/[email protected] | ||
|
||
- name: Build and Install | ||
working-directory: ${{github.workspace}} | ||
run: .\build.bat dev | ||
# - name: Configure CMake | ||
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. | ||
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type | ||
# run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} | ||
|
||
# - name: Build | ||
# Build your program with the given configuration | ||
# run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} | ||
|
||
# - name: Test | ||
# working-directory: ${{github.workspace}}/build | ||
# Execute tests defined by the CMake configuration. | ||
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail | ||
# run: ctest -C ${{env.BUILD_TYPE}} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
**/.vscode | ||
**/*.exe | ||
**/*.pptx | ||
cmake_tests/ | ||
third_party/ | ||
build/ | ||
install/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
cmake_minimum_required(VERSION 3.10) | ||
|
||
# project name | ||
project(cursorControl VERSION 0.1.1) | ||
|
||
# secify C++ standard | ||
set(CMAKE_CXX_STANDARD 11) | ||
set(CMAKE_CXX_STANDARD_REQUIRED True) | ||
|
||
configure_file(cursorControl.h.in cursorControl.h) | ||
|
||
# include third-party packages | ||
set(BOOST_ROOT ".\\third_party\\boost_1_76_0") | ||
find_package(Boost 1.76.0 REQUIRED) | ||
if(Boost_FOUND) | ||
message(STATUS "Boost_VERSION: ${Boost_VERSION}") | ||
message(STATUS "Boost_INCLUDE_DIRS: ${Boost_INCLUDE_DIRS}") | ||
message(STATUS "Boost_LIBRARIES: ${Boost_LIBRARIES}") | ||
include_directories(${Boost_INCLUDE_DIR}) | ||
endif() | ||
|
||
set(OpenCV_STATIC ON) | ||
set(OpenCV_DIR "third_party\\opencv\\build") | ||
find_package(OpenCV REQUIRED) | ||
if(OpenCV_FOUND) | ||
message(STATUS "OpenCV_VERSION: ${OpenCV_VERSION}") | ||
message(STATUS "OpenCV_INCLUDE_DIRS: ${OpenCV_INCLUDE_DIRS}") | ||
message(STATUS "OpenCV_LIBRARIES: ${OpenCV_LIBS}") | ||
include_directories(${OpenCV_INCLUDE_DIRS}) | ||
endif() | ||
|
||
# include subdirectories to be built | ||
add_subdirectory(Controller) | ||
add_subdirectory(InputBuffer) | ||
add_subdirectory(EventProcessor) | ||
add_subdirectory(Detector) | ||
add_subdirectory(Engine) | ||
|
||
# add executables | ||
add_executable(cursorControl cursorControl.cpp) | ||
|
||
target_link_libraries(cursorControl PUBLIC | ||
Controller | ||
InputBuffer | ||
EventProcessor | ||
Detector | ||
Engine | ||
${OpenCV_LIBS} | ||
) | ||
|
||
target_include_directories(cursorControl PUBLIC | ||
"${PROJECT_BINARY_DIR}" | ||
"${OpenCV_INCLUDE_DIRS}" | ||
) | ||
|
||
install(TARGETS cursorControl DESTINATION bin) | ||
install(FILES "${PROJECT_BINARY_DIR}/cursorControl.h" DESTINATION include) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
add_library(Controller mousectl.cpp) | ||
|
||
target_include_directories(Controller PUBLIC | ||
../ | ||
) | ||
|
||
install(TARGETS Controller DESTINATION lib) | ||
install(FILES Controller.h DESTINATION include) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#ifndef CC_CONTROLLER | ||
#define CC_CONTROLLER | ||
|
||
#include "boost\variant.hpp" | ||
|
||
#include <utility> | ||
#include <string> | ||
#include <map> | ||
|
||
// enum for controller state names | ||
enum class StateNames{ | ||
mouse_position, | ||
mouse_click_state | ||
}; | ||
|
||
// enum for mouse click states | ||
enum class ClickStates{ None, Right, Left }; | ||
|
||
// class to hold position such as mouse cursor | ||
class Position{ | ||
public: | ||
int x; | ||
int y; | ||
Position() { x = -1; y = -1; } | ||
Position(int x_p, int y_p) { x = x_p; y = y_p; } | ||
}; | ||
|
||
// template class to create controller state value | ||
template <typename StateValue> | ||
class ControllerStateValue{ | ||
StateValue stateValue; | ||
public: | ||
ControllerStateValue() {}; | ||
ControllerStateValue(StateValue value) : stateValue(value) {}; | ||
StateValue value() { return stateValue; }; | ||
}; | ||
|
||
// typedef of controller state value types | ||
typedef boost::variant<ControllerStateValue<Position>,ControllerStateValue<ClickStates>> StateValues; | ||
|
||
// base class for contorller | ||
class Controller { | ||
std::map< StateNames, StateValues > states; | ||
public: | ||
template <typename StateValue> void setState(StateNames stateName, StateValue stateValue){ states[stateName] = stateValue; } | ||
template <typename StateValue> StateValue getState(StateNames name){ return boost::get<StateValue>(states[name]); } | ||
virtual void execute() = 0; | ||
}; | ||
|
||
// base class for mouse event processor | ||
class MouseController : public Controller { | ||
public: | ||
MouseController(); | ||
virtual void execute() = 0; | ||
}; | ||
|
||
// class for mouse movement event processor | ||
class MouseMover : public MouseController { | ||
public: | ||
void execute(); | ||
}; | ||
|
||
// class for mouse click event processor | ||
class MouseClicker : public MouseController { | ||
public: | ||
void execute(); | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#ifndef CC_MOUSE_CONTROLLER | ||
#define CC_MOUSE_CONTROLLER | ||
|
||
#include "Controller.h" | ||
|
||
#include <windows.h> | ||
|
||
MouseController::MouseController(){ | ||
// StateNames mousePosition = mouse_position; | ||
Position position; | ||
setState(StateNames::mouse_position, ControllerStateValue<Position>(position)); | ||
|
||
// StateNames mouseClickState = mouse_click_state; | ||
ClickStates clickState{}; | ||
setState(StateNames::mouse_click_state, ControllerStateValue<ClickStates>(clickState)); | ||
} | ||
|
||
void MouseMover::execute(){ | ||
// get mouse position | ||
ControllerStateValue<Position> mouseMoveState = getState<ControllerStateValue<Position>>(StateNames::mouse_position); | ||
Position position = mouseMoveState.value(); | ||
|
||
// create an mouse input event | ||
INPUT Input = {0}; | ||
Input.type = INPUT_MOUSE; | ||
Input.mi.dwFlags = MOUSEEVENTF_MOVE|MOUSEEVENTF_ABSOLUTE; | ||
|
||
// move mouse cursor | ||
Input.mi.dx = LONG(position.x); | ||
Input.mi.dy = LONG(position.y); | ||
SendInput(1,&Input,sizeof(INPUT)); | ||
|
||
// set input event to zero - TODO delete INPUT | ||
ZeroMemory(&Input,sizeof(INPUT)); | ||
} | ||
|
||
void MouseClicker::execute(){ | ||
// get click state | ||
ControllerStateValue<ClickStates> mouseClickState = getState<ControllerStateValue<ClickStates>>(StateNames::mouse_click_state); | ||
ClickStates clickState = mouseClickState.value(); | ||
|
||
// create and mouse input event | ||
INPUT Input = {0}; | ||
Input.type = INPUT_MOUSE; | ||
|
||
if(clickState == ClickStates::Right){ | ||
// hold down mouse right button | ||
Input.mi.dwFlags = MOUSEEVENTF_RIGHTDOWN; | ||
SendInput(1,&Input,sizeof(INPUT)); | ||
|
||
// release mouse right button | ||
Input.mi.dwFlags = MOUSEEVENTF_RIGHTUP; | ||
SendInput(1,&Input,sizeof(INPUT)); | ||
} | ||
else if(clickState == ClickStates::Left){ | ||
// hold down mouse left button | ||
Input.mi.dwFlags = MOUSEEVENTF_LEFTDOWN; | ||
SendInput(1,&Input,sizeof(INPUT)); | ||
|
||
// release mouse left button | ||
Input.mi.dwFlags = MOUSEEVENTF_LEFTUP; | ||
SendInput(1,&Input,sizeof(INPUT)); | ||
} | ||
else{ | ||
printf("[DEBUG][Controller:mousectl] MouseClicker - No actionable click state\n"); | ||
} | ||
|
||
// set input event to zero - TODO delete INPUT | ||
ZeroMemory(&Input,sizeof(INPUT)); | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
add_library(Detector cvfacedetect.cpp) | ||
|
||
target_include_directories(Detector PUBLIC | ||
../ | ||
) | ||
|
||
install(TARGETS Detector DESTINATION lib) | ||
install(FILES Detector.h DESTINATION include) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#ifndef CC_FACE_DETECTOR | ||
#define CC_FACE_DETECTOR | ||
|
||
#include "opencv2\core.hpp" | ||
#include "opencv2\core\core.hpp" | ||
#include "opencv2\core\base.hpp" | ||
#include "opencv2\core\mat.hpp" | ||
#include "opencv2\core\types.hpp" | ||
#include <opencv2\core\utility.hpp> | ||
#include "opencv2\imgproc.hpp" | ||
#include "opencv2\objdetect.hpp" | ||
#include "opencv2\highgui.hpp" | ||
|
||
#include <cstdarg> | ||
#include <vector> | ||
|
||
// base class for face detector | ||
template <typename DetectedOutput> | ||
class Detector{ | ||
int type; | ||
public: | ||
virtual DetectedOutput detect(int argc, ...) = 0; | ||
}; | ||
|
||
// class for face detector using opencv tempalte matching | ||
class CVTemplateFaceDetector : public Detector<cv::Point>{ | ||
int matchMethod = cv::TM_CCOEFF_NORMED; | ||
public: | ||
cv::Point detect(int argc, ...); | ||
}; | ||
|
||
// class for face detector using opencv haar cascade classifier | ||
class CVCascadeFaceDetector : public Detector<cv::Rect>{ | ||
cv::String faceCascadeName = cv::samples::findFile("haarcascades\\haarcascade_frontalface_alt.xml"); | ||
cv::CascadeClassifier faceCascade; | ||
public: | ||
cv::Rect detect(int argc, ...); | ||
}; | ||
|
||
#endif |
Oops, something went wrong.