Use C++ openCV code into Windows Universal app in C#
Dear all, I am planning to do a Windows 10 Universal app. Into this app I want integrate part of my c++ OpenCV code. So I create a solution with a c# project and a windows c++ runtime component. So, now, I can call c++ code from c# app, this strategy work well, maybe is not the better, but work for my purpose. The c++ code into runtime component is very easy, just read frame from Webcam:
#include "Class1.h"
#include <core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include "opencv2/objdetect/objdetect.hpp"
#include <opencv2/imgproc.hpp>
using namespace WindowsRuntimeComponent1;
using namespace Platform;
using namespace cv;
using namespace std;
Mat cameraFrame;
Mat mGray;
Class1::Class1()
{
VideoCapture stream1(0);
Mat mGray;
while (true) {
stream1.read(cameraFrame);
cvtColor(cameraFrame, mGray, CV_RGB2GRAY);
//imshow("My Window", mGray);
if (waitKey(10) >= 0)
break;
}
}
For now, imshow is commented, I think that I can't use into C# app.
Now, I want show mGray Mat into an Image object into my c# app, this is my XAML:
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Image x:Name="imgCV" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Loaded="imgCV_Loaded"/>
</Grid>
as you can see I also add a Loaded event, but for now I don't code this event. I am stop here and I am not able to proceed. Can you help me? How can I show my mGray Mat into XAML object Image?
Thank you all, and happy new year.
I know nothing about universal application but it is an interesting thread. Have you try with this ?