1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171
|
/*
* Copyright 1994-2012 Olivier Girondel
*
* This file is part of lebiniou.
*
* lebiniou 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 2 of the License, or
* (at your option) any later version.
*
* lebiniou 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 lebiniou. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* EffecTV - Realtime Digital Video Effector
* Copyright (C) 2001-2006 FUKUCHI Kentaro
*
* PredatorTV - makes incoming objects invisible like the Predator.
* Copyright (C) 2001-2002 FUKUCHI Kentaro
*
*/
#include "context.h"
u_long id = 1325445400;
u_long options = BE_GFX|BEQ_PICTURE|BEQ_BYPASS;
char desc[] = "PredatorTV plugin from the EffecTV project";
u_long mode = OVERLAY;
#define MAGIC_THRESHOLD 40
static Buffer8_t *diff = NULL;
extern int webcams;
void
create(__attribute__ ((unused)) Context_t *ctx)
{
if (!webcams)
options |= BEQ_DISABLED;
else
diff = Buffer8_new();
}
void
delete(__attribute__ ((unused)) Context_t *ctx)
{
Buffer8_delete(diff);
}
void
on_switch_on(Context_t *ctx)
{
ctx->ref_taken[ctx->cam] = 0;
}
#if 0
static unsigned char *
image_diff_filter(unsigned char *diff)
{
#if 0
/* noise filter for subtracted image. */
unsigned char *image_diff_filter(unsigned char *diff)
{
int x, y;
unsigned char *src, *dest;
unsigned int count;
unsigned int sum1, sum2, sum3;
const int width = video_width;
src = diff;
dest = diff2 + width +1;
for(y=1; y<video_height-1; y++) {
sum1 = src[0] + src[width] + src[width*2];
sum2 = src[1] + src[width+1] + src[width*2+1];
src += 2;
for(x=1; x<width-1; x++) {
sum3 = src[0] + src[width] + src[width*2];
count = sum1 + sum2 + sum3;
sum1 = sum2;
sum2 = sum3;
*dest++ = (0xff*3 - count)>>24;
src++;
}
dest += 2;
}
return diff2;
}
#endif
}
#endif
void
run(Context_t *ctx)
{
Buffer8_t *src1;
Buffer8_t *src2;
Pixel_t *d, *src;
Pixel_t *dst;
uint16_t x, y;
if (!webcams)
return;
pthread_mutex_lock(&ctx->cam_mtx[ctx->cam]);
src1 = ctx->cam_save[ctx->cam][0];
src2 = ctx->cam_ref[ctx->cam];
Buffer8_substract_y(src1, src2, MAGIC_THRESHOLD, diff);
d = diff->buffer;
dst = passive_buffer(ctx)->buffer;
dst += WIDTH * sizeof(Pixel_t);
d += WIDTH * sizeof(Pixel_t);
src = ctx->cam_ref[ctx->cam]->buffer + (WIDTH * sizeof(Pixel_t));
for (y = 1; y < MAXY; y++) {
for (x = 0; x < WIDTH; x++) {
if (*d)
*dst = src[4] & 0xfc;
else
*dst = *src;
d++;
src++;
dst++;
}
}
pthread_mutex_unlock(&ctx->cam_mtx[ctx->cam]);
}
#if 0
static int draw(RGB32 *src, RGB32 *dest)
{
int x, y;
unsigned char *diff;
diff = image_bgsubtract_y(src);
diff = image_diff_filter(diff);
dest += video_width;
diff += video_width;
src = bgimage + video_width;
for(y=1; y<video_height-1; y++) {
for(x=0; x<video_width; x++) {
if(*diff){
*dest = src[4] & 0xfcfcfc;
} else {
*dest = *src;
}
diff++;
src++;
dest++;
}
}
return 0;
}
#endif /* 0 */
|