Получение sf::Texture из фрейма OpenCV
This commit is contained in:
parent
c844ea9749
commit
11209d13d5
14
code/SFML/getTextureFromCvFrame.cpp
Normal file
14
code/SFML/getTextureFromCvFrame.cpp
Normal 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;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user