Samsung SmartTV can use both the internal and an external camera. Here's how the cameras are controlled in an application. The SDF provides intensive camera-related API guides, including how to set initial position and size of the camera window, that are sufficient for developing an application with the camera feature.

“Fitness VOD” is a good example that uses the camera feature. It offers “Virtual Mirror” that shows a user’s action on the screen using the camera feature, so that the user can closely compare a professional coach and herself. The application is available on the Samsung SmartTV App Store.

image0.jpg

A user can also control sizes of VOD and the Virtual Mirror (camera) windows with three preset modes.

image1.jpg

The SDF’s DTV Web Device API provides all camera-related API functions. Unlike the IME or AVPlayer, no complex exception handling is needed to add the camera capability. The API simply supports turning on or off a camera.

List of Camera Controlling Member Functions
Camera
CLSID clsid:SAMSUNG-INFOLINK-SEF
Functions GetCameraState
RegisterEventCallback
StartCamVideo
StopCamVideo

Checking camera status

A camera’s current status can be checked using the GetCameraState() function, which returns one of four statuses listed.

The GetCameraState() function
Function GetCameraState
Version Support from Camera-0001
Usage GetCameraState()
Security Type RECOG
Return Value PL_CAMERA_STATE
PL_CAMERA_STATE_DISCONNECTED
(Camera is not connected)
PL_CAMERA_STATE_CONNECTING
(Camera is being loaded)
PL_CAMERA_STATE_READY
(Camera is ready)
PL_CAMERA_STATE_PLAYING
(Camera is working)

Source: Samsung Developers Forum

The change in the camera status can be monitored using the RegisterEventCallback function, which returns one of the following three events.

  • PL_CAMERA_EVENT_DISCONNECTED: Camera is disconnected

  • PL_CAMERA_EVENT_CONNECTING: Camera is connecting

  • PL_CAMERA_EVENT_CONNECTED: Camera is connected

The RegisterEventCallback() Function
Function RegisterEventCallback
Version Support from Camera-0001
Usage RegisterEventCallback (Callback Function)
Return Value void

Source: Samsung Developers Forum

Example 1 of the RegisterEventCallback() function:

image2.jpg

Example 2 of the RegisterEventCallback() function:

image3.jpg

Turning on a camera

Use the StartCamVideo() function to start a camera with initial cam video parameters, including distance from the TV screen’s top-left edge, the cam video region’s width and height, and screen resolution and quality level.

[Credit: Source: <a href=
Credit: Source: Samsung Developers Forum

The parameters of the StartCamVideo( ) function are as follows:

  • [positionX]

    Horizontal distance from the TV screen’s top-left corner (integer value)

  • [positionY]

    Vertical distance from the TV screen’s top-left corner (integer value)

  • [displayW]

    Width of the camera window (integer value)

  • [displayH]

    Height of the camera window (integer value)

  • [PL_CAMERA_RESOLUTION]

    May choose between VGA and HD using these options:

    webapis.camera.PL_CAMERA_RESOLUTION_VGA
    webapis.camera.PL_CAMERA_RESOLUTION_HD
  • [PL_CAMERA_QUALITY]

    May choose among Low, Middle, and High using these options:

webapis.camera.PL_CAMERA_QUALITY_LOW
webapis.camera.PL_CAMERA_QUALITY_MID
webapis.camera.PL_CAMERA_QUALITY_HIGH

Following is an example of the StartCamVideo( ) function that turn the camera on with its screen displayed as a 640px by 480px window located at the top-left corner of the TV screen:

image5.jpg

Turning off a camera

Turning off a camera is easier than turning it on since no parameter is necessary. Use the StopCamVideo() function to turn off a camera. The function returns a value that indicates if the camera was successfully turned off.

The StopCamVideo( ) Function
Function StopCamVideo
Version Support from Camera-0001
Usage StopCamVideo()
Return Value 1 (Success)
0 (Failure)
Example webapis.camera.StopCamVideo();

Source: Samsung Developers Forum

The next example demonstrates turning on a camera and then turning it off.

image6.jpg