CHDK_DE Vorschauversion  Trunk Rev. 5163
 Alle Datenstrukturen Dateien Funktionen Variablen Typdefinitionen Aufzählungen Aufzählungswerte Makrodefinitionen
motion_detector.c-Dateireferenz
#include "camera_info.h"
#include "action_stack.h"
#include "console.h"
#include "keyboard.h"
#include "clock.h"
#include "viewport.h"
#include "debug_led.h"
#include "gui.h"
#include "gui_draw.h"
#include "script_api.h"
#include "script.h"
#include "motion_detector.h"
#include "module_def.h"
#include "gui_lang.h"
+ Include-Abhängigkeitsdiagramm für motion_detector.c:

gehe zum Quellcode dieser Datei

Datenstrukturen

struct  motion_detector_s
 

Makrodefinitionen

#define MD_XY2IDX(x, y)   ((y)*motion_detector.columns+(x))
 
#define MOTION_DETECTOR_CELLS   1024
 
#define md_save_calls_history()
 
#define mx_dump_memory(x)
 

Aufzählungen

enum  {
  MD_MEASURE_MODE_U =0, MD_MEASURE_MODE_Y =1, MD_MEASURE_MODE_V =2, MD_MEASURE_MODE_R =3,
  MD_MEASURE_MODE_G =4, MD_MEASURE_MODE_B =5
}
 
enum  { MD_DO_IMMEDIATE_SHOOT =1, MD_MAKE_DEBUG_LOG_FILE =2, MD_MAKE_RAM_DUMP_FILE =4, MD_NO_SHUTTER_RELEASE_ON_SHOOT =8 }
 
enum  { MD_REGION_NONE =0, MD_REGION_INCLUDE =1, MD_REGION_EXCLUDE =2 }
 

Funktionen

static int md_detect_motion (void)
 
static void time_counter_capture (time_counter *t)
 
static int action_stack_AS_MOTION_DETECTOR ()
 
static void md_kbd_sched_immediate_shoot (int no_release)
 
static int clip (int v)
 
void md_close_motion_detector ()
 
int md_init_motion_detector (int columns, int rows, int pixel_measure_mode, int detection_timeout, int measure_interval, int threshold, int draw_grid, int clipping_region_mode, int clipping_region_column1, int clipping_region_row1, int clipping_region_column2, int clipping_region_row2, int parameters, int pixels_step, int msecs_before_trigger)
 
static int md_running ()
 
int md_get_cell_val (int column, int row)
 
int md_get_cell_diff (int column, int row)
 
void md_draw_grid ()
 
int _module_unloader ()
 
int _module_can_unload ()
 

Variablen

int xs =6
 
int np =4
 
static struct motion_detector_s motion_detector
 
libmotiondetect_sym _libmotiondetect
 
ModuleInfo _module_info
 

Makro-Dokumentation

#define md_save_calls_history ( )

Definiert in Zeile 427 der Datei motion_detector.c.

#define MD_XY2IDX (   x,
  y 
)    ((y)*motion_detector.columns+(x))

Definiert in Zeile 57 der Datei motion_detector.c.

#define MOTION_DETECTOR_CELLS   1024

Definiert in Zeile 85 der Datei motion_detector.c.

#define mx_dump_memory (   x)

Definiert in Zeile 428 der Datei motion_detector.c.

Dokumentation der Aufzählungstypen

anonymous enum
Aufzählungswerte
MD_MEASURE_MODE_U 
MD_MEASURE_MODE_Y 
MD_MEASURE_MODE_V 
MD_MEASURE_MODE_R 
MD_MEASURE_MODE_G 
MD_MEASURE_MODE_B 

Definiert in Zeile 59 der Datei motion_detector.c.

anonymous enum
Aufzählungswerte
MD_DO_IMMEDIATE_SHOOT 
MD_MAKE_DEBUG_LOG_FILE 
MD_MAKE_RAM_DUMP_FILE 
MD_NO_SHUTTER_RELEASE_ON_SHOOT 

Definiert in Zeile 70 der Datei motion_detector.c.

anonymous enum
Aufzählungswerte
MD_REGION_NONE 
MD_REGION_INCLUDE 
MD_REGION_EXCLUDE 

Definiert in Zeile 78 der Datei motion_detector.c.

79 {
83 };

Dokumentation der Funktionen

int _module_can_unload ( )

Definiert in Zeile 950 der Datei motion_detector.c.

int _module_unloader ( )

Definiert in Zeile 944 der Datei motion_detector.c.

945 {
947  return 0;
948 }
static int action_stack_AS_MOTION_DETECTOR ( )
static

Definiert in Zeile 142 der Datei motion_detector.c.

143 {
144  // MD testing with AF LED
146  {
147  if (camera_info.perf.af_led_on == 0)
148  {
152  }
153  else if (camera_info.perf.af_led_on > 0)
154  {
156  }
157  }
158 
159  if (md_detect_motion() == 0)
160  {
162  {
164  }
165 
166  // MD testing with AF LED
168  {
171  {
173  }
174  }
175 
176  // We need to recover the motion detector's
177  // result and push it onto the thread's stack.
179 
180  action_pop_func(0);
181  return 1;
182  }
183  return 0;
184 }
static int clip ( int  v)
static

Definiert in Zeile 207 der Datei motion_detector.c.

208 {
209  if (v<0) v=0;
210  else if (v>255) v=255;
211  return v;
212 }
void md_close_motion_detector ( )

Definiert in Zeile 215 der Datei motion_detector.c.

216 {
217 }
static int md_detect_motion ( void  )
static
void md_draw_grid ( )

Definiert in Zeile 860 der Datei motion_detector.c.

861 {
862  int col, row;
863  int i;
864  char mdbuff[8];
865 
867  {
868  return;
869  }
870 
871  int xoffset = vid_get_viewport_display_xoffset(); // used when image size != viewport size
872  int yoffset = vid_get_viewport_display_yoffset(); // used when image size != viewport size
873 
874  // display area size
875  int x_size = camera_screen.width-xoffset * 2;
876  int y_size = camera_screen.height-yoffset * 2;
877 
878  // initial display offsets
879  int y_start, y_end = yoffset;
880  int x_start, x_end;
881 
882  for (i=0, row=0; row < motion_detector.rows && camera_info.state.state_kbd_script_run; row++)
883  {
884  // Calc display start and end offsets
885  y_start = y_end; // reuse last end value as new start value
886  y_end = yoffset + ((row + 1) * y_size) / motion_detector.rows;
887 
888  x_end = xoffset;
889 
890  for (col=0; col < motion_detector.columns; col++, i++)
891  {
892  // Calc display x start and end offsets
893  x_start = x_end; // reuse last end value as new start value
894  x_end = xoffset + ((col + 1) * x_size) / motion_detector.columns;
895 
896  int in_clipping_region = 0;
901  )
902  {
903  in_clipping_region = 1;
904  }
905 
906  if ((motion_detector.clipping_region_mode==MD_REGION_EXCLUDE && in_clipping_region==0) ||
907  (motion_detector.clipping_region_mode==MD_REGION_INCLUDE && in_clipping_region==1) ||
909  {
910  int diff = motion_detector.diff[i];
911 
913  if (diff > motion_detector.threshold)
914  {
916  }
917 
918  if (motion_detector.draw_grid & 2)
919  {
920  sprintf(mdbuff,"%-3d", diff);
921  draw_string(x_start+4, y_start+2, mdbuff, c);
922  }
923 
924  if (motion_detector.draw_grid & 1)
925  {
926  draw_rectangle(x_start+2, y_start+2, x_end-2, y_end-2, c, RECT_BORDER1);
927  }
928  }
929  }
930  }
931 }
int md_get_cell_diff ( int  column,
int  row 
)

Definiert in Zeile 849 der Datei motion_detector.c.

850 {
851  if ((column<1 || column > motion_detector.columns) ||
852  (row<1 || row > motion_detector.rows))
853  {
854  return 0;
855  }
856 
857  return motion_detector.diff[ MD_XY2IDX(column-1,row-1) ];
858 }
int md_get_cell_val ( int  column,
int  row 
)

Definiert in Zeile 838 der Datei motion_detector.c.

839 {
840  if ((column<1 || column > motion_detector.columns) ||
841  (row<1 || row > motion_detector.rows))
842  {
843  return 0;
844  }
845 
846  return motion_detector.prev[ MD_XY2IDX(column-1,row-1) ]/motion_detector.points ;
847 }
int md_init_motion_detector ( int  columns,
int  rows,
int  pixel_measure_mode,
int  detection_timeout,
int  measure_interval,
int  threshold,
int  draw_grid,
int  clipping_region_mode,
int  clipping_region_column1,
int  clipping_region_row1,
int  clipping_region_column2,
int  clipping_region_row2,
int  parameters,
int  pixels_step,
int  msecs_before_trigger 
)

Definiert in Zeile 220 der Datei motion_detector.c.

237 {
238 #ifdef OPT_MD_DEBUG
239  motion_detector.comp_calls_cnt=0;
240 #endif
241 
242  if( pixel_measure_mode != MD_MEASURE_MODE_Y
243  && pixel_measure_mode != MD_MEASURE_MODE_U
244  && pixel_measure_mode != MD_MEASURE_MODE_V
245  && pixel_measure_mode != MD_MEASURE_MODE_R
246  && pixel_measure_mode != MD_MEASURE_MODE_G
247  && pixel_measure_mode != MD_MEASURE_MODE_B
248  )
249  {
250  pixel_measure_mode = MD_MEASURE_MODE_Y;
251  }
252 
253  // Sanity check on grid size
254  if (columns < 1) columns = 3;
255  if (rows < 1) rows = 3;
256  // If too many grid cells, reduce larger of columns and rows until it fits
257  while ((columns * rows) > MOTION_DETECTOR_CELLS)
258  {
259  if (columns > rows) columns--;
260  else rows--;
261  }
262 
263  if(msecs_before_trigger<0)
264  {
265  msecs_before_trigger=0;
266  }
267 
268  if (pixels_step<1)
269  {
270  pixels_step=1;
271  }
272 
273  if(detection_timeout<0)
274  {
275  detection_timeout=0;
276  }
277 
278  if(measure_interval<0)
279  {
280  measure_interval=0;
281  }
282 
283  if(threshold<0)
284  {
285  threshold=0;
286  }
287 
288  motion_detector.msecs_before_trigger = msecs_before_trigger;
289  motion_detector.parameters = parameters;
290  motion_detector.pixels_step = pixels_step;
291  motion_detector.columns = columns;
292  motion_detector.rows = rows;
294 
295  motion_detector.pixel_measure_mode = pixel_measure_mode;
296  motion_detector.timeout = detection_timeout;
297  motion_detector.measure_interval = measure_interval;
298  motion_detector.threshold = threshold;
299  motion_detector.draw_grid = draw_grid;
300 
301  if (clipping_region_column1>clipping_region_column2)
302  {
303  motion_detector.clipping_region_column2 = clipping_region_column1;
304  motion_detector.clipping_region_column1 = clipping_region_column2;
305  }
306  else
307  {
308  motion_detector.clipping_region_column2 = clipping_region_column2;
309  motion_detector.clipping_region_column1 = clipping_region_column1;
310  }
311 
312  if (clipping_region_row1>clipping_region_row2)
313  {
314  motion_detector.clipping_region_row2 = clipping_region_row1;
315  motion_detector.clipping_region_row1 = clipping_region_row2;
316  }
317  else
318  {
319  motion_detector.clipping_region_row2 = clipping_region_row2;
320  motion_detector.clipping_region_row1 = clipping_region_row1;
321  }
322 
323  if (clipping_region_mode!=MD_REGION_NONE && clipping_region_mode!=MD_REGION_INCLUDE && clipping_region_mode!=MD_REGION_EXCLUDE)
324  {
325  clipping_region_mode=MD_REGION_NONE;
326  }
327  motion_detector.clipping_region_mode = clipping_region_mode;
328 
332 
334 
336 
337  camera_info.perf.af_led_on = 100;
340 
341  return 1;
342 }
static void md_kbd_sched_immediate_shoot ( int  no_release)
static

Definiert in Zeile 186 der Datei motion_detector.c.

187 {
188  action_pop_func(0);// REMOVE MD ITEM
189 
190  // stack operations are reversed!
191  if (!no_release) // only release shutter if allowed
192  {
194  }
197  action_push_func(action_stack_AS_MOTION_DETECTOR); // it will removed right after exit from this function
198  kbd_key_press(KEY_SHOOT_FULL); // not a stack operation... pressing right now
199 
200  // MD testing with AF LED
202  {
204  }
205 }
static int md_running ( )
static

Definiert in Zeile 432 der Datei motion_detector.c.

433 {
434  return motion_detector.running;
435 }
static void time_counter_capture ( time_counter t)
static

Definiert in Zeile 130 der Datei motion_detector.c.

131 {
132  t->last = get_tick_count() - t->tick_count;
133  if (t->last < t->min)
134  t->min = t->last;
135  if (t->last > t->max)
136  t->max = t->last;
137  t->sum += t->last;
138  t->count++;
139 }

Variablen-Dokumentation

struct motion_detector_s motion_detector
static

Definiert in Zeile 128 der Datei motion_detector.c.

int np =4

Definiert in Zeile 49 der Datei motion_detector.c.

int xs =6

Definiert in Zeile 48 der Datei motion_detector.c.