Может ли кто-нибудь помочь мне решить проблему в моем коде? Короче говоря, идея состоит в том, чтобы прочитать веб-камеру /dev/video0, вставить фоновое изображение (jpg, png обои) и отправить его в /dev/video2.
Я использую v4l2loopback .
modprobe v4l2loopback video_nr=2 devices=1 card_label="Виртуальная камера"exclusive_caps=0 Keep_format=1
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
struct Buffer {
void *start;
size_t length;
};
struct CameraInfo {
int width;
int height;
__u32 pixelFormat;
};
std::atomic running{true};
void applyBackground(const cv::Mat &foreground, const cv::Mat &background, cv::Mat &output) {
output = foreground.clone();
for (int i = 0; i < foreground.rows; ++i) {
for (int j = 0; j < foreground.cols; ++j) {
cv::Vec3b pixel = foreground.at(i, j);
cv::Vec3b bgPixel = background.at(i, j);
if (pixel[0] < 50 && pixel[1] < 50 && pixel[2] < 50) {
output.at(i, j) = bgPixel;
} else {
output.at(i, j)[0] = (pixel[0] * 0.7 + bgPixel[0] * 0.3);
output.at(i, j)[1] = (pixel[1] * 0.7 + bgPixel[1] * 0.3);
output.at(i, j)[2] = (pixel[2] * 0.7 + bgPixel[2] * 0.3);
}
}
}
}
cv::Mat loadBackground(const std::string &path, int width, int height) {
cv::Mat bg = cv::imread(path);
if (bg.empty()) {
std::cerr
Подробнее здесь: https://stackoverflow.com/questions/792 ... her-device
Захватите изображение с веб-камеры, поместите фоновое изображение и отправьте его на другое устройство. ⇐ C++
Программы на C++. Форум разработчиков
1732926207
Anonymous
Может ли кто-нибудь помочь мне решить проблему в моем коде? Короче говоря, идея состоит в том, чтобы прочитать веб-камеру /dev/video0, вставить фоновое изображение (jpg, png обои) и отправить его в /dev/video2.
Я использую v4l2loopback .
modprobe v4l2loopback video_nr=2 devices=1 card_label="Виртуальная камера"exclusive_caps=0 Keep_format=1
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
struct Buffer {
void *start;
size_t length;
};
struct CameraInfo {
int width;
int height;
__u32 pixelFormat;
};
std::atomic running{true};
void applyBackground(const cv::Mat &foreground, const cv::Mat &background, cv::Mat &output) {
output = foreground.clone();
for (int i = 0; i < foreground.rows; ++i) {
for (int j = 0; j < foreground.cols; ++j) {
cv::Vec3b pixel = foreground.at(i, j);
cv::Vec3b bgPixel = background.at(i, j);
if (pixel[0] < 50 && pixel[1] < 50 && pixel[2] < 50) {
output.at(i, j) = bgPixel;
} else {
output.at(i, j)[0] = (pixel[0] * 0.7 + bgPixel[0] * 0.3);
output.at(i, j)[1] = (pixel[1] * 0.7 + bgPixel[1] * 0.3);
output.at(i, j)[2] = (pixel[2] * 0.7 + bgPixel[2] * 0.3);
}
}
}
}
cv::Mat loadBackground(const std::string &path, int width, int height) {
cv::Mat bg = cv::imread(path);
if (bg.empty()) {
std::cerr
Подробнее здесь: [url]https://stackoverflow.com/questions/79238633/capture-webcam-image-and-put-background-image-and-sent-to-other-device[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия