3535#define SMARTMASK_SENSITIVITY_INCR 5
3636
3737typedef struct {
38- short y, xl, xr, dy;
38+ int y, xl, xr, dy;
3939} Segment;
4040
4141
@@ -519,7 +519,7 @@ static void alg_despeckle(ctx_dev *cam)
519519 width = cam->imgs .width ;
520520 height = cam->imgs .height ;
521521 done = 0 ;
522- len = cam->conf ->despeckle_filter .length ();
522+ len = ( int ) cam->conf ->despeckle_filter .length ();
523523 common_buffer = cam->imgs .common_buffer ;
524524 cam->current_image ->total_labels = 0 ;
525525 cam->imgs .largest_label = 0 ;
@@ -573,7 +573,8 @@ static void alg_despeckle(ctx_dev *cam)
573573
574574void alg_tune_smartmask (ctx_dev *cam)
575575{
576- int i, diff;
576+ int i;
577+ unsigned char diff;
577578 int motionsize = cam->imgs .motionsize ;
578579 unsigned char *smartmask = cam->imgs .smartmask ;
579580 unsigned char *smartmask_final = cam->imgs .smartmask_final ;
@@ -592,7 +593,7 @@ void alg_tune_smartmask(ctx_dev *cam)
592593 smartmask[i]--;
593594 }
594595 /* Increase smart_mask sensitivity based on the buffered values. */
595- diff = smartmask_buffer[i] / sensitivity;
596+ diff = ( unsigned char )( smartmask_buffer[i] / sensitivity) ;
596597
597598 if (diff) {
598599 if (smartmask[i] <= diff + 80 ) {
@@ -610,9 +611,9 @@ void alg_tune_smartmask(ctx_dev *cam)
610611 }
611612 }
612613 /* Further expansion (here:erode due to inverted logic!) of the mask. */
613- diff = alg_erode9 (smartmask_final, cam->imgs .width , cam->imgs .height ,
614+ alg_erode9 (smartmask_final, cam->imgs .width , cam->imgs .height ,
614615 cam->imgs .common_buffer , 255 );
615- diff = alg_erode5 (smartmask_final, cam->imgs .width , cam->imgs .height ,
616+ alg_erode5 (smartmask_final, cam->imgs .width , cam->imgs .height ,
616617 cam->imgs .common_buffer , 255 );
617618 cam->smartmask_count = cam->smartmask_ratio ;
618619}
@@ -944,7 +945,7 @@ void alg_update_reference_frame(ctx_dev *cam, int action)
944945 (*ref_dyn)++; /* Motionpixel? Keep excluding from ref frame. */
945946 } else {
946947 *ref_dyn = 0 ; /* Nothing special - release pixel. */
947- *ref = (*ref + *image_virgin) / 2 ;
948+ *ref = (unsigned char )(( *ref + *image_virgin) / 2 ) ;
948949 }
949950
950951 } else { /* No motion: copy to ref frame. */
@@ -1048,7 +1049,7 @@ static void alg_location_dist(ctx_dev *cam)
10481049 if (*(out++)) {
10491050 variance_x += ((x - cent->x ) * (x - cent->x ));
10501051 variance_y += ((y - cent->y ) * (y - cent->y ));
1051- distance_mean += sqrt (
1052+ distance_mean += ( uint64_t ) sqrt (
10521053 ((x - cent->x ) * (x - cent->x )) +
10531054 ((y - cent->y ) * (y - cent->y )));
10541055
@@ -1074,9 +1075,9 @@ static void alg_location_dist(ctx_dev *cam)
10741075 cent->maxx = cent->x + xdist / centc * 3 ;
10751076 cent->miny = cent->y - ydist / centc * 3 ;
10761077 cent->maxy = cent->y + ydist / centc * 3 ;
1077- cent->stddev_x = sqrt ((variance_x / centc));
1078- cent->stddev_y = sqrt ((variance_y / centc));
1079- distance_mean = (distance_mean / centc);
1078+ cent->stddev_x = ( int ) sqrt ((variance_x / centc));
1079+ cent->stddev_y = ( int ) sqrt ((variance_y / centc));
1080+ distance_mean = (uint64_t )( distance_mean / centc);
10801081 } else {
10811082 cent->stddev_y = 0 ;
10821083 cent->stddev_x = 0 ;
@@ -1089,16 +1090,16 @@ static void alg_location_dist(ctx_dev *cam)
10891090 for (x = 0 ; x < width; x++) {
10901091 if (*(out++)) {
10911092 variance_xy += (
1092- (sqrt (((x - cent->x ) * (x - cent->x )) +
1093+ (( uint64_t ) sqrt (((x - cent->x ) * (x - cent->x )) +
10931094 ((y - cent->y ) * (y - cent->y ))) - distance_mean) *
1094- (sqrt (((x - cent->x ) * (x - cent->x )) +
1095+ (( uint64_t ) sqrt (((x - cent->x ) * (x - cent->x )) +
10951096 ((y - cent->y ) * (y - cent->y ))) - distance_mean));
10961097 }
10971098 }
10981099 }
10991100 /* Per statistics, divide by n-1 for calc of a standard deviation */
11001101 if ((centc-1 ) > 0 ) {
1101- cent->stddev_xy = sqrt ((variance_xy / (centc-1 )));
1102+ cent->stddev_xy = ( int ) sqrt ((variance_xy / (centc-1 )));
11021103 }
11031104}
11041105
0 commit comments