How to Use the Samsung SmartTV's Camera Feature in Applications - dummies

How to Use the Samsung SmartTV’s Camera Feature in Applications

By Handstudio Co., Ltd

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.


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


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
Functions GetCameraState

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
(Camera is not connected)
(Camera is being loaded)
(Camera is ready)
(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:


Example 2 of the RegisterEventCallback() function:


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: 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)


    May choose between VGA and HD using these options:

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

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:


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)

Source: Samsung Developers Forum

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