Skip to content

User Provided Color Specifier #1178

@Mr-DaveDev

Description

@Mr-DaveDev
  1. Reviewed guide and contributing documents? (Yes/No): Yes
  2. version [x.y.z, hash, other]: 4.3.1
  3. installed as a package or compiled from sources [deb, rpm, git, other]: Compiled
  4. standalone or part of third party [motion, MotionEyeOS, other]: Standalone
  5. video stream source [V4L (card or USB), net cam (mjpeg, rtsp, other), mmal]: RTSP
  6. hardware [x86, ARM, other]: x86
  7. operating system [16.04, Stretch, etc, FreeBSD, other]: 18.04

Eliminate the Red / non red boxes and crosses and instead have a parameter that allows the user to specify the desired Y/U/V parameters that they desire. This would allow for black, white, red, blue, yellow and any color between.

The following snippet illustrates a patch to do this via hard coded values and have the red box be blue.

index 20c83c5..e311e69 100644
--- a/src/alg.c
+++ b/src/alg.c
@@ -243,6 +243,23 @@ void alg_draw_red_location(struct coord *cent, struct images *imgs, int width, u
     unsigned char *out = imgs->img_motion.image_norm;
     unsigned char *new_u, *new_v;
     int x, y, v, cwidth, cblock;
+    int clr_y, clr_u, clr_v;
+
+    /* Red */
+    clr_y = 128;
+    clr_u = 128;
+    clr_v = 255;
+
+    /* Blue */
+    clr_y = 0;
+    clr_u = 240;
+    clr_v = 110;
+
+    /* Yellow */
+    //clr_y = 210;
+    //clr_u = 16;
+    //clr_v = 146;
+
 
     cwidth = width / 2;
     cblock = imgs->motionsize / 4;
@@ -286,22 +303,22 @@ void alg_draw_red_location(struct coord *cent, struct images *imgs, int width, u
             int cwidth_miny_x = x / 2 + cwidth_miny;
             int cwidth_maxy_x = x / 2 + cwidth_maxy;
 
-            new_u[cwidth_miny_x] = 128;
-            new_u[cwidth_maxy_x] = 128;
-            new_v[cwidth_miny_x] = 255;
-            new_v[cwidth_maxy_x] = 255;
+            new_u[cwidth_miny_x] = clr_u;
+            new_u[cwidth_maxy_x] = clr_u;
+            new_v[cwidth_miny_x] = clr_v;
+            new_v[cwidth_maxy_x] = clr_v;
 
-            new[width_miny_x] = 128;
-            new[width_maxy_x] = 128;
+            new[width_miny_x] = clr_y;
+            new[width_maxy_x] = clr_y;
 
-            new[width_miny_x + 1] = 128;
-            new[width_maxy_x + 1] = 128;
+            new[width_miny_x + 1] = clr_y;
+            new[width_maxy_x + 1] = clr_y;
 
-            new[width_miny_x + width] = 128;
-            new[width_maxy_x + width] = 128;
+            new[width_miny_x + width] = clr_y;
+            new[width_maxy_x + width] = clr_y;
 
-            new[width_miny_x + 1 + width] = 128;
-            new[width_maxy_x + 1 + width] = 128;
+            new[width_miny_x + 1 + width] = clr_y;
+            new[width_maxy_x + 1 + width] = clr_y;
         }
 
         for (y = cent->miny; y <= cent->maxy; y += 2) {
@@ -310,22 +327,22 @@ void alg_draw_red_location(struct coord *cent, struct images *imgs, int width, u
             int cwidth_minx_y = (cent->minx / 2) + (y / 2) * cwidth;
             int cwidth_maxx_y = (cent->maxx / 2) + (y / 2) * cwidth;
 
-            new_u[cwidth_minx_y] = 128;
-            new_u[cwidth_maxx_y] = 128;
-            new_v[cwidth_minx_y] = 255;
-            new_v[cwidth_maxx_y] = 255;
+            new_u[cwidth_minx_y] = clr_u;
+            new_u[cwidth_maxx_y] = clr_u;
+            new_v[cwidth_minx_y] = clr_v;
+            new_v[cwidth_maxx_y] = clr_v;
 
-            new[width_minx_y] = 128;
-            new[width_maxx_y] = 128;
+            new[width_minx_y] = clr_y;
+            new[width_maxx_y] = clr_y;
 
-            new[width_minx_y + width] = 128;
-            new[width_maxx_y + width] = 128;
+            new[width_minx_y + width] = clr_y;
+            new[width_maxx_y + width] = clr_y;
 
-            new[width_minx_y + 1] = 128;
-            new[width_maxx_y + 1] = 128;
+            new[width_minx_y + 1] = clr_y;
+            new[width_maxx_y + 1] = clr_y;
 
-            new[width_minx_y + width + 1] = 128;
-            new[width_maxx_y + width + 1] = 128;
+            new[width_minx_y + width + 1] = clr_y;
+            new[width_maxx_y + width + 1] = clr_y;
         }
     } else if (style == LOCATE_REDCROSS) { /* Draw a red cross on normal images. */
         int cwidth_maxy = cwidth * (cent->y / 2);
@@ -333,15 +350,15 @@ void alg_draw_red_location(struct coord *cent, struct images *imgs, int width, u
         for (x = cent->x - 10; x <= cent->x + 10; x += 2) {
             int cwidth_maxy_x = x / 2 + cwidth_maxy;
 
-            new_u[cwidth_maxy_x] = 128;
-            new_v[cwidth_maxy_x] = 255;
+            new_u[cwidth_maxy_x] = clr_u;
+            new_v[cwidth_maxy_x] = clr_v;
         }
 
         for (y = cent->y - 10; y <= cent->y + 10; y += 2) {
             int cwidth_minx_y = (cent->x / 2) + (y / 2) * cwidth;
 
-            new_u[cwidth_minx_y] = 128;
-            new_v[cwidth_minx_y] = 255;
+            new_u[cwidth_minx_y] = clr_u;
+            new_v[cwidth_minx_y] = clr_v;
         }
     }
 }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions