Thursday, November 29, 2012

Camera header files, flash control source and flashlight ipk

A flashlight program recently in order to put forward a flashlight, specially rebuilt according to the API mmfcamcoder.h and some of the header files, along with control of the source of the flash, and do a good job for you greatly to continue to study

Fever too big ah flashlight Do not drive too long Oh, be careful, first off you put twists, burning JJ peril

Flashlight:

Header file:

Source:
Turn on the camera:
  1. MMHandleType handler = 0, attr;
  2. MMCamPreset cp;
  3. cp.videodev_type = MM_VIDEO_DEVICE_CAMERA0; / / camera0 on behalf of the main camera
  4. int c = MMCamcorderCreate (& handler, & cp); / / Create a handler
  5. fprintf (stderr, "create [% d] \ n", c);

  6. / / Get the handler the strobe attributes enumeration, and assigned to the attr
  7. MMCamcorderGetAttrs (handler, MM_CAMCORDER_ATTR_STROBE, & attr);
  8. fprintf (stderr, "attr [% d] \ n", attr);

  9. int r = MMCamcorderRealize (handler); / / initialize handler
  10. fprintf (stderr, "Realize [% d] \ n", r);

  11. / / From attr obtain the strobe property control, and set FLASH_MOVIE_ON
  12. / / Set FLASH_OFF said Close, FLASH_ON and FLASH_AUTO are only flash, FLASH_MOVIE_ON long bright
  13. MMAttrsSetInt (attr, MM_CAMCORDER_STROBE_CONTROL, MM_CAMCORDER_FLASH_MOVIE_ON);

  14. / / Set a good strobe attribute set back to the handler
  15. MMCamcorderSetAttrs (handler, MM_CAMCORDER_ATTR_STROBE, attr);

  16. / / Start camera preview preview state handler
  17. int s = MMCamcorderStart (handler);
  18. fprintf (stderr, "start [% d] \ n", s);

  19. / / This is where the real start shooting, open to little reaction time, so if you just open the flash, do not need this step
  20. / / Int cs = MMCamcorderCaptureStart (handler);
  21. / / Fprintf (stderr, "CaptureStart [% d] \ n", cs);
Turn off the camera:
  1. / / Close is turn you stop shooting
  2. / / Int css = MMCamcorderCaptureStop (handler);
  3. / / Fprintf (stderr, "CaptureStop [% d] \ n", css);

  4. / / Close the preview mode
  5. int ss = MMCamcorderStop (handler);
  6. fprintf (stderr, "Stop [% d] \ n", ss);

  7. / / Turn off the flash
  8. MMAttrsSetInt (attr, MM_CAMCORDER_STROBE_CONTROL, MM_CAMCORDER_FLASH_OFF);
  9. MMCamcorderSetAttrs (handler, MM_CAMCORDER_ATTR_STROBE, attr);

  10. / / Unrealize
  11. int ur = MMCamcorderUnrealize (handler);
  12. fprintf (stderr, "unrealize [% d] \ n", ur);

  13. / / Final destruction
  14. int d = MMCamcorderDestroy (handler);
  15. fprintf (stderr, "destroy [% d] \ n", d);

No comments:

Post a Comment