ducdanganhit
Topic Author
Posts: 25
Joined: 18 May 2019, 10:46

[C++, OpenCV] Display image CV::Mat queue as video in XAML

06 Jun 2019, 12:29

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!
 
whidbey
Posts: 49
Joined: 26 May 2019, 07:16

Re: [C++, OpenCV] Display image CV::Mat queue as video in XAML

06 Jun 2019, 15:48

guess you would like to use cbimtmap ..
 
User avatar
sfernandez
Site Admin
Posts: 3008
Joined: 22 Dec 2011, 19:20

Re: [C++, OpenCV] Display image CV::Mat queue as video in XAML

06 Jun 2019, 18:23

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
 
ducdanganhit
Topic Author
Posts: 25
Joined: 18 May 2019, 10:46

Re: [C++, OpenCV] Display image CV::Mat queue as video in XAML

07 Jun 2019, 04:39

NIce suggestion. I will try it. Thank you very much.
 
User avatar
jsantos
Site Admin
Posts: 3939
Joined: 20 Jan 2012, 17:18
Contact:

Re: [C++, OpenCV] Display image CV::Mat queue as video in XAML

10 Jun 2019, 12:56

For example, If you are using D3D11 you can create a texture using an external handle with WrapTexture:
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
Topic Author
Posts: 25
Joined: 18 May 2019, 10:46

Re: [C++, OpenCV] Display image CV::Mat queue as video in XAML

13 Jun 2019, 05:29

For example, If you are using D3D11 you can create a texture using an external handle with WrapTexture:
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);
};
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.
 
ducdanganhit
Topic Author
Posts: 25
Joined: 18 May 2019, 10:46

Re: [C++, OpenCV] Display image CV::Mat queue as video in XAML

14 Jun 2019, 09:49

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:
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 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!
 
User avatar
jsantos
Site Admin
Posts: 3939
Joined: 20 Jan 2012, 17:18
Contact:

Re: [C++, OpenCV] Display image CV::Mat queue as video in XAML

14 Jun 2019, 14:24

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)'
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 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?
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.
 
ducdanganhit
Topic Author
Posts: 25
Joined: 18 May 2019, 10:46

Re: [C++, OpenCV] Display image CV::Mat queue as video in XAML

17 Jun 2019, 05:21

For example, If you are using D3D11 you can create a texture using an external handle with WrapTexture:
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);
};
Hi @jsantos,
I added #include <NsRender/D3D11Factory.h> to use WrapTexture in D3D11Factory. But i got this message:
undefined reference to `NoesisApp::D3D11Factory::WrapTexture(ID3D11Texture2D*, unsigned int, unsigned int, unsigned int, bool)'
It seems that the program could not find implementation of WrapTexture. does libNoesisApp.so or libNoesis.socontain WrapTexture implementation?
Thank you!
 
User avatar
jsantos
Site Admin
Posts: 3939
Joined: 20 Jan 2012, 17:18
Contact:

Re: [C++, OpenCV] Display image CV::Mat queue as video in XAML

18 Jun 2019, 16:55

It seems that the program could not find implementation of WrapTexture. does libNoesisApp.so or libNoesis.socontain WrapTexture implementation?
Thank you!
If you search inside the code you will find the implementation in the D3D11RenderDevice.cpp file.

Who is online

Users browsing this forum: Bing [Bot], ersenal and 7 guests