diff --git a/po/POTFILES.in b/po/POTFILES.in
index 8b8cab4d..7cfea57b 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -11,7 +11,6 @@ src/motionplus.cpp
src/netcam.cpp
src/picture.cpp
src/rotate.cpp
-src/track.cpp
src/video_common.cpp
src/video_loopback.cpp
src/video_v4l2.cpp
diff --git a/src/Makefile.am b/src/Makefile.am
index ccd852e9..72344f09 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -10,7 +10,7 @@ bin_PROGRAMS = motionplus
motionplus_SOURCES = motionplus.cpp motion_loop.cpp logger.cpp conf.cpp util.cpp alg.cpp alg_sec.cpp\
video_v4l2.cpp video_common.cpp video_loopback.cpp netcam.cpp jpegutils.cpp exif.cpp \
- rotate.cpp draw.cpp event.cpp movie.cpp picture.cpp dbse.cpp track.cpp \
+ rotate.cpp draw.cpp event.cpp movie.cpp picture.cpp dbse.cpp \
webu.cpp webu_html.cpp webu_stream.cpp webu_json.cpp webu_post.cpp \
mmalcam.cpp $(MMAL_SRC)
diff --git a/src/conf.cpp b/src/conf.cpp
index 59070bae..16f11782 100644
--- a/src/conf.cpp
+++ b/src/conf.cpp
@@ -623,14 +623,10 @@ struct ctx_parm config_parms[] = {
0, PARM_TYP_STRING, PARM_CAT_16, WEBUI_LEVEL_ADVANCED},
{
- "track_type",
+ "track_auto",
"############################################################\n"
"# Tracking configuration parameters\n"
"############################################################\n\n"
- "# Method used by tracking camera. See motionplus_guide.html",
- 0, PARM_TYP_INT, PARM_CAT_17, WEBUI_LEVEL_LIMITED },
- {
- "track_auto",
"# Enable auto tracking",
0, PARM_TYP_BOOL, PARM_CAT_17, WEBUI_LEVEL_LIMITED },
{
@@ -638,18 +634,10 @@ struct ctx_parm config_parms[] = {
"# Delay to wait for after tracking movement as number of picture frames.",
0, PARM_TYP_INT, PARM_CAT_17, WEBUI_LEVEL_LIMITED },
{
- "track_generic_move",
+ "track_move_command",
"# Command to execute to move a camera in generic tracking mode",
0, PARM_TYP_STRING, PARM_CAT_17, WEBUI_LEVEL_LIMITED },
{
- "track_step_angle_x",
- "# Angle in degrees the camera moves per step on the X-axis with auto-track",
- 0, PARM_TYP_INT, PARM_CAT_17, WEBUI_LEVEL_LIMITED },
- {
- "track_step_angle_y",
- "# Angle in degrees the camera moves per step on the Y-axis with auto-track.",
- 0, PARM_TYP_INT, PARM_CAT_17, WEBUI_LEVEL_LIMITED },
- {
"camera",
"##############################################################\n"
"# Camera config files - One for each camera.\n"
@@ -2995,25 +2983,6 @@ static void conf_edit_sql_query(struct ctx_cam *cam, std::string &parm, enum PAR
MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","sql_query",_("sql_query"));
}
-static void conf_edit_track_type(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact)
-{
- int parm_in;
- if (pact == PARM_ACT_DFLT){
- cam->conf->track_type = 0;
- } else if (pact == PARM_ACT_SET){
- parm_in = atoi(parm.c_str());
- if ((parm_in < 0) || (parm_in > 5)) {
- MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid track_type %d"),parm_in);
- } else {
- cam->conf->track_type = parm_in;
- }
- } else if (pact == PARM_ACT_GET){
- parm = std::to_string(cam->conf->track_type);
- }
- return;
- MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","track_type",_("track_type"));
-}
-
static void conf_edit_track_auto(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact)
{
if (pact == PARM_ACT_DFLT){
@@ -3046,55 +3015,17 @@ static void conf_edit_track_move_wait(struct ctx_cam *cam, std::string &parm, en
MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","track_move_wait",_("track_move_wait"));
}
-static void conf_edit_track_generic_move(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact)
+static void conf_edit_track_move_command(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact)
{
if (pact == PARM_ACT_DFLT) {
- cam->conf->track_generic_move = "";
+ cam->conf->track_move_command = "";
} else if (pact == PARM_ACT_SET){
- cam->conf->track_generic_move = parm;
+ cam->conf->track_move_command = parm;
} else if (pact == PARM_ACT_GET){
- parm = cam->conf->track_generic_move;
+ parm = cam->conf->track_move_command;
}
return;
- MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","track_generic_move",_("track_generic_move"));
-}
-
-static void conf_edit_track_step_angle_x(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact)
-{
- int parm_in;
- if (pact == PARM_ACT_DFLT){
- cam->conf->track_step_angle_x = 0;
- } else if (pact == PARM_ACT_SET){
- parm_in = atoi(parm.c_str());
- if ((parm_in < 0) || (parm_in > 2147483647)) {
- MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid track_step_angle_x %d"),parm_in);
- } else {
- cam->conf->track_step_angle_x = parm_in;
- }
- } else if (pact == PARM_ACT_GET){
- parm = std::to_string(cam->conf->track_step_angle_x);
- }
- return;
- MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","track_step_angle_x",_("track_step_angle_x"));
-}
-
-static void conf_edit_track_step_angle_y(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact)
-{
- int parm_in;
- if (pact == PARM_ACT_DFLT){
- cam->conf->track_step_angle_y = 0;
- } else if (pact == PARM_ACT_SET){
- parm_in = atoi(parm.c_str());
- if ((parm_in < 0) || (parm_in > 2147483647)) {
- MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid track_step_angle_y %d"),parm_in);
- } else {
- cam->conf->track_step_angle_y = parm_in;
- }
- } else if (pact == PARM_ACT_GET){
- parm = std::to_string(cam->conf->track_step_angle_y);
- }
- return;
- MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","track_step_angle_y",_("track_step_angle_y"));
+ MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","track_move_command",_("track_move_command"));
}
/* Application level parameters */
@@ -3352,12 +3283,9 @@ static void conf_edit_cat16(struct ctx_cam *cam, std::string parm_nm
static void conf_edit_cat17(struct ctx_cam *cam, std::string parm_nm
, std::string &parm_val, enum PARM_ACT pact)
{
- if (parm_nm == "track_type"){ conf_edit_track_type(cam, parm_val, pact);
- } else if (parm_nm == "track_auto"){ conf_edit_track_auto(cam, parm_val, pact);
+ if (parm_nm == "track_auto"){ conf_edit_track_auto(cam, parm_val, pact);
} else if (parm_nm == "track_move_wait"){ conf_edit_track_move_wait(cam, parm_val, pact);
- } else if (parm_nm == "track_generic_move"){ conf_edit_track_generic_move(cam, parm_val, pact);
- } else if (parm_nm == "track_step_angle_x"){ conf_edit_track_step_angle_x(cam, parm_val, pact);
- } else if (parm_nm == "track_step_angle_y"){ conf_edit_track_step_angle_y(cam, parm_val, pact);
+ } else if (parm_nm == "track_move_command"){ conf_edit_track_move_command(cam, parm_val, pact);
}
}
diff --git a/src/conf.hpp b/src/conf.hpp
index 3aa99908..08a3b51e 100644
--- a/src/conf.hpp
+++ b/src/conf.hpp
@@ -178,12 +178,9 @@
std::string sql_query_stop;
std::string sql_query;
- int track_type;
int track_auto;
- int track_step_angle_x;
- int track_step_angle_y;
int track_move_wait;
- std::string track_generic_move;
+ std::string track_move_command;
};
/* Categories for he edits and display on web interface*/
diff --git a/src/motion_loop.cpp b/src/motion_loop.cpp
index 97ef7983..41b8ebf4 100644
--- a/src/motion_loop.cpp
+++ b/src/motion_loop.cpp
@@ -32,7 +32,6 @@
#include "conf.hpp"
#include "alg.hpp"
#include "alg_sec.hpp"
-#include "track.hpp"
#include "event.hpp"
#include "picture.hpp"
#include "rotate.hpp"
@@ -208,7 +207,30 @@ static void mlp_detected_trigger(struct ctx_cam *cam, struct ctx_image_data *img
}
-static void mlp_detected(struct ctx_cam *cam, int dev, struct ctx_image_data *img)
+static void mlp_track_center(struct ctx_cam *cam)
+{
+
+ if ((cam->conf->track_auto) && (cam->conf->track_move_command != "")) {
+ cam->track_posx = 0;
+ cam->track_posy = 0;
+ util_exec_command(cam, cam->conf->track_move_command.c_str(), NULL, 0);
+ cam->frame_skip = cam->conf->track_move_wait;
+ }
+
+}
+
+static void mlp_track_move(struct ctx_cam *cam, struct ctx_coord *cent)
+{
+
+ if ((cam->conf->track_auto) && (cam->conf->track_move_command != "")) {
+ cam->track_posx += cent->x;
+ cam->track_posy += cent->y;
+ util_exec_command(cam, cam->conf->track_move_command.c_str(), NULL, 0);
+ cam->frame_skip = cam->conf->track_move_wait;
+ }
+}
+
+static void mlp_detected(struct ctx_cam *cam, struct ctx_image_data *img)
{
struct ctx_config *conf = cam->conf;
unsigned int distX, distY;
@@ -233,9 +255,7 @@ static void mlp_detected(struct ctx_cam *cam, int dev, struct ctx_image_data *im
}
}
- if (cam->conf->track_type && cam->conf->track_auto){
- cam->frame_skip = track_move(cam, dev, &img->location, &cam->imgs, 0);
- }
+ mlp_track_move(cam, &img->location);
}
@@ -671,8 +691,6 @@ static int mlp_init(struct ctx_cam *cam)
pic_init_privacy(cam);
- track_init(cam);
-
mlp_init_areadetect(cam);
mlp_init_ref(cam);
@@ -699,8 +717,6 @@ void mlp_cleanup(struct ctx_cam *cam)
algsec_deinit(cam);
- track_deinit(cam);
-
if (cam->video_dev >= 0) mlp_cam_close(cam);
free(cam->imgs.image_motion.image_norm);
@@ -1167,7 +1183,7 @@ static void mlp_actions_emulate(struct ctx_cam *cam)
cam->imgs.image_ring[indx].flags |= IMAGE_SAVE;
}
- mlp_detected(cam, cam->video_dev, cam->current_image);
+ mlp_detected(cam, cam->current_image);
}
@@ -1207,7 +1223,7 @@ static void mlp_actions_motion(struct ctx_cam *cam)
cam->current_image->flags |= IMAGE_PRECAP;
}
- mlp_detected(cam, cam->video_dev, cam->current_image);
+ mlp_detected(cam, cam->current_image);
}
static void mlp_actions_event(struct ctx_cam *cam)
@@ -1231,9 +1247,7 @@ static void mlp_actions_event(struct ctx_cam *cam)
}
event(cam, EVENT_ENDMOTION, NULL, NULL, NULL, &cam->current_image->imgts);
- if (cam->conf->track_type) {
- cam->frame_skip = track_center(cam, cam->video_dev, 0, 0, 0);
- }
+ mlp_track_center(cam);
if (cam->algsec_inuse){
if (cam->algsec->isdetected){
diff --git a/src/motionplus.hpp b/src/motionplus.hpp
index c79f9e78..b40efc68 100644
--- a/src/motionplus.hpp
+++ b/src/motionplus.hpp
@@ -80,7 +80,6 @@ struct ctx_movie;
struct ctx_netcam;
struct ctx_algsec;
struct ctx_config;
-struct ctx_track;
struct ctx_v4l2cam;
#define MYFFVER (LIBAVFORMAT_VERSION_MAJOR * 1000)+LIBAVFORMAT_VERSION_MINOR
@@ -284,7 +283,6 @@ struct ctx_cam {
pthread_t thread_id;
struct ctx_config *conf;
- struct ctx_track *track;
struct ctx_images imgs;
struct ctx_mmalcam *mmalcam;
struct ctx_netcam *netcam; /* this structure contains the context for normal RTSP connection */
diff --git a/src/track.cpp b/src/track.cpp
deleted file mode 100644
index 41e6c4eb..00000000
--- a/src/track.cpp
+++ /dev/null
@@ -1,498 +0,0 @@
-/*
- * This file is part of MotionPlus.
- *
- * MotionPlus is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * MotionPlus is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with MotionPlus. If not, see .
- *
- * Copyright 2020 MotionMrDave@gmail.com
- *
-*/
-#include
-#include "motionplus.hpp"
-#include "conf.hpp"
-#include "logger.hpp"
-#include "util.hpp"
-#include "track.hpp"
-
-#ifdef HAVE_V4L2
- #define INCPANTILT 64 // 1 degree
- #include
-#endif
-
-#define TRACK_TYPE_GENERIC 1
-#define TRACK_TYPE_UVC 2
-
-
-/**Center the uvc camera*/
-static int uvc_center(struct ctx_cam *cam, int dev, int x_angle, int y_angle)
-{
-
- #ifdef HAVE_V4L2
- /* CALC ABSOLUTE MOVING : Act.Position +/- delta to request X and Y */
- int move_x_degrees = 0, move_y_degrees = 0;
-
- union pantilt {
- struct {
- short pan;
- short tilt;
- } s16;
- int value;
- };
- union pantilt pan;
-
- if (cam->track->dev == -1) {
-
- int reset = 3; //0-non reset, 1-reset pan, 2-reset tilt, 3-reset pan&tilt
- struct v4l2_control control_s;
-
- control_s.id = V4L2_CID_PAN_RESET;
- control_s.value = (unsigned char) reset;
-
- if (ioctl(dev, VIDIOC_S_CTRL, &control_s) < 0) {
- MOTION_LOG(ERR, TYPE_TRACK, SHOW_ERRNO
- ,_("Failed to reset UVC camera to starting position! Reason"));
- return 0;
- }
-
- control_s.id = V4L2_CID_TILT_RESET;
- control_s.value = (unsigned char) reset;
-
- if (ioctl(dev, VIDIOC_S_CTRL, &control_s) < 0) {
- MOTION_LOG(ERR, TYPE_TRACK, SHOW_ERRNO
- ,_("Failed to reset UVC camera to starting position! Reason"));
- return 0;
- }
-
- MOTION_LOG(NTC, TYPE_TRACK, NO_ERRNO
- ,_("Reseting UVC camera to starting position"));
-
- SLEEP(8, 0);
-
- /* Get camera range */
- struct v4l2_queryctrl queryctrl;
- queryctrl.id = V4L2_CID_PAN_RELATIVE;
-
- if (ioctl(dev, VIDIOC_QUERYCTRL, &queryctrl) < 0) {
- MOTION_LOG(ERR, TYPE_TRACK, SHOW_ERRNO,_("ioctl querycontrol"));
- return 0;
- }
-
- MOTION_LOG(NTC, TYPE_TRACK, NO_ERRNO,_("Getting camera range"));
-
- /* DWe 30.03.07 The orig request failed :
- * must be VIDIOC_G_CTRL separate for pan and tilt or via VIDIOC_G_EXT_CTRLS - now for 1st manual
- * Range X = -70 to +70 degrees
- * Y = -30 to +30 degrees
- */
-
- //get mininum
- cam->track->minx = -4480 / INCPANTILT;
- cam->track->miny = -1920 / INCPANTILT;
- //get maximum
- cam->track->maxx = 4480 / INCPANTILT;
- cam->track->maxy = 1920 / INCPANTILT;
-
- cam->track->dev = dev;
- cam->track->pan_angle = 0;
- cam->track->tilt_angle = 0;
- cam->track->minmaxfound = 1;
-
- }
-
- struct v4l2_control control_s;
-
- MOTION_LOG(DBG, TYPE_TRACK, NO_ERRNO
- ,_("INPUT_PARAM_ABS pan_min %d,pan_max %d,tilt_min %d,tilt_max %d ")
- ,cam->track->minx, cam->track->maxx, cam->track->miny, cam->track->maxy);
- MOTION_LOG(DBG, TYPE_TRACK, NO_ERRNO
- ,_("INPUT_PARAM_ABS X_Angel %d, Y_Angel %d ")
- ,x_angle, y_angle);
-
- if (x_angle <= cam->track->maxx && x_angle >= cam->track->minx) {
- move_x_degrees = x_angle - (cam->track->pan_angle);
- }
-
- if (y_angle <= cam->track->maxy && y_angle >= cam->track->miny) {
- move_y_degrees = y_angle - (cam->track->tilt_angle);
- }
-
- /*
- * tilt up: - value
- * tilt down: + value
- * pan left: - value
- * pan right: + value
- */
- pan.s16.pan = -move_x_degrees * INCPANTILT;
- pan.s16.tilt = -move_y_degrees * INCPANTILT;
-
- MOTION_LOG(DBG, TYPE_TRACK, NO_ERRNO
- ,_("For_SET_ABS move_X %d,move_Y %d")
- ,move_x_degrees, move_y_degrees);
-
- /* DWe 30.03.07 Must be broken in diff calls, because
- * one call for both is not accept via VIDIOC_S_CTRL -> maybe via VIDIOC_S_EXT_CTRLS
- * The Webcam or uvcvideo does not like a call with a zero-move
- */
-
- if (move_x_degrees != 0) {
- control_s.id = V4L2_CID_PAN_RELATIVE;
- control_s.value = pan.s16.pan;
-
- if (ioctl(dev, VIDIOC_S_CTRL, &control_s) < 0) {
- MOTION_LOG(ERR, TYPE_TRACK, SHOW_ERRNO,_("Failed to move UVC camera!"));
- return 0;
- }
- }
-
- /* DWe 30.03.07 We must wait a little,before we set the next CMD, otherwise PAN is mad ... */
- if ((move_x_degrees != 0) && (move_y_degrees != 0)) {
- SLEEP(1, 0);
- }
-
- if (move_y_degrees != 0) {
- control_s.id = V4L2_CID_TILT_RELATIVE;
- control_s.value = pan.s16.tilt;
-
- if (ioctl(dev, VIDIOC_S_CTRL, &control_s) < 0) {
- MOTION_LOG(ERR, TYPE_TRACK, SHOW_ERRNO,_("Failed to move UVC camera!"));
- return 0;
- }
- }
-
- MOTION_LOG(NTC, TYPE_TRACK, NO_ERRNO
- ,_("Found MINMAX = %d"),cam->track->minmaxfound);
-
- if (cam->track->dev != -1) {
- MOTION_LOG(DBG, TYPE_TRACK, NO_ERRNO
- ,_("Before_ABS_Y_Angel : x= %d , Y= %d, ")
- ,cam->track->pan_angle, cam->track->tilt_angle);
-
- if (move_x_degrees != -1) {
- cam->track->pan_angle += move_x_degrees;
- }
-
- if (move_x_degrees != -1) {
- cam->track->tilt_angle += move_y_degrees;
- }
-
- MOTION_LOG(NTC, TYPE_TRACK, NO_ERRNO
- ,_("After_ABS_Y_Angel : x= %d , Y= %d")
- ,cam->track->pan_angle, cam->track->tilt_angle);
- }
-
- return cam->conf->track_move_wait;
- #else
- (void)cam;
- (void)dev;
- (void)x_angle;
- (void)y_angle;
- return 0;
- #endif
-
-}
-
-/**Move the uvc camera*/
-static int uvc_move(struct ctx_cam *cam, int dev, struct ctx_coord *cent
- , struct ctx_images *imgs, int manual)
-{
-
- #ifdef HAVE_V4L2
- /* RELATIVE MOVING : Act.Position +/- X and Y */
-
- int delta_x = cent->x - (imgs->width / 2);
- int delta_y = cent->y - (imgs->height / 2);
- int move_x_degrees, move_y_degrees;
-
- /*
- * DWe 30.03.07 Does the request of act.position from WebCam work ? luvcview shows at every position 180 :(
- * Now we init the Web by call Reset, so we can sure, that we are at x/y = 0,0
- * Don't worry, if the WebCam make a sound - over End at PAN - hmmm, should it be normal ...?
- * PAN Value 7777 in relative will init also a want reset for CAM - it will be "0" after that
- */
- if ((cam->track->minmaxfound != 1) || (cent->x == 7777)) {
- int reset = 3; //0-non reset, 1-reset pan, 2-reset tilt, 3-reset pan&tilt
- struct v4l2_control control_s;
-
- control_s.id = V4L2_CID_PAN_RESET;
- control_s.value = (unsigned char) reset;
-
- if (ioctl(dev, VIDIOC_S_CTRL, &control_s) < 0) {
- MOTION_LOG(ERR, TYPE_TRACK, SHOW_ERRNO
- ,_("Failed to reset UVC camera to starting position! Reason"));
- return 0;
- }
-
- control_s.id = V4L2_CID_TILT_RESET;
- control_s.value = (unsigned char) reset;
-
- if (ioctl(dev, VIDIOC_S_CTRL, &control_s) < 0) {
- MOTION_LOG(ERR, TYPE_TRACK, SHOW_ERRNO
- ,_("Failed to reset UVC camera to starting position! Reason"));
- return 0;
- }
-
- MOTION_LOG(NTC, TYPE_TRACK, NO_ERRNO
- ,_("Reseting UVC camera to starting position"));
-
- /* set the "helpvalue" back to null because after reset CAM should be in x=0 and not 70 */
- cent->x = 0;
- SLEEP(8, 0);
-
- /*
- * DWe 30.03.07 The orig request failed :
- * must be VIDIOC_G_CTRL separate for pan and tilt or via VIDIOC_G_EXT_CTRLS - now for 1st manual
- * Range X = -70 to +70 degrees
- * Y = -30 to +30 degrees
- */
-
- cam->track->minx = -4480 / INCPANTILT;
- cam->track->miny = -1920 / INCPANTILT;
- cam->track->maxx = 4480 / INCPANTILT;
- cam->track->maxy = 1920 / INCPANTILT;
- cam->track->dev = dev;
- cam->track->pan_angle = 0;
- cam->track->tilt_angle = 0;
- cam->track->minmaxfound = 1;
- }
-
-
- /* If we are on auto track we calculate delta, otherwise we use user input in degrees */
- if (!manual) {
- if (delta_x > imgs->width * 3/8 && delta_x < imgs->width * 5/8) {
- return 0;
- }
- if (delta_y > imgs->height * 3/8 && delta_y < imgs->height * 5/8) {
- return 0;
- }
-
- move_x_degrees = delta_x * cam->conf->track_step_angle_x / (imgs->width / 2);
- move_y_degrees = -delta_y * cam->conf->track_step_angle_y / (imgs->height / 2);
- } else {
- move_x_degrees = cent->x;
- move_y_degrees = cent->y;
- }
-
- union pantilt {
- struct {
- short pan;
- short tilt;
- } s16;
- int value;
- };
-
- struct v4l2_control control_s;
- union pantilt pan;
-
- if (cam->track->minmaxfound == 1) {
- /*
- * Check current position of camera and see if we need to adjust
- * values down to what is left to move
- */
- if (move_x_degrees < 0 && (cam->track->minx - cam->track->pan_angle) > move_x_degrees) {
- move_x_degrees = cam->track->minx - cam->track->pan_angle;
- }
-
- if (move_x_degrees > 0 && (cam->track->maxx - cam->track->pan_angle) < move_x_degrees) {
- move_x_degrees = cam->track->maxx - cam->track->pan_angle;
- }
-
- if (move_y_degrees < 0 && (cam->track->miny - cam->track->tilt_angle) > move_y_degrees) {
- move_y_degrees = cam->track->miny - cam->track->tilt_angle;
- }
-
- if (move_y_degrees > 0 && (cam->track->maxy - cam->track->tilt_angle) < move_y_degrees) {
- move_y_degrees = cam->track->maxy - cam->track->tilt_angle;
- }
- }
-
- MOTION_LOG(DBG, TYPE_TRACK, NO_ERRNO
- ,_("For_SET_REL pan_min %d,pan_max %d,tilt_min %d,tilt_max %d")
- ,cam->track->minx, cam->track->maxx, cam->track->miny, cam->track->maxy);
- MOTION_LOG(DBG, TYPE_TRACK, NO_ERRNO
- ,_("For_SET_REL track_pan_Angel %d, track_tilt_Angel %d")
- ,cam->track->pan_angle, cam->track->tilt_angle);
- MOTION_LOG(DBG, TYPE_TRACK, NO_ERRNO
- ,_("For_SET_REL move_X %d,move_Y %d"), move_x_degrees, move_y_degrees);
-
- /*
- * tilt up: - value
- * tilt down: + value
- * pan left: - value
- * pan right: + value
- */
-
- pan.s16.pan = -move_x_degrees * INCPANTILT;
- pan.s16.tilt = -move_y_degrees * INCPANTILT;
-
- /* DWe 30.03.07 Must be broken in diff calls, because
- * one call for both is not accept via VIDIOC_S_CTRL -> maybe via VIDIOC_S_EXT_CTRLS
- * The Webcam or uvcvideo does not like a call with a zero-move
- */
-
- if (move_x_degrees != 0) {
-
- control_s.id = V4L2_CID_PAN_RELATIVE;
-
- control_s.value = pan.s16.pan;
- MOTION_LOG(DBG, TYPE_TRACK, NO_ERRNO
- ,_(" dev %d, addr= %d, control_S= %d, Wert= %d")
- ,dev, VIDIOC_S_CTRL, &control_s, pan.s16.pan);
-
- if (ioctl(dev, VIDIOC_S_CTRL, &control_s) < 0) {
- MOTION_LOG(ERR, TYPE_TRACK, SHOW_ERRNO
- ,_("Failed to move UVC camera!"));
- return 0;
- }
- }
-
- /* DWe 30.03.07 We must wait a little,before we set the next CMD, otherwise PAN is mad ... */
- if ((move_x_degrees != 0) && (move_y_degrees != 0)) {
- SLEEP (1, 0);
- }
-
- if (move_y_degrees != 0) {
-
- control_s.id = V4L2_CID_TILT_RELATIVE;
-
- control_s.value = pan.s16.tilt;
- MOTION_LOG(DBG, TYPE_TRACK, NO_ERRNO
- ,_(" dev %d,addr= %d, control_S= %d, Wert= %d")
- ,dev, VIDIOC_S_CTRL, &control_s, pan.s16.tilt);
-
- if (ioctl(dev, VIDIOC_S_CTRL, &control_s) < 0) {
- MOTION_LOG(ERR, TYPE_TRACK, SHOW_ERRNO
- ,_("Failed to move UVC camera!"));
- return 0;
- }
- }
-
- MOTION_LOG(DBG, TYPE_TRACK, NO_ERRNO
- ,_("Found MINMAX = %d"), cam->track->minmaxfound);
-
- if (cam->track->minmaxfound == 1) {
- MOTION_LOG(DBG, TYPE_TRACK, NO_ERRNO
- ,_("Before_REL_Y_Angel : x= %d , Y= %d")
- ,cam->track->pan_angle, cam->track->tilt_angle);
-
- if (move_x_degrees != 0) {
- cam->track->pan_angle += -pan.s16.pan / INCPANTILT;
- }
-
- if (move_y_degrees != 0) {
- cam->track->tilt_angle += -pan.s16.tilt / INCPANTILT;
- }
-
- MOTION_LOG(DBG, TYPE_TRACK, NO_ERRNO
- ,_("After_REL_Y_Angel : x= %d , Y= %d")
- ,cam->track->pan_angle, cam->track->tilt_angle);
- }
-
- return cam->conf->track_move_wait;
- #else
- (void)cam;
- (void)dev;
- (void)cent;
- (void)imgs;
- (void)manual;
- return 0;
- #endif /* HAVE_V4L2 */
-}
-
-/**Move the generic camera*/
-static int generic_move(struct ctx_cam *cam, struct ctx_coord *cent)
-{
-
- cam->track->posx += cent->x;
- cam->track->posy += cent->y;
-
- util_exec_command(cam, cam->conf->track_generic_move.c_str(), NULL, 0);
-
- return cam->conf->track_move_wait;
-}
-
-/* Initialize the tracking functionality */
-void track_init(struct ctx_cam *cam)
-{
-
- cam->track = new ctx_track;
- memset(cam->track,0,sizeof(ctx_track));
-
- cam->track->dev = -1; /* dev open */
-
- if (cam->conf->track_type) {
- cam->frame_skip = track_center(cam, cam->video_dev, 0, 0, 0);
- }
-
-}
-
-/* Clean up the tracking functionality */
-void track_deinit(struct ctx_cam *cam)
-{
-
- delete cam->track;
-
-}
-
-/* Center the camera */
-int track_center(struct ctx_cam *cam, int dev, int manual, int xoff, int yoff)
-{
- struct ctx_coord cent;
- (void)dev;
-
- if (!manual && !cam->conf->track_auto) {
- return 0;
- }
-
- if (cam->conf->track_type == TRACK_TYPE_UVC) {
- return uvc_center(cam, dev, xoff, yoff);
- } else if (cam->conf->track_type == TRACK_TYPE_GENERIC) {
- if (cam->conf->track_generic_move != "") {
- cent.x = -cam->track->posx;
- cent.y = -cam->track->posy;
- return generic_move(cam, ¢);
- } else {
- return 10;
- }
- }
-
- MOTION_LOG(ERR, TYPE_TRACK, SHOW_ERRNO
- ,_("internal error, %hu is not a known track-type"), cam->conf->track_type);
-
- return 0;
-}
-
-int track_move(struct ctx_cam *cam, int dev, struct ctx_coord *cent
- , struct ctx_images *imgs, int manual)
-{
-
- if (!manual && !cam->conf->track_auto) {
- return 0;
- }
-
- if (cam->conf->track_type == TRACK_TYPE_UVC) {
- return uvc_move(cam, dev, cent, imgs, manual);
- } else if (cam->conf->track_type == TRACK_TYPE_GENERIC) {
- if (cam->conf->track_generic_move != "") {
- return generic_move(cam, cent);
- } else {
- return cam->conf->track_move_wait;
- }
- }
-
- MOTION_LOG(WRN, TYPE_TRACK, SHOW_ERRNO
- ,_("internal error, %hu is not a known track-type")
- , cam->conf->track_type);
-
- return 0;
-}
-
diff --git a/src/track.hpp b/src/track.hpp
deleted file mode 100644
index 95fcc426..00000000
--- a/src/track.hpp
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * This file is part of MotionPlus.
- *
- * MotionPlus is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * MotionPlus is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with MotionPlus. If not, see .
- *
- * Copyright 2020 MotionMrDave@gmail.com
- *
-*/
-
-#ifndef _INCLUDE_TRACK_H
-#define _INCLUDE_TRACK_H
-
-struct ctx_coord;
-
-struct ctx_track {
- int dev;
- int maxx;
- int minx;
- int maxy;
- int miny;
-
- int pan_angle; // degrees
- int tilt_angle; // degrees
- int posx;
- int posy;
- int minmaxfound;
-};
-
-
-enum track_action { TRACK_CENTER, TRACK_MOVE };
-
-void track_init(struct ctx_cam *cam);
-void track_deinit(struct ctx_cam *cam);
-
-int track_center(struct ctx_cam *cam, int dev,
- int manual, int xoff, int yoff);
-
-int track_move(struct ctx_cam *cam, int dev,struct ctx_coord *cent
- , struct ctx_images *imgs, int manual);
-
-#endif /* _INCLUDE_TRACK_H */
diff --git a/src/webu.cpp b/src/webu.cpp
index c323179b..67a673c0 100644
--- a/src/webu.cpp
+++ b/src/webu.cpp
@@ -30,7 +30,6 @@
#include "webu_stream.hpp"
#include "webu_json.hpp"
#include "webu_post.hpp"
-#include "track.hpp"
#include "video_v4l2.hpp"