Получение sf::Texture из фрейма OpenCV

This commit is contained in:
Alexander Popov 2024-03-07 21:42:16 +03:00
parent c844ea9749
commit 11209d13d5
1 changed files with 14 additions and 0 deletions

View File

@ -0,0 +1,14 @@
#include <SFML/Graphics.hpp>
#include <opencv2/opencv.hpp>
sf::Texture getTextureFromCvFrame(cv::Mat frame) {
cv::Mat frameRGBA;
sf::Image image;
sf::Texture texture;
cv::cvtColor(frame, frameRGBA, cv::COLOR_BGR2RGBA);
image.create(frameRGBA.cols, frameRGBA.rows, frameRGBA.ptr());
texture.loadFromImage(image);
return texture;
}