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

Imencode - OpenCV Error: (!image.empty()) in imencode, in file... RPI4 #859

Open
evgeniy-bondarenk0 opened this issue Oct 30, 2022 · 1 comment

Comments

@evgeniy-bondarenk0
Copy link

evgeniy-bondarenk0 commented Oct 30, 2022

Hello. I'm trying to get a video stream behind the cameras on the RPI 4, but I'm getting the following error:
photo_2022-10-30_14-31-08

Using the libcamera-hello command, the image is displayed. I suspect there may be an error in the camera's image format.
photo_2022-10-30_14-34-31

Platform: Raspbian Bullseye 11 (32-bit)
OpenCV: v4.5.5
NodeJS: v16

My code:
const cv2 = require('@u4/opencv4nodejs');
const path = require('path');
const express = require('express');
const app = express();
const server = require('http').Server(app);
const io = require('socket.io')(server);

app.set('view engine', 'ejs');
const FPS = 30;
const Vcap = new cv2.VideoCapture(0);
Vcap.set(cv2.CAP_PROP_FRAME_WIDTH, 300);
Vcap.set(cv2.CAP_PROP_FRAME_HEIGHT, 300);

app.get('/', async(req, res, next) => {
res.render('index');
});
let frame;
setInterval(() => {
frame = Vcap.read()
const image = cv2.imencode('.jpg', frame).toString('base64')
io.emit('image', image);
}, 1000 / FPS);
server.listen(3030, () => console.log('open up your browser'));

@piercus
Copy link
Collaborator

piercus commented Nov 8, 2022

This repository is not maintained anymore, please use @u4/opencv4nodejs for a more active fork

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

2 participants