User talk:Dead project: Difference between revisions

Line 61: Line 61:
But that means the developer or library provider should provide a way to transform ImageBitmap to OpenCV::Mat type. The alternative is providing a new API(WebImage) which dealing with those kinds of interface problems. We can start this kind of implementation in B2G case first.<br>
But that means the developer or library provider should provide a way to transform ImageBitmap to OpenCV::Mat type. The alternative is providing a new API(WebImage) which dealing with those kinds of interface problems. We can start this kind of implementation in B2G case first.<br>


===Example Code 1 ===
===Example Code ===
Main javascript file:
Please check the section in [http://chiahungtai.github.io/mediacapture-worker/index.html#Examples examples of MediaStreamTrack with worker].
<source lang="javascript">
 
var myMediaStream;
navigator.getUserMedia({video:true, audio:false}, function(localMediaStream) {
  myMediaStream = localMediaStream;
  var videoTracks = myMediaStream.getVideoTracks();
  var track = videoTracks[0];
  var myWorker = new Worker("textRecognition.js");
  track.addWorkerMonitor(myWorker));
  myWorker.onmessage = function (oEvent) {
    console.log("Worker recognized: " + oEvent.data);
  };
  var elem = document.getElementById('videoelem');
  elem.mozSrcObject = dest.stream;
  elem.play();
}, null);
 
</source>
textRecognition.js:
<source lang="javascript">
var textDetector = WebImage.createTextDetector(img.width, img.height)
 
onvideoprocess = function (event) {
  var img = event.inputFrame;
  // Do text recognition.
  // We might use built-in detection function or OpenCV in asm.js
  var words= textDetector.findText(img);
  var recognizedText;
  for (var ix = 0; ix < words.length; ix++) {
    recognizedText = recognizedText  + words[ix] + " ";
  }
  postMessage(recognizedText);
}
</source>


==ImageBitmap extensions==
==ImageBitmap extensions==
Confirmed users
770

edits