snipplets.dev/code/SFML/getTextureFromCvFrame.cpp

15 lines
347 B
C++
Raw Normal View History

#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;
}