ACT-CV - Machine Vision for Cognitive Modeling
|
the computer vision server provides the interface to ACT-R More...
#include <map>
#include <thread>
#include <vision/FrameSource.h>
#include <vision/QtFrameSource.h>
#include <vision/RobotFrameSource.h>
#include <vision/OpenCVFrameSource.h>
#include <vision/ImageFrameSource.h>
#include <Robot.h>
#include <Threads/Condition.h>
#include <Threads/ThreadSafeQueue.h>
#include <tests/TestFrameSource.h>
#include <FrameLoop.h>
#include "ACT-CV.i"
#include "ResultHolder.h"
Go to the source code of this file.
Classes | |
struct | Job |
something to do in the background thread More... | |
Macros | |
#define | DLLFUNC |
Functions | |
void | SetUpLoopInternal () |
void | TearDownLoopInternal () |
void | SelectSourceInternal (int vidSource) |
DLLFUNC void | SelectSource (video_source vs) |
select a source and initialize it More... | |
DLLFUNC void | SelectFileBasedSource (const char *filename, video_source vs) |
select a source and initialize it More... | |
void | ReleaseSourceInternal () |
DLLFUNC void | ReleaseSource () |
release a previous selected source More... | |
static void | BGFunc () |
the background video thread function More... | |
DLLFUNC void | ActCvInit () |
start the video processing thread More... | |
DLLFUNC void | WaitForNextFrame () |
wait a short time for a frame More... | |
DLLFUNC void | ActCvDeInit () |
stop the video processing thread More... | |
void | AddRecognitionInternal (int cvAlgo) |
DLLFUNC void | AddRecognition (cv_algorithm a) |
add an algorithm to the list of currently used algorithms More... | |
DLLFUNC void | SetMatchDefFile (const char *s) |
set the definition file for the matcher More... | |
DLLFUNC void | RemoveRecognition (cv_algorithm a) |
remove an algorithm from the list of currently used algorithms More... | |
DLLFUNC void | UpdateAttendedLoc (int x, int y) |
tell the vision package where ACT-R is currently looking More... | |
DLLFUNC void | MoveMouseTo (int x, int y) |
DLLFUNC void | MouseClick (int button) |
DLLFUNC void | PressKey (int key) |
DLLFUNC int | FindFirstLine () |
start the line data exchange More... | |
DLLFUNC int | FindNextLine (int handle, struct Line *line) |
harvest the line data More... | |
DLLFUNC void | LineFindFinish (int handle) |
release internal structures More... | |
DLLFUNC int | FindFirstMatch () |
start the image matching result exchange More... | |
DLLFUNC int | FindNextMatch (int handle, struct ObjectPosition *pos) |
harvest the match data More... | |
DLLFUNC void | MatchFindFinish (int handle) |
release internal structures More... | |
DLLFUNC int | FindFirstText () |
get textual elements More... | |
DLLFUNC int | FindNextText (int handle, struct ObjectPosition *pos) |
harvest the text data More... | |
DLLFUNC void | TextFindFinish (int handle) |
release internal structures More... | |
Variables | |
GCPointer< FrameSource > | frameSource = nullptr |
the currently used video source More... | |
Robot * | robot = nullptr |
instance of Robot if this is used More... | |
QtFrameSource * | qt = nullptr |
GCPointer< GCString > | frameSourceFileName |
name of the file used by image/file type frame sources More... | |
GCPointer< FrameLoop > | frameLoop |
the actual FrameLoop and support for observer classes More... | |
GCPointer< LineObs > | lineObs |
instance of the LineObs if this is used More... | |
GCPointer< ResultHolder< Line > > | lineResult |
global variable holding the results of LineObs More... | |
GCPointer< GCString > | matchDefFileName |
name of the file that defines the match targets More... | |
GCPointer< MatchObs > | matchObs |
instance of the MatchObs if this is used More... | |
GCPointer< ResultHolder < ObjectPosition > > | matchResult |
global variable holding the results of MatchObs More... | |
GCPointer< TextObs > | textObs |
instance of the TextObs if this is used More... | |
GCPointer< ResultHolder < ObjectPosition > > | textResult |
global variable holding the results of TextObs More... | |
GCPointer< AttendedLocObs > | attLocObs |
the observer that shows the current attended location More... | |
bool | exitFlag =false |
flag forcing the video thread to exit More... | |
std::mutex | threadMutex |
mutex for synchronisation with the video thread More... | |
thread * | bgThread = nullptr |
ThreadSafeQueue< Job > | jobs |
call queue for the background thread More... | |
the computer vision server provides the interface to ACT-R
Definition in file server-main.cpp.
#define DLLFUNC |
Definition at line 34 of file server-main.cpp.
DLLFUNC void ActCvDeInit | ( | ) |
stop the video processing thread
Definition at line 331 of file server-main.cpp.
References bgThread, exitFlag, and threadMutex.
Referenced by TestLines(), TestMatch(), and TestText().
DLLFUNC void ActCvInit | ( | ) |
start the video processing thread
Definition at line 307 of file server-main.cpp.
References BGFunc(), bgThread, exitFlag, MHDBGMSG, and threadMutex.
Referenced by TestLines(), TestMatch(), and TestText().
DLLFUNC void AddRecognition | ( | cv_algorithm | a) |
add an algorithm to the list of currently used algorithms
Definition at line 375 of file server-main.cpp.
References AddRecognitionInternal(), jobs, MHDBGMSG, and mhthreads::Condition::Wait().
Referenced by TestLines(), TestMatch(), and TestText().
void AddRecognitionInternal | ( | int | cvAlgo) |
Definition at line 347 of file server-main.cpp.
References a_lines, a_match, a_oflow, a_text, frameLoop, GCString::GetString(), lineObs, matchDefFileName, matchObs, textObs, and threadMutex.
Referenced by AddRecognition().
|
static |
the background video thread function
Definition at line 273 of file server-main.cpp.
References Job::completed, exitFlag, frameLoop, frameSource, jobs, lineObs, matchObs, Job::nullary_fn, SetUpLoopInternal(), mhthreads::Condition::Signal(), TearDownLoopInternal(), textObs, threadMutex, Job::unary_fn, and Job::val.
Referenced by ActCvInit().
DLLFUNC int FindFirstLine | ( | ) |
start the line data exchange
If FindFirstLine returns a handle, you must call LineFindFinish to release internal memory structures.
Definition at line 434 of file server-main.cpp.
References lineObs, lineResult, and MHDBGMSG.
Referenced by TestLines().
DLLFUNC int FindFirstMatch | ( | ) |
start the image matching result exchange
If FindFirstMatch returns a handle, you must call MatchFindFinish to release internal memory structures.
Definition at line 463 of file server-main.cpp.
References matchObs, matchResult, and MHDBGMSG.
Referenced by TestMatch().
DLLFUNC int FindFirstText | ( | ) |
get textual elements
Definition at line 490 of file server-main.cpp.
References MHDBGMSG, textObs, and textResult.
Referenced by TestText().
harvest the line data
Definition at line 448 of file server-main.cpp.
References lineResult, and MHDBGMSG.
Referenced by TestLines().
DLLFUNC int FindNextMatch | ( | int | handle, |
struct ObjectPosition * | pos | ||
) |
harvest the match data
Definition at line 474 of file server-main.cpp.
References matchResult, and MHDBGMSG.
Referenced by TestMatch().
DLLFUNC int FindNextText | ( | int | handle, |
struct ObjectPosition * | pos | ||
) |
harvest the text data
Definition at line 501 of file server-main.cpp.
References MHDBGMSG, and textResult.
Referenced by TestText().
DLLFUNC void LineFindFinish | ( | int | handle) |
release internal structures
Definition at line 454 of file server-main.cpp.
References lineResult, and MHDBGMSG.
Referenced by TestLines().
DLLFUNC void MatchFindFinish | ( | int | handle) |
release internal structures
Definition at line 480 of file server-main.cpp.
References matchResult, and MHDBGMSG.
Referenced by TestMatch().
DLLFUNC void MouseClick | ( | int | button) |
Definition at line 419 of file server-main.cpp.
References QtFrameSource::DoClick(), and qt.
Referenced by TestText().
DLLFUNC void MoveMouseTo | ( | int | x, |
int | y | ||
) |
Definition at line 410 of file server-main.cpp.
References attLocObs, qt, and QtFrameSource::SetMousePos().
Referenced by TestText().
DLLFUNC void PressKey | ( | int | key) |
Definition at line 426 of file server-main.cpp.
References QtFrameSource::DoPressKey(), and qt.
DLLFUNC void ReleaseSource | ( | ) |
release a previous selected source
Definition at line 263 of file server-main.cpp.
References jobs, MHDBGMSG, ReleaseSourceInternal(), and mhthreads::Condition::Wait().
Referenced by TestLines(), TestMatch(), and TestText().
void ReleaseSourceInternal | ( | ) |
Definition at line 239 of file server-main.cpp.
References attLocObs, frameLoop, frameSource, lineObs, MHDBGMSG, qt, robot, and threadMutex.
Referenced by ReleaseSource().
DLLFUNC void RemoveRecognition | ( | cv_algorithm | a) |
remove an algorithm from the list of currently used algorithms
Definition at line 396 of file server-main.cpp.
DLLFUNC void SelectFileBasedSource | ( | const char * | filename, |
video_source | vs | ||
) |
select a source and initialize it
Definition at line 226 of file server-main.cpp.
References frameSourceFileName, jobs, MHDBGMSG, SelectSourceInternal(), and mhthreads::Condition::Wait().
Referenced by TestLines(), and TestText().
DLLFUNC void SelectSource | ( | video_source | vs) |
select a source and initialize it
Definition at line 212 of file server-main.cpp.
References jobs, MHDBGMSG, SelectSourceInternal(), and mhthreads::Condition::Wait().
Referenced by TestLines(), and TestMatch().
void SelectSourceInternal | ( | int | vidSource) |
Definition at line 156 of file server-main.cpp.
References OpenCVFrameSource::CameraSourceFactory(), OpenCVFrameSource::FileSourceFactory(), frameSource, frameSourceFileName, Robot::GetScreenHeight(), Robot::GetScreenWidth(), GCString::GetString(), ImageFrameSource::ImageSourceFactory(), MHDBGMSG, qt, QtFrameSource::QtSourceFactory(), robot, s_cam, s_file, s_robot, s_singleImage, s_test, s_web, RobotFrameSource::SetSize(), and threadMutex.
Referenced by SelectFileBasedSource(), and SelectSource().
DLLFUNC void SetMatchDefFile | ( | const char * | s) |
set the definition file for the matcher
Definition at line 389 of file server-main.cpp.
References matchDefFileName.
Referenced by TestMatch().
void SetUpLoopInternal | ( | ) |
Definition at line 140 of file server-main.cpp.
References attLocObs, frameLoop, and threadMutex.
Referenced by BGFunc().
void TearDownLoopInternal | ( | ) |
Definition at line 147 of file server-main.cpp.
References attLocObs, frameLoop, lineObs, matchObs, textObs, and threadMutex.
Referenced by BGFunc().
DLLFUNC void TextFindFinish | ( | int | handle) |
release internal structures
Definition at line 507 of file server-main.cpp.
References MHDBGMSG, and textResult.
Referenced by TestText().
DLLFUNC void UpdateAttendedLoc | ( | int | x, |
int | y | ||
) |
tell the vision package where ACT-R is currently looking
Definition at line 400 of file server-main.cpp.
References attLocObs, and MHDBGMSG.
Referenced by TestMatch(), and TestText().
DLLFUNC void WaitForNextFrame | ( | ) |
wait a short time for a frame
Definition at line 320 of file server-main.cpp.
References frameLoop, and MHDBGMSG.
Referenced by TestLines(), TestMatch(), and TestText().
GCPointer<AttendedLocObs> attLocObs |
the observer that shows the current attended location
Definition at line 109 of file server-main.cpp.
Referenced by MoveMouseTo(), ReleaseSourceInternal(), SetUpLoopInternal(), TearDownLoopInternal(), and UpdateAttendedLoc().
thread* bgThread = nullptr |
Definition at line 116 of file server-main.cpp.
Referenced by ActCvDeInit(), and ActCvInit().
bool exitFlag =false |
flag forcing the video thread to exit
Definition at line 112 of file server-main.cpp.
Referenced by ActCvDeInit(), ActCvInit(), and BGFunc().
the actual FrameLoop and support for observer classes
Currently there's only one implementation of this class, so this usage of inheritance might be overdoing
Definition at line 86 of file server-main.cpp.
Referenced by AddRecognitionInternal(), BGFunc(), main(), ReleaseSourceInternal(), SetUpLoopInternal(), TearDownLoopInternal(), and WaitForNextFrame().
GCPointer<FrameSource> frameSource = nullptr |
the currently used video source
Definition at line 64 of file server-main.cpp.
Referenced by BGFunc(), ReleaseSourceInternal(), and SelectSourceInternal().
name of the file used by image/file type frame sources
Definition at line 79 of file server-main.cpp.
Referenced by SelectFileBasedSource(), and SelectSourceInternal().
ThreadSafeQueue<Job> jobs |
call queue for the background thread
Definition at line 138 of file server-main.cpp.
Referenced by AddRecognition(), BGFunc(), ReleaseSource(), SelectFileBasedSource(), and SelectSource().
instance of the LineObs if this is used
Definition at line 89 of file server-main.cpp.
Referenced by AddRecognitionInternal(), BGFunc(), FindFirstLine(), ReleaseSourceInternal(), and TearDownLoopInternal().
GCPointer<ResultHolder<Line> > lineResult |
global variable holding the results of LineObs
Definition at line 91 of file server-main.cpp.
Referenced by FindFirstLine(), FindNextLine(), and LineFindFinish().
name of the file that defines the match targets
Definition at line 95 of file server-main.cpp.
Referenced by AddRecognitionInternal(), and SetMatchDefFile().
instance of the MatchObs if this is used
Definition at line 97 of file server-main.cpp.
Referenced by AddRecognitionInternal(), BGFunc(), FindFirstMatch(), and TearDownLoopInternal().
GCPointer<ResultHolder<ObjectPosition> > matchResult |
global variable holding the results of MatchObs
Definition at line 99 of file server-main.cpp.
Referenced by FindFirstMatch(), FindNextMatch(), and MatchFindFinish().
QtFrameSource* qt = nullptr |
Definition at line 75 of file server-main.cpp.
Referenced by MouseClick(), MoveMouseTo(), PressKey(), ReleaseSourceInternal(), and SelectSourceInternal().
Robot* robot = nullptr |
instance of Robot if this is used
The Robot is not a member of the RobotFrameSource because its other members (for the generation of mouse and key events) will be needed.
Definition at line 73 of file server-main.cpp.
Referenced by main(), ReleaseSourceInternal(), and SelectSourceInternal().
instance of the TextObs if this is used
Definition at line 103 of file server-main.cpp.
Referenced by AddRecognitionInternal(), BGFunc(), FindFirstText(), and TearDownLoopInternal().
GCPointer<ResultHolder<ObjectPosition> > textResult |
global variable holding the results of TextObs
Definition at line 105 of file server-main.cpp.
Referenced by FindFirstText(), FindNextText(), and TextFindFinish().
std::mutex threadMutex |
mutex for synchronisation with the video thread
Definition at line 114 of file server-main.cpp.
Referenced by ActCvDeInit(), ActCvInit(), AddRecognitionInternal(), BGFunc(), ReleaseSourceInternal(), SelectSourceInternal(), SetUpLoopInternal(), and TearDownLoopInternal().