Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I render the video to client side browser? #29

Open
tanmoyAtb opened this issue Dec 27, 2017 · 3 comments
Open

How do I render the video to client side browser? #29

tanmoyAtb opened this issue Dec 27, 2017 · 3 comments

Comments

@tanmoyAtb
Copy link

tanmoyAtb commented Dec 27, 2017

Hello I tried streaming the modified chunks to front end using sockets.io. Here's a code snippet.

on server side

darknet.detect({
  cfg: './cfg/yolo.cfg',
  weights: './yolo.weights',
  data: './cfg/coco.data',
  cameraIndex: 0,
  frameSkip: 0, // how many frames to skip, when calling the callback
}, function(modified, original, detections, dimensions) {
  getPipe(dimensions).write(modified);
  
  io.emit('data', modified);

});

on client side

socket.on('data', data => {
	console.log(data);
	image.src = `data:image/jpeg;base64,${data}`;
});

I'm receiving data in my client side console, but the images are not getting decoded for preview

@OrKoN
Copy link
Contributor

OrKoN commented Dec 27, 2017

@tanmoy12 the data in the modified buffer is raw pixels (normally in bgr24 format). You need to transform it to jpeg or anything else before sending to the client.

@tanmoyAtb
Copy link
Author

Thank you. I could not find any native library in nodejs for the conversion.

@CasperPas
Copy link

Have you tried using the data with Canvas2D on browser side?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants