- ducdanganhit
- Posts: 25
- Joined:
[C++, OpenCV] Display image CV::Mat queue as video in XAML
Hello,
I am implementing to show video on GUI from OpenCV cv::Mat. I have a queue of cv::Mat as video frames read from video.
How to show cv::mat into XAML GUI?
Any idea? or an example?
Thanks in advanced!
I am implementing to show video on GUI from OpenCV cv::Mat. I have a queue of cv::Mat as video frames read from video.
How to show cv::mat into XAML GUI?
Any idea? or an example?
Thanks in advanced!
Re: [C++, OpenCV] Display image CV::Mat queue as video in XAML
guess you would like to use cbimtmap ..
-
sfernandez
Site Admin
- Posts: 2991
- Joined:
Re: [C++, OpenCV] Display image CV::Mat queue as video in XAML
You need to create a texture that will be updated with that video frame data.
Then create a TextureSource from that texture and use it as image source of an Image (or ImageBrush).
You can take a look at our Images tutorial for more info: https://www.noesisengine.com/docs/Gui.C ... ime-images
Then create a TextureSource from that texture and use it as image source of an Image (or ImageBrush).
You can take a look at our Images tutorial for more info: https://www.noesisengine.com/docs/Gui.C ... ime-images
- ducdanganhit
- Posts: 25
- Joined:
Re: [C++, OpenCV] Display image CV::Mat queue as video in XAML
NIce suggestion. I will try it. Thank you very much.
Re: [C++, OpenCV] Display image CV::Mat queue as video in XAML
For example, If you are using D3D11 you can create a texture using an external handle with WrapTexture:
Code: Select all
struct NS_RENDER_D3D11RENDERDEVICE_API D3D11Factory
{
static Noesis::Ptr<Noesis::Texture> WrapTexture(ID3D11Texture2D* texture, uint32_t width,
uint32_t height, uint32_t levels, bool isInverted);
};
- ducdanganhit
- Posts: 25
- Joined:
Re: [C++, OpenCV] Display image CV::Mat queue as video in XAML
How to convert an image to ID3D11Texture2D* type or Cv::Mat to ID3D11Texture2D* or TextureSource? I have not made any games(need Unity?), so i cant understand how to do this.For example, If you are using D3D11 you can create a texture using an external handle with WrapTexture:Code: Select allstruct NS_RENDER_D3D11RENDERDEVICE_API D3D11Factory { static Noesis::Ptr<Noesis::Texture> WrapTexture(ID3D11Texture2D* texture, uint32_t width, uint32_t height, uint32_t levels, bool isInverted); };
- ducdanganhit
- Posts: 25
- Joined:
Re: [C++, OpenCV] Display image CV::Mat queue as video in XAML
I tried to convert from cv::Mat to ID3D11Texture2D* but got an error:
Main.cpp:58: undefined reference to `NoesisApp::D3D11Factory::WrapTexture(ID3D11Texture2D*, unsigned int, unsigned int, unsigned int, bool)'
This is my code:
I thought i was missing implementation of this header file "NoesisApp::D3D11Factory::WrapTexture"
I included the header /Src/Packages/Render/D3D11RenderDevice/Include/NsRender/D3D11Factory.h
I saw the implementation of "D3D11Factory::WrapTexture" in Src/Packages/Render/D3D11RenderDevice/Src/Render.D3D11RenderDevice.cpp. was it included in libNoesis.so or libNoesisApp.so? Or should i include "Render.D3D11RenderDevice.cpp" manually into project?
Thanks!
Main.cpp:58: undefined reference to `NoesisApp::D3D11Factory::WrapTexture(ID3D11Texture2D*, unsigned int, unsigned int, unsigned int, bool)'
This is my code:
Code: Select all
cv::Mat img = cv::imread("./photo_2018-12-25_23-49-35.jpg");
ID3D11Texture2D* d3dTexture;
cv::directx::convertToD3D11Texture2D(img, d3dTexture);
Ptr<Texture> texture = D3D11Factory::WrapTexture(d3dTexture, 512, 512, 1, false);
Image* image = this->FindName<Image>("image1");
image->SetSource(MakePtr<TextureSource>(texture));
I included the header /Src/Packages/Render/D3D11RenderDevice/Include/NsRender/D3D11Factory.h
I saw the implementation of "D3D11Factory::WrapTexture" in Src/Packages/Render/D3D11RenderDevice/Src/Render.D3D11RenderDevice.cpp. was it included in libNoesis.so or libNoesisApp.so? Or should i include "Render.D3D11RenderDevice.cpp" manually into project?
Thanks!
Re: [C++, OpenCV] Display image CV::Mat queue as video in XAML
Sorry, I have no idea what is "cv::Mat", you need probably to get assistance in other forums about it. That's not a NoesisGUI thing.I tried to convert from cv::Mat to ID3D11Texture2D* but got an error:
Main.cpp:58: undefined reference to `NoesisApp::D3D11Factory::WrapTexture(ID3D11Texture2D*, unsigned int, unsigned int, unsigned int, bool)'
All the source you see in our SDK is part of the application framework (libNoesisApp.so). You can use that code as reference to build your own integration with NoesisGUI.I saw the implementation of "D3D11Factory::WrapTexture" in Src/Packages/Render/D3D11RenderDevice/Src/Render.D3D11RenderDevice.cpp. was it included in libNoesis.so or libNoesisApp.so? Or should i include "Render.D3D11RenderDevice.cpp" manually into project?
- ducdanganhit
- Posts: 25
- Joined:
Re: [C++, OpenCV] Display image CV::Mat queue as video in XAML
Hi @jsantos,For example, If you are using D3D11 you can create a texture using an external handle with WrapTexture:Code: Select allstruct NS_RENDER_D3D11RENDERDEVICE_API D3D11Factory { static Noesis::Ptr<Noesis::Texture> WrapTexture(ID3D11Texture2D* texture, uint32_t width, uint32_t height, uint32_t levels, bool isInverted); };
I added #include <NsRender/D3D11Factory.h> to use WrapTexture in D3D11Factory. But i got this message:
Code: Select all
undefined reference to `NoesisApp::D3D11Factory::WrapTexture(ID3D11Texture2D*, unsigned int, unsigned int, unsigned int, bool)'
Thank you!
Re: [C++, OpenCV] Display image CV::Mat queue as video in XAML
If you search inside the code you will find the implementation in the D3D11RenderDevice.cpp file.It seems that the program could not find implementation of WrapTexture. does libNoesisApp.so or libNoesis.socontain WrapTexture implementation?
Thank you!
Who is online
Users browsing this forum: TommyDawkins and 22 guests