CHDK_DE Vorschauversion  Trunk Rev. 5214
 Alle Datenstrukturen Dateien Funktionen Variablen Typdefinitionen Aufzählungen Aufzählungswerte Makrodefinitionen
camera_functions.h-Dateireferenz

gehe zum Quellcode dieser Datei

Funktionen

int script_key_is_clicked (int keyid)
 
int script_key_is_pressed (int keyid)
 
int camera_is_pressed (int i)
 
int camera_is_clicked (int i)
 
void camera_sleep (long v)
 
void camera_shoot ()
 
int md_detect_motion (void)
 
int md_get_cell_diff (int column, int row)
 
int md_get_cell_val (int column, int row)
 
int md_init_motion_detector ()
 
void camera_set_raw (int mode)
 
void ubasic_camera_get_raw ()
 
void camera_set_nr (int to)
 
int camera_get_nr ()
 
void shooting_set_prop (int id, int v)
 
int shooting_get_prop (int id)
 
long stat_get_vbatt ()
 
void camera_set_led (int led, int state, int bright)
 
int ubasic_camera_script_autostart ()
 
int get_usb_power (int edge)
 
void camera_set_script_autostart (int state)
 
void exit_alt ()
 

Dokumentation der Funktionen

int camera_get_nr ( )
int camera_is_clicked ( int  i)
int camera_is_pressed ( int  i)
void camera_set_led ( int  led,
int  state,
int  bright 
)

Definiert in Zeile 44 der Datei lib.c.

44  {
45  struct led_control led_c;
46  char convert_table[11]={0,1,2,3,0,2,3,1,8,10,10}; // s3 to a710 (and a720) convert table
47 
48  //char convert_table[6]={0,1,2,3,8,10}; // Test a720, values 0-5 are valid
49 
50  // 0 gr
51  // 1 red
52  // 2 yel
53  // 3 pw
54  // 8 dp
55  // 9 af
56 
57  led_c.led_num=convert_table[led%11];
58  led_c.action=state<=1 ? !state : state;
59  led_c.brightness=bright;
60  led_c.blink_count=255;
61  _PostLEDMessage(&led_c);
62 }
void camera_set_nr ( int  to)
void camera_set_raw ( int  mode)
void camera_set_script_autostart ( int  state)
void camera_shoot ( )
void camera_sleep ( long  v)
void exit_alt ( )

Definiert in Zeile 72 der Datei kbd_process.c.

73 {
74  kbd_blocked = 0;
76 }
int get_usb_power ( int  edge)

Definiert in Zeile 327 der Datei usb_remote.c.

328 {
329  int x = 0;
330 
331  switch( mode)
332  {
333  case SINGLE_PULSE :
334  x = usb_power;
335  usb_power = 0;
336  break ;
337  case USB_STATE :
338  x=usb_state;
339  break ;
340  case BUFFERED_PULSE :
341  if ( usb_buffer_out != usb_buffer_in )
342  {
344  x = *usb_buffer_out ;
345  }
346  break ;
347  case PULSE_COUNT :
348  x = usb_count;
349  usb_count = 0;
350  break ;
351  case LM_PULSE_COUNT :
354  break ;
355  case HPTIMER_ERROR_COUNT :
358  break ;
359  }
360  return x;
361 }
static int md_detect_motion ( void  )

Definiert in Zeile 441 der Datei motion_detector.c.

