View
3.051
Download
0
Embed Size (px)
DESCRIPTION
Quick overview and code snippets to include Motion Recognition and Voice recognition capability in your Smart TV apps for Samsung.
Citation preview
Motion Recognitionhttp://www.samsungdforum.com/Guide/d01/index.html
Single Handed Gestures• You need to include mouse support in
config.xml<mouse>y</mouse>
• Mouse listener like the web.• Create a div in scene1.html<div id="button0">Button</div> <!-- make it as button --><div id="div0“></div> <!-- make it as trial element -->
• Adding listenerdocument.getElementById('div0').addEventListener('mouseover', function(){
document.getElementById('div0').style.backgroundColor = 'lime';}, false);
document.getElementById('div0').addEventListener('mouseout', function(){document.getElementById('div0').style.backgroundColor = 'yellow';}, false);
document.getElementById('div0').addEventListener('click', function(){alert("clicked");}, false);
Double Handed Gestures• Include webapis
<script type="text/javascript" src="$MANAGER_WIDGET/Common/webapi/1.0/webapis.js"></script>
• Usage.• Check for support and enabledif (webapis.recognition.IsRecognitionSupported()) {
if (webapis.recognition.IsGestureRecognitionEnabled()) {// perform Recognition related actions here, e.g. subscribe } else { alert("ERROR: Gesture recognition is not enabled"); }
} else { alert("ERROR: Gesture recognition not supported"); }
Subscribe to eventswebapis.recognition.SubscribeExEvent(webapis.recognition.PL_RECOGNITION_TYPE_GESTURE, “returnID", function (evt) { that.handleRecognitionEvent.call(that, evt); });
EVENT_GESTURE_2HAND_ZOOM , EVENT_GESTURE_2HAND_ROTATE etc
Voice Recognitionhttp://samsungdforum.com/Guide/tut000001/index.html
Voice Recognition• Embedded Mode
Predefined voice commands.The engine does more of comparison than recognitionDoes NOT require internet.Limited to comparing between 7 items.
• Server Guide ModeFree- form speech.Depends heavily on user’s linguistics and pronunciation.Voice Data is sent to internet to recognize user’s speech.No limits.
Voice Recognition• Include webapis and in config.xml
<script type="text/javascript" src="$MANAGER_WIDGET/Common/webapi/1.0/webapis.js"></script>
<voice>y</voice> in config.xml
• Check for support and if enableddeviceapis.recognition.IsRecognitionSupported()deviceapis.recognition.IsVoiceRecognitionEnabled()deviceapis.recognition.IsVoiceServerLanguageSupported()
Voice Recognition• Subscribe to Voice Events
deviceapis.recognition.SubscribeExEvent(deviceapis.recognition.PL_RECOGNITION_TYPE_VOICE, "VoiceEvt", Main.onVoiceEvent
);
deviceapis.recognition.UnsubscribeExEvent(deviceapis.recognition.PL_RECOGNITION_TYPE_VOICE, "VoiceEvt”
);
• Handle voice eventsMain.onVoiceEvent = function(evt){
switch (evt.eventtype){case 'EVENT_VOICE_RECOG_RESULT':
alert('The user say ' + evt.result);break;
}};
Thank You