Skip to content

Commit

Permalink
Add more camera configuration (hard-coded values)
Browse files Browse the repository at this point in the history
  • Loading branch information
linuxstb committed May 30, 2013
1 parent 99cb948 commit 26530c1
Showing 1 changed file with 62 additions and 7 deletions.
69 changes: 62 additions & 7 deletions omx_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -560,13 +560,6 @@ OMX_ERRORTYPE omx_setup_camera_pipeline(struct omx_pipeline_t* pipe)
framerate.xEncodeFramerate = 25 << 16; // Q16 format - 25fps
OERR(OMX_SetConfig(pipe->camera.h, OMX_IndexConfigVideoFramerate, &framerate));

/* Set the brightness */
OMX_CONFIG_BRIGHTNESSTYPE brightness;
OMX_INIT_STRUCTURE(brightness);
brightness.nPortIndex = OMX_ALL;
brightness.nBrightness = 50; /* 0 to 100 */
OERR(OMX_SetConfig(pipe->camera.h, OMX_IndexConfigCommonBrightness, &brightness));

/* Set the sharpness */
OMX_CONFIG_SHARPNESSTYPE sharpness;
OMX_INIT_STRUCTURE(sharpness);
Expand All @@ -581,13 +574,75 @@ OMX_ERRORTYPE omx_setup_camera_pipeline(struct omx_pipeline_t* pipe)
contrast.nContrast = -10; /* -100 to 100 */
OERR(OMX_SetConfig(pipe->camera.h, OMX_IndexConfigCommonContrast, &contrast));

/* Set the brightness */
OMX_CONFIG_BRIGHTNESSTYPE brightness;
OMX_INIT_STRUCTURE(brightness);
brightness.nPortIndex = OMX_ALL;
brightness.nBrightness = 50; /* 0 to 100 */
OERR(OMX_SetConfig(pipe->camera.h, OMX_IndexConfigCommonBrightness, &brightness));

/* Set the saturation */
OMX_CONFIG_SATURATIONTYPE saturation;
OMX_INIT_STRUCTURE(saturation);
saturation.nPortIndex = OMX_ALL;
saturation.nSaturation = 0; /* -100 to 100 */
OERR(OMX_SetConfig(pipe->camera.h, OMX_IndexConfigCommonSaturation, &saturation));

/* Video stabilisation */
OMX_CONFIG_FRAMESTABTYPE framestab;
OMX_INIT_STRUCTURE(framestab);
framestab.nPortIndex = OMX_ALL;
framestab.bStab = OMX_FALSE;
OERR(OMX_SetConfig(pipe->camera.h, OMX_IndexConfigCommonFrameStabilisation, &framestab));

/* Set EV compensation, ISO and metering mode */
OMX_CONFIG_EXPOSUREVALUETYPE exposurevalue;
OMX_INIT_STRUCTURE(exposurevalue);
exposurevalue.nPortIndex = OMX_ALL;
OERR(OMX_GetConfig(pipe->camera.h, OMX_IndexConfigCommonExposureValue, &exposurevalue));
fprintf(stderr,"nSensitivity=%d\n",exposurevalue.nSensitivity);
exposurevalue.xEVCompensation = 0; /* Fixed point value stored as Q16 */
exposurevalue.nSensitivity = 100; /**< e.g. nSensitivity = 100 implies "ISO 100" */
exposurevalue.bAutoSensitivity = OMX_FALSE;
exposurevalue.eMetering = OMX_MeteringModeAverage;
OERR(OMX_SetConfig(pipe->camera.h, OMX_IndexConfigCommonExposureValue, &exposurevalue));

/* Set exposure mode */
OMX_CONFIG_EXPOSURECONTROLTYPE exposure;
OMX_INIT_STRUCTURE(exposure);
exposure.nPortIndex = OMX_ALL;
exposure.eExposureControl = OMX_ExposureControlAuto;
OERR(OMX_SetConfig(pipe->camera.h, OMX_IndexConfigCommonExposure, &exposure));

/* Set AWB mode */
OMX_CONFIG_WHITEBALCONTROLTYPE awb;
OMX_INIT_STRUCTURE(awb);
awb.nPortIndex = OMX_ALL;
awb.eWhiteBalControl = OMX_WhiteBalControlAuto;
OERR(OMX_SetConfig(pipe->camera.h, OMX_IndexConfigCommonWhiteBalance, &awb));

/* Set image effect */
OMX_CONFIG_IMAGEFILTERTYPE imagefilter;
OMX_INIT_STRUCTURE(imagefilter);
imagefilter.nPortIndex = OMX_ALL;
imagefilter.eImageFilter = OMX_ImageFilterNone;
OERR(OMX_SetConfig(pipe->camera.h, OMX_IndexConfigCommonImageFilter, &imagefilter));

/* Set colour effect */
OMX_CONFIG_COLORENHANCEMENTTYPE colour;
OMX_INIT_STRUCTURE(colour);
colour.nPortIndex = OMX_ALL;
colour.bColorEnhancement = OMX_FALSE;
colour.nCustomizedU = 128;
colour.nCustomizedV = 128;
OERR(OMX_SetConfig(pipe->camera.h, OMX_IndexConfigCommonColorEnhancement, &colour));

/* Turn off the LED - doesn't work! */
OMX_CONFIG_PRIVACYINDICATORTYPE privacy;
OMX_INIT_STRUCTURE(privacy);
privacy.ePrivacyIndicatorMode = OMX_PrivacyIndicatorOff;
OERR(OMX_SetConfig(pipe->camera.h, OMX_IndexConfigPrivacyIndicator, &privacy));

// Wait for the callback that OMX_IndexParamCameraDeviceNumber has
// changed. At this point, all the drivers have been loaded. Other
// settings can be applied whilst waiting for this event.
Expand Down

1 comment on commit 26530c1

@jvcleave
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - just wanted to say thanks for this example! I was able to use a lot of it to be able to connect to the camera and output to an EGL texture so I can run shaders on it :)

It's super messy and written for openFrameworks (a c++ framework) but it is a start!
https://github.com/jvcleave/omxCameraApp/blob/master/src/testApp.cpp

Please sign in to comment.