You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
SimpleSkyCam/detect.h

142 lines
3.2 KiB

/***************************************************************************************
*
* detect.h is part of SimpleSkyCam.
*
*****************************************************************************************/
#ifndef _DETECT_H_
#define _DETECT_H_
#include "pid.h"
#include "gui.h"
#include "config.h"
#include "video.h"
#include "videoframe.h"
#define DET_MAXSHIFT 20
enum {
AUTODETECT_OFF = 0,
AUTODETECT_BRIGHT
};
enum {
AUTOFOLLOW_OFF = 0,
AUTOFOLLOW_BRIGHT,
AUTOFOLLOW_CROSSC
};
enum {
POSCTL_MODE_OFF = 0,
POSCTL_MODE_CALIB,
POSCTL_MODE_CONTROL
};
class PosCtl {
private:
GMutex mutex;
int mode;
PID pid_axis[2];
time_t test_t1; // FIXME: only for testing gui functions
public:
PosCtl();
~PosCtl() {};
void LockMutex() { g_mutex_lock(&mutex); };
void UnLockMutex() { g_mutex_unlock(&mutex); };
void Stop ();
void StartCalibration ();
void StartControl ();
int GetMode () { return mode; };
void SetAxisParam (int axis, double min, double max, double k, double i, double d);
void GetAxisParam (int axis, double *min, double *max, double *k, double *i, double *d);
void Loop (int posx, int posy);
};
struct {
VideoFrame *image; // detected image
uint32_t *detmatrix;
int posx; // position of the detected object
int posy; // position of the detected object
} typedef DetectOutput;
class Detect {
private:
int running;
VideoFrame inFrame; // input frame
VideoFrame oldFrame; // oldinput frame
int inFrameNew; // new input frame;
VideoFrame image; // output image
VideoFrame imagegtk; // output image -- send to gtk
GMutex muteximage;
GMutex mutexin;
GMutex mutex; // general mutex for changing settings
GThread *thread;
float *maxx;
float *maxy;
int posmaxx;
int posmaxy;
uint32_t *detmatrix;
int objectX; // current object position
int objectY; // current object position
int objectW; // object Image Size Width
int objectH; // object Image Size Height
int minBright; // min brightness
int autodetecttype; // input detection type to use
int autofollowtype; // input detection type to use
void InputDetect (int *posx, int *posy);
void InputDetectCrossC (int *posx, int *posy);
void SetInputSize (int nw, int nh);
void CopyObjectImage(int objx, int objy);
public:
Detect();
~Detect();
int NewFrame(VideoFrame *newframe);
//
// Thread Releated Functions (maybe soon private?)
int TryLockInMutex() { return g_mutex_trylock(&mutexin); };
void LockInMutex() { g_mutex_lock(&mutexin);};
void UnLockInMutex() { g_mutex_unlock(&mutexin);};
int TryLockImageMutex() { return g_mutex_trylock(&muteximage); };
void LockImageMutex() { g_mutex_lock(&muteximage);};
void UnLockImageMutex() { g_mutex_unlock(&muteximage);};
void LockMutex() { g_mutex_lock(&mutex);};
void UnLockMutex() { g_mutex_unlock(&mutex);};
//
// Object functions
void SetObjectSize (int neww, int newh);
void GetObjectSize (int *ow, int *oh);
void SetMinBrightness (int value);
int GetMinBrightness();
void SetFollowType(int intype);
int GetFollowType();
void SetDetectType(int intype);
int GetDetectType();
void SetObjectPos (int x, int y);
void GetObjectPos (int *x, int *y);
void Thread();
};
#endif