Answer the question
In order to leave comments, you need to log in
Why are there so many delays in taking a photo?
Good afternoon to all DYI lovers,
I'm going to make a streaming video from a raspberry via the Internet (a prerequisite) with a minimum delay (to control the robot in real time). I went according to the scheme that I take a lot of pictures, they are constantly updated and the impression of a video is created, it seems like the best option.
Given: I
use Raspberry Pi 3b+
I put one of the standard cameras on it via a cable.
Deployed a node.js application
Connected the node-raspistill package
'use strict';
var express = require('express');
var router = express.Router();
var http = require("http");
const Raspistill = require('node-raspistill').Raspistill;
const camera = new Raspistill({
width: 640,
height: 480,
encoding: 'jpg'
});
/* GET home page. */
router.get('/', function (req, res) {
sendPhoto();
});
function sendPhoto(){
var startTime = new Date().getTime();
var options = {
hostname: '192.168.0.105',
port: '5000',
path: '/api/chat/push',
method: 'POST',
headers: {
'Content-Type': 'application/json'
}
};
var remoteReq = http.request(options);
camera.takePhoto().then((photo)=>{
var baseStrImg = photo.toString('base64');
var spanTime = (new Date().getTime() - startTime)/1000+'';
console.log(spanTime);
remoteReq.write(JSON.stringify({ message: baseStrImg, Time: spanTime}));
remoteReq.end();
sendPhoto();
});
}
module.exports = router;
Answer the question
In order to leave comments, you need to log in
That is, it camera.takePhoto()
takes more than 5 seconds? Try checking the snapshot time using the command in the terminal, writing to RAM, not to the SD card.
If it's still long, then there is hardly a better solution when working with raspistill.
I once made a mirroring program (left - right) for a laptop camera on DirectShow. The camera gave out 30 fps, all frames were processed at this speed. But one laptop (Samsung?) had lag and the other (HP?) didn't, so the laptop's camera driver is to blame. (the delay, of course, is not 5 seconds, but some fraction of a second, visible if you move your hand from side to side)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question