442 {
443  int idx, tick, rv;
444  int val, cy, cv, cu;
445 
446  register int col, row, x, y;
447 
448  if(!md_running())
449  {
450  return 0;
451  }
452 
453  tick = get_tick_count();
454  rv = 1;
455 
456 #ifdef OPT_MD_DEBUG
457  if(motion_detector.comp_calls_cnt < MD_REC_CALLS_CNT)
458  {
459  motion_detector.comp_calls[motion_detector.comp_calls_cnt]=tick;
460  }
461  motion_detector.comp_calls_cnt++;
462 #endif
463 
465  {
468  return 0;
469  }
470 
472  {
473  // wait for the next time
474  return 1;
475  }
476 
478 
479  unsigned char* img = vid_get_viewport_active_buffer();
480  if (!img) return 0;
481 
482 #ifdef OPT_MD_DEBUG
483  if(motion_detector.comp_calls_cnt==50 && (motion_detector.parameters & MD_MAKE_RAM_DUMP_FILE) != 0 )
484  {
485  mx_dump_memory((char*)img);
486  }
487 #endif
488 
490 
491  img += vid_get_viewport_image_offset(); // offset into viewport for when image size != viewport size (e.g. 16:9 image on 4:3 LCD)
492 
493  int vp_h = vid_get_viewport_height();
494  int vp_w = vid_get_viewport_width();
496 
497  int x_step = motion_detector.pixels_step * 3;
498  int y_step = motion_detector.pixels_step * vp_bw;
499 
500  for (idx=0, row=0; row < motion_detector.rows; row++)
501  {
502  // Calc img y start and end offsets (use same height for all cells so 'points' is consistent)
503  int y_start = ((row * vp_h) / motion_detector.rows) * vp_bw;
504  int y_end = y_start + ((vp_h / motion_detector.rows) * vp_bw);
505 
506  for (col=0; col < motion_detector.columns; col++, idx++)
507  {
508  int in_clipping_region=0;
509 
514  {
515  in_clipping_region=1;
516  }
517 
518  int curr = 0;
519  int diff = 0;
520 
521  if (
523  (motion_detector.clipping_region_mode==MD_REGION_EXCLUDE && in_clipping_region==0) ||
524  (motion_detector.clipping_region_mode==MD_REGION_INCLUDE && in_clipping_region==1)
525  )
526  {
527  // Calc img x start and end offsets (use same width for all cells so 'points' is consistent)
528  int x_start = ((col * vp_w) / motion_detector.columns) * 3;
529  int x_end = x_start + ((vp_w / motion_detector.columns) * 3);
530 
531  int points = 0;
532 
533  for (y=y_start; y<y_end; y+=y_step)
534  {
535  for (x=x_start; x<x_end; x+=x_step)
536  {
537  // ARRAY of UYVYYY values
538  // 6 bytes - 4 pixels
539 
541  {
542  val = img[y + x + 1]; //Y
543  }
544  else
545  {
546  // Calc offset to UYV component
547  int uvx = x;
548  if (uvx & 1) uvx -= 3;
549 
551  {
552  case MD_MEASURE_MODE_U:
553  val = (signed char)img[y + uvx]; //U
554  break;
555 
556  case MD_MEASURE_MODE_V:
557  val = (signed char)img[y + uvx + 2]; //V
558  break;
559 
560  case MD_MEASURE_MODE_R:
561  cy = img[y + x + 1];
562  cv = (signed char)img[y + uvx + 2];
563  val = clip(((cy<<12) + cv*5743 + 2048)>>12); // R
564  break;
565 
566  case MD_MEASURE_MODE_G:
567  cy = img[y + x + 1];
568  cu = (signed char)img[y + uvx];
569  cv = (signed char)img[y + uvx + 2];
570  val = clip(((cy<<12) - cu*1411 - cv*2925 + 2048)>>12); // G
571  break;
572 
573  case MD_MEASURE_MODE_B:
574  cy = img[y + x + 1];
575  cu = (signed char)img[y + uvx];
576  val = clip(((cy<<12) + cu*7258 + 2048)>>12); // B
577  break;
578 
579  default:
580  val = 0; // Stop compiler warning
581  break;
582  }
583  }
584 
585  curr += val;
586  points++;
587  }
588  }
590  diff = (curr - motion_detector.prev[idx]) / points;
591  if (diff < 0) diff = -diff;
592  if ((diff > motion_detector.threshold) &&
594  {
596  }
597  }
598 
599  motion_detector.diff[idx] = diff;
600  motion_detector.prev[idx] = curr;
601  }
602  }
603 
605  {
609  }
610  else if ( motion_detector.detected_cells > 0 )
611  {
613  {
616 
618  {
619  //make shoot
621  }
622  rv = 0;
623  }
624  }
625 
626  return rv;
627 }
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 script_key_is_clicked ( int  keyid)
int script_key_is_pressed ( int  keyid)
int shooting_get_prop ( int  id)

Definiert in Zeile 60 der Datei shooting.c.

61 {
62  short vv;
63  get_property_case(id, &vv, sizeof(vv));
64  return vv;
65 }
void shooting_set_prop ( int  id,
int  v 
)

Definiert in Zeile 74 der Datei shooting.c.

75 {
76  short vv = v;
77  set_property_case(id, &vv, sizeof(vv));
78  return;
79 }
long stat_get_vbatt ( )

Definiert in Zeile 287 der Datei wrappers.c.

288 {
289  return _VbattGet();
290 }
void ubasic_camera_get_raw ( )
int ubasic_camera_script_autostart ( )