public abstract class SCameraEffectProcessor extends SCameraProcessor
SCameraFilter Effect processor applies the filter effect on the image data. This processor can be applied to a single image data (Image buffer processing) and also to a stream of image data (Image stream processing).
During 'Image buffer processing' this processor acquire input data via requestProcess(Image)
and filter effect applied result
Image will be posted to SCameraEffectProcessor.EventCallback
.
For 'Image stream processing', this processor takes a series of image data from input surface
and writes down
results image data to output surface
or recording surface
. This processing is useful for live-preview/live-recording effect.
The output surface
needs to be configured before startStreamProcessing()
as its default output target for 'Image stream processing'.
However, the recording surface
can be set to null
; it works as an auxiliary output target.
(c.f., For normal camera device usage, recording can be started or stopped during preview)
If the resolution of the device is Quad HD(2560X1440), it is recommended to use the Full HD(1920X1080) video stream for the better performance and current consumption. When using SurfaceView in the application, by using setFixedSize function of SurfaceHolder with reference to the following linked guide, the Screen Resolution can be set to less than Full HD. In addition, when using a TextureView, it can be done by using the setDefaultBufferSize function of SurfaceTexture.
Also note that a filter with FILTER_TYPE_FACE_AR
is not compatible with
requestProcess(Image)
. A filter with FILTER_TYPE_FACE_AR
type must use requestSnapCapture()
.
Initialization key | |
---|---|
Key | Meaning |
SCameraProcessor.STREAM_SIZE | Input stream size |
SCameraProcessor.STILL_SIZE | Still image size |
SCameraProcessor.STILL_INPUT_FORMAT | Still image input format |
SCameraProcessor.STILL_OUTPUT_FORMAT | Still image output format |
SCameraProcessor.CAMERA_ID | ID of camera device, which is used to provide preview data to processor. |
Modifier and Type | Class and Description |
---|---|
static class |
SCameraEffectProcessor.EventCallback
Callback interface used to deliver the result image.
|
Modifier and Type | Field and Description |
---|---|
static SCameraProcessorParameter.Key<SCameraFilter> |
FILTER_EFFECT
Desired
filter , SCameraEffectProcessor will use to process stream and image data. |
static String |
NAME
String name of effect processor.
|
CAMERA_ID, JPEG_ORIENTATION, JPEG_QUALITY, MULTI_INPUT_COUNT_RANGE, NATIVE_PROCESSOR_MSG_DECODING_FAIL, NATIVE_PROCESSOR_MSG_ENCODING_FAIL, NATIVE_PROCESSOR_MSG_PROCESSING_FAIL, NATIVE_PROCESSOR_MSG_UNKNOWN_ERROR, STILL_INPUT_FORMAT, STILL_INPUT_FORMAT_LIST, STILL_OUTPUT_FORMAT, STILL_OUTPUT_FORMAT_LIST, STILL_SIZE, STILL_SIZE_LIST, STREAM_SIZE, STREAM_SIZE_LIST
Modifier and Type | Method and Description |
---|---|
abstract Surface |
getInputSurface()
Returns a surface, which will be an input to this processor.
|
abstract void |
requestProcess(Image data)
Processes image data.
|
abstract void |
requestSnapCapture()
Request a snap-shot of filter effect processed preview image.
|
abstract void |
setEventCallback(SCameraEffectProcessor.EventCallback callback,
Handler handler)
Registers a callback to be invoked for result.
|
abstract void |
setOutputSurface(Surface surface)
Sets output surface.
|
abstract void |
setRecordingSurface(Surface surface)
Sets recording surface.
|
abstract void |
startStreamProcessing()
Starts the stream processing.
|
abstract void |
stopStreamProcessing()
Stops the processing.
|
close, deinitialize, getParameters, initialize, setParameters
public static final String NAME
public static final SCameraProcessorParameter.Key<SCameraFilter> FILTER_EFFECT
filter
, SCameraEffectProcessor will use to process stream and image data.public abstract Surface getInputSurface()
Returns a surface, which will be an input to this processor.
A returned surface will have a dimension same to SCameraProcessor.STREAM_SIZE
and a format of ImageFormat.YUV_420_888
.
The surface must be set to SCaptureRequest
and
should call SCameraCaptureSession.setRepeatingRequest(SCaptureRequest, SCameraCaptureSession.CaptureCallback, Handler)
after initialize(), but before startStreamProcessing().
IllegalStateException
- If SCameraProcessor.initialize()
is not called.public abstract void setOutputSurface(Surface surface)
Sets output surface. Processed input image from input surface will be written to output surface. Generally, this function sets the surface to output the camera images.
SCameraEffectProcessor supports only 24fps; So FPS must be set to 24 in SCameraDevice.
This method must be called after initialize(), but before startStreamProcessing().
A Surface must be one of a TextureView, Allocation, SurfaceView, SurfaceTexture
. Not from ImageReader
.
This function has no checking of wrong format of surface.
surface
- Output surface.IllegalStateException
- If SCameraProcessor.initialize()
is not called.IllegalArgumentException
- If surface is null or invalidpublic abstract void setRecordingSurface(Surface surface)
Sets recording surface. Processed input image from input surface will be written to recording surface. Recording surface is auxiliary output target for recording purpose. A camera image for recording writes down if the surface is set in this function.
This method must be called after startStreamProcessing(), but before stopStreamProcessing().
A Surface must be one of a MediaCodec, MediaRecorder
. Not from ImageReader
.
This function has no checking of wrong format of surface.
SCameraEffectProcessor supports only 24fps; So FPS must be set to 24 in MediaCodec or MediaRecorder.
If recording surface has a larger dimension than SCameraProcessor.STREAM_SIZE
, the processed image will be scaled.
If 'null' is given to setRecordingSurface(Surface)
, the result will no longer be updated to the recording surface.
surface
- Output surface.IllegalStateException
- If SCameraProcessor.initialize()
is not called or processor is in Stop state.public abstract void startStreamProcessing()
IllegalStateException
- If SCameraProcessor.initialize()
is not called or the processor is Streaming state.IllegalArgumentException
- If setOutputSurface(Surface)
is not called.public abstract void stopStreamProcessing()
IllegalStateException
- If SCameraProcessor.initialize()
is not called or the processor is in Stop state.public abstract void requestProcess(Image data)
Processes image data.
After calling this method, you must not call another requestProcess(Image)
or requestSnapCapture()
until the EventCallback has returned.
Otherwise, RuntimeException will be thrown.
This method must be called after startStreamProcessing(), but before stopStreamProcessing().
data
- Image instance on which the filter effect will be applied to.IllegalStateException
- If SCameraProcessor.initialize()
is not called.IllegalArgumentException
- If data is null. Or if data is invalid.RuntimeException
- If fail to start processing or startStreamProcessing()
is not called.UnsupportedOperationException
- If current filter effect has a type of FILTER_TYPE_FACE_AR
.public abstract void requestSnapCapture()
Request a snap-shot of filter effect processed preview image.
After calling this method, you must not call another requestProcess(Image)
or requestSnapCapture()
until the EventCallback has returned.
Otherwise, RuntimeException will be thrown.
This method must be called after startStreamProcessing(), but before stopStreamProcessing().
Note that captured image is not flipped for the front-facing camera. While the preview image is flipped, so the user can see themselves as looking into a mirror.
IllegalStateException
- If SCameraProcessor.initialize()
is not called.RuntimeException
- If fail to start processing or startStreamProcessing()
is not called.UnsupportedOperationException
- If current filter effect does not have a type of FILTER_TYPE_FACE_AR
.public abstract void setEventCallback(SCameraEffectProcessor.EventCallback callback, Handler handler)
callback
- a callback object that receives a result.handler
- the handler on which the callback should be invoked, or null
to use the current thread's looper
.IllegalStateException
- If SCameraProcessor.initialize()
is not called.IllegalArgumentException
- If no handler is given and the calling thread has no looper.Copyright © Samsung Electronics, Co., Ltd. All rights reserved.