node-webcam icon indicating copy to clipboard operation
node-webcam copied to clipboard

Is it possible to use this without saving a file?

Open TheLogan opened this issue 4 years ago • 3 comments

I've tried playing around with saveShots, output and callbackReturn, but non of them seem to allow me to stop the saving of the photo as a file. I really only need the photo in memory though, so it's just unnecessary overhead for me.

TheLogan avatar Nov 08 '21 23:11 TheLogan

As far as I can tell, there isn't-- I think that the issue is that the way it gets the data is by running a command to save an image, then getting that images data-- here's a bit of a workaround that I find works, just delete the file that gets saved immediately. A bit annoying, but eh

const nw = require('node-webcam');
const fs = require('fs');

let cam = nw.create({
    callbackReturn: 'buffer'
});

cam.capture('delete', (err, data) => {
    if (err) {
        console.log(err);
    } else {
        // Data is buffer w/ image
        fs.unlinkSync('delete.jpg');
    }
});

Oman395 avatar Feb 04 '22 15:02 Oman395

ah dang, this is bad limitation as write/reads off a drive are obviously much slower then memory, wish the buffer option just returned the buffer without saving, kinda makes it pointless to even have the callback controls.

paulash avatar May 14 '23 23:05 paulash