
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Capturing images from webcam and converting to rgb24. Linux only (v4l2)
npm install linuxcam
var cam = require('linuxcam');
cam.start("/dev/video0", 320, 240);
var frame = cam.frame(); // Buffer
The buffer contains rgb24 data and you can convert it using jpeg-fresh module.
var Jpeg = require('jpeg-fresh').Jpeg;
var jpeg = new Jpeg(frame.data, frame.width, frame.height, 'rgb');
var jpeg_image = jpeg.encodeSync(); // Buffer
var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http);
var cam = require('linuxcam');
var Jpeg = require('jpeg-fresh').Jpeg;
cam.start("/dev/video0", 320, 240);
function update(socket) {
var frame = cam.frame();
var jpeg = new Jpeg(frame.data, frame.width, frame.height, 'rgb');
var jpeg_frame = jpeg.encodeSync();
socket.emit("frame", jpeg_frame.toString('base64'));
setTimeout(function() {
update(socket);
}, 40);
}
io.on('connection', function(socket){
socket.on('error', function(err){
console.log("ERROR: "+err);
});
update(socket);
});
http.listen(9639, function(){
console.log('listening on *:9639');
});
<!DOCTYPE html>
<html>
<head>
<script src="https://cdn.socket.io/socket.io-1.3.5.js"></script>
<head>
<body>
<canvas id="canvas" width="320" height="240"></canvas>
<script>
socket = io("http://localhost:9639");
var canvas = document.getElementById("canvas");
var ctx = canvas.getContext("2d");
var image = new Image();
image.onload = function() {
ctx.drawImage(image, 0, 0, 320, 240);
};
socket.on('frame', function (frame) {
image.src = "data:image/jpeg;base64," + frame;
});
</script>
</body>
</html>
FAQs
Capturing images from webcam and converting to rgb24. Linux only (v4l2)
The npm package linuxcam receives a total of 3 weekly downloads. As such, linuxcam popularity was classified as not popular.
We found that linuxcam demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.