Sdílet prostřednictvím


Camera Class

Definition

Caution

This class is obsoleted in this android platform

The Camera class is used to set image capture settings, start/stop preview, snap pictures, and retrieve frames for encoding for video.

[Android.Runtime.Register("android/hardware/Camera", DoNotGenerateAcw=true)]
[System.Obsolete("This class is obsoleted in this android platform")]
public class Camera : Java.Lang.Object
[<Android.Runtime.Register("android/hardware/Camera", DoNotGenerateAcw=true)>]
[<System.Obsolete("This class is obsoleted in this android platform")>]
type Camera = class
    inherit Object
Inheritance
Camera
Attributes

Remarks

The Camera class is used to set image capture settings, start/stop preview, snap pictures, and retrieve frames for encoding for video. This class is a client for the Camera service, which manages the actual camera hardware.

To access the device camera, you must declare the android.Manifest.permission#CAMERA permission in your Android Manifest. Also be sure to include the <uses-feature> manifest element to declare camera features used by your application. For example, if you use the camera and auto-focus feature, your Manifest should include the following:

&lt;uses-permission android:name="android.permission.CAMERA" />
            &lt;uses-feature android:name="android.hardware.camera" />
            &lt;uses-feature android:name="android.hardware.camera.autofocus" />

To take pictures with this class, use the following steps:

<ol> <li>Obtain an instance of Camera from #open(int).

<li>Get existing (default) settings with #getParameters().

<li>If necessary, modify the returned Camera.Parameters object and call #setParameters(Camera.Parameters).

<li>Call #setDisplayOrientation(int) to ensure correct orientation of preview.

<li><b>Important</b>: Pass a fully initialized SurfaceHolder to #setPreviewDisplay(SurfaceHolder). Without a surface, the camera will be unable to start the preview.

<li><b>Important</b>: Call #startPreview() to start updating the preview surface. Preview must be started before you can take a picture.

<li>When you want, call #takePicture(Camera.ShutterCallback, Camera.PictureCallback, Camera.PictureCallback, Camera.PictureCallback) to capture a photo. Wait for the callbacks to provide the actual image data.

<li>After taking a picture, preview display will have stopped. To take more photos, call #startPreview() again first.

<li>Call #stopPreview() to stop updating the preview surface.

<li><b>Important:</b> Call #release() to release the camera for use by other applications. Applications should release the camera immediately in android.app.Activity#onPause() (and re-#open() it in android.app.Activity#onResume()). </ol>

To quickly switch to video recording mode, use these steps:

<ol> <li>Obtain and initialize a Camera and start preview as described above.

<li>Call #unlock() to allow the media process to access the camera.

<li>Pass the camera to android.media.MediaRecorder#setCamera(Camera). See android.media.MediaRecorder information about video recording.

<li>When finished recording, call #reconnect() to re-acquire and re-lock the camera.

<li>If desired, restart preview and take more photos or videos.

<li>Call #stopPreview() and #release() as described above. </ol>

This class is not thread-safe, and is meant for use from one event thread. Most long-running operations (preview, focus, photo capture, etc) happen asynchronously and invoke callbacks as necessary. Callbacks will be invoked on the event thread #open(int) was called from. This class's methods must never be called from multiple threads at once.

<p class="caution"><strong>Caution:</strong> Different Android-powered devices may have different hardware specifications, such as megapixel ratings and auto-focus capabilities. In order for your application to be compatible with more devices, you should not make assumptions about the device camera specifications.</p>

<div class="special reference"> <h3>Developer Guides</h3>

For more information about using cameras, read the Camera developer guide.

</div>

This member is deprecated. We recommend using the new android.hardware.camera2 API for new applications.

Java documentation for android.hardware.Camera.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Constructors

Camera(IntPtr, JniHandleOwnership)

A constructor used when creating managed representations of JNI objects; called by the runtime.

Fields

ActionNewPicture
Obsolete.

Broadcast Action: A new picture is taken by the camera, and the entry of the picture has been added to the media store.

ActionNewVideo
Obsolete.

Broadcast Action: A new video is recorded by the camera, and the entry of the video has been added to the media store.

Properties

Class

Returns the runtime class of this Object.

(Inherited from Object)
Handle

The handle to the underlying Android instance.

(Inherited from Object)
JniIdentityHashCode (Inherited from Object)
JniPeerMembers
NumberOfCameras
Obsolete.

Returns the number of physical cameras available on this device.

PeerReference (Inherited from Object)
ThresholdClass

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

ThresholdType

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

Methods

AddCallbackBuffer(Byte[])
Obsolete.

Adds a pre-allocated buffer to the preview callback buffer queue.

AutoFocus(Camera+IAutoFocusCallback)
Obsolete.

Starts camera auto-focus and registers a callback function to run when the camera is focused.

CancelAutoFocus()
Obsolete.

Cancels any auto-focus function in progress.

Clone()

Creates and returns a copy of this object.

(Inherited from Object)
Dispose() (Inherited from Object)
Dispose(Boolean) (Inherited from Object)
EnableShutterSound(Boolean)
Obsolete.

Enable or disable the default shutter sound when taking a picture.

Equals(Object)

Indicates whether some other object is "equal to" this one.

(Inherited from Object)
GetCameraInfo(Int32, Camera+CameraInfo)
Obsolete.

Returns the information about a particular camera.

GetHashCode()

Returns a hash code value for the object.

(Inherited from Object)
GetParameters()
Obsolete.

Returns the current settings for this Camera service.

JavaFinalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

(Inherited from Object)
Lock()
Obsolete.

Re-locks the camera to prevent other processes from accessing it.

Notify()

Wakes up a single thread that is waiting on this object's monitor.

(Inherited from Object)
NotifyAll()

Wakes up all threads that are waiting on this object's monitor.

(Inherited from Object)
Open()
Obsolete.

Creates a new Camera object to access the first back-facing camera on the device.

Open(Int32)
Obsolete.

Creates a new Camera object to access a particular hardware camera.

Reconnect()
Obsolete.

Reconnects to the camera service after another process used it.

Release()
Obsolete.

Disconnects and releases the Camera object resources.

SetAutoFocusMoveCallback(Camera+IAutoFocusMoveCallback)
Obsolete.

Sets camera auto-focus move callback.

SetDisplayOrientation(Int32)
Obsolete.

Set the clockwise rotation of preview display in degrees.

SetErrorCallback(Camera+IErrorCallback)
Obsolete.

Registers a callback to be invoked when an error occurs.

SetFaceDetectionListener(Camera+IFaceDetectionListener)
Obsolete.

Registers a listener to be notified about the faces detected in the preview frame.

SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
SetOneShotPreviewCallback(Camera+IPreviewCallback)
Obsolete.

Installs a callback to be invoked for the next preview frame in addition to displaying it on the screen.

SetParameters(Camera+Parameters)
Obsolete.

Changes the settings for this Camera service.

SetPreviewCallback(Camera+IPreviewCallback)
Obsolete.

Installs a callback to be invoked for every preview frame in addition to displaying them on the screen.

SetPreviewCallbackWithBuffer(Camera+IPreviewCallback)
Obsolete.

Installs a callback to be invoked for every preview frame, using buffers supplied with #addCallbackBuffer(byte[]), in addition to displaying them on the screen.

SetPreviewDisplay(ISurfaceHolder)
Obsolete.

Sets the Surface to be used for live preview.

SetPreviewTexture(SurfaceTexture)
Obsolete.

Sets the SurfaceTexture to be used for live preview.

SetZoomChangeListener(Camera+IOnZoomChangeListener)
Obsolete.

Registers a listener to be notified when the zoom value is updated by the camera driver during smooth zoom.

StartFaceDetection()
Obsolete.

Starts the face detection.

StartPreview()
Obsolete.

Starts capturing and drawing preview frames to the screen.

StartSmoothZoom(Int32)
Obsolete.

Zooms to the requested value smoothly.

StopFaceDetection()
Obsolete.

Stops the face detection.

StopPreview()
Obsolete.

Stops capturing and drawing preview frames to the surface, and resets the camera for a future call to #startPreview().

StopSmoothZoom()
Obsolete.

Stops the smooth zoom.

TakePicture(Camera+IShutterCallback, Camera+IPictureCallback, Camera+IPictureCallback, Camera+IPictureCallback)
Obsolete.

Equivalent to

TakePicture(Camera+IShutterCallback, Camera+IPictureCallback, Camera+IPictureCallback)
Obsolete.

Equivalent to

ToArray<T>() (Inherited from Object)
ToString()

Returns a string representation of the object.

(Inherited from Object)
Unlock()
Obsolete.

Unlocks the camera to allow another process to access it.

UnregisterFromRuntime() (Inherited from Object)
Wait()

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>.

(Inherited from Object)
Wait(Int64, Int32)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
Wait(Int64)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)

Events

FaceDetection
ZoomChange

Explicit Interface Implementations

IJavaPeerable.Disposed() (Inherited from Object)
IJavaPeerable.DisposeUnlessReferenced() (Inherited from Object)
IJavaPeerable.Finalized() (Inherited from Object)
IJavaPeerable.JniManagedPeerState (Inherited from Object)
IJavaPeerable.SetJniIdentityHashCode(Int32) (Inherited from Object)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) (Inherited from Object)
IJavaPeerable.SetPeerReference(JniObjectReference) (Inherited from Object)

Extension Methods

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable)

Applies to