OpenCV  4.5.1
Open Source Computer Vision
Enumerations | Functions
WinRT glue for video I/O

Enumerations

enum  {
  cv::OPEN_CAMERA = 300,
  cv::CLOSE_CAMERA,
  cv::UPDATE_IMAGE_ELEMENT,
  cv::SHOW_TRACKBAR
}
 

Functions

void cv::winrt_imshow ()
 
void cv::winrt_onVisibilityChanged (bool visible)
 
void cv::winrt_setFrameContainer (::Windows::UI::Xaml::Controls::Image^ image)
 
template<typename ... Args>
void cv::winrt_startMessageLoop (std::function< void(Args...)> &&callback, Args... args)
 
template<typename ... Args>
void cv::winrt_startMessageLoop (void callback(Args...), Args... args)
 
template void cv::winrt_startMessageLoop (void callback(void))
 

Detailed Description

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

#include <opencv2/videoio/cap_winrt.hpp>

Enumerator
OPEN_CAMERA 
CLOSE_CAMERA 
UPDATE_IMAGE_ELEMENT 
SHOW_TRACKBAR 

Function Documentation

◆ winrt_imshow()

void cv::winrt_imshow ( )

#include <opencv2/videoio/cap_winrt.hpp>

Note
Must be called to update attached image source. Code sample is available for winrt_startMessageLoop().

◆ winrt_onVisibilityChanged()

void cv::winrt_onVisibilityChanged ( bool  visible)

#include <opencv2/videoio/cap_winrt.hpp>

Note
Must be called from WinRT specific callback to handle image grabber state. Here is how the class can be used:
MainPage::MainPage()
{
// ...
Window::Current->VisibilityChanged += ref new Windows::UI::Xaml::WindowVisibilityChangedEventHandler(this, &Application::MainPage::OnVisibilityChanged);
// ...
}
void Application::MainPage::OnVisibilityChanged(Platform::Object ^sender,
Windows::UI::Core::VisibilityChangedEventArgs ^e)
{
}

◆ winrt_setFrameContainer()

void cv::winrt_setFrameContainer ( ::Windows::UI::Xaml::Controls::Image^  image)

#include <opencv2/videoio/cap_winrt.hpp>

Note
Must be called to assign WinRT control holding image you're working with. Code sample is available for winrt_startMessageLoop().

◆ winrt_startMessageLoop() [1/3]

template<typename ... Args>
void cv::winrt_startMessageLoop ( std::function< void(Args...)> &&  callback,
Args...  args 
)

◆ winrt_startMessageLoop() [2/3]

template<typename ... Args>
void cv::winrt_startMessageLoop ( void   callbackArgs...,
Args...  args 
)

◆ winrt_startMessageLoop() [3/3]

template void cv::winrt_startMessageLoop ( void   callbackvoid)

#include <opencv2/videoio/cap_winrt.hpp>

Note
Starts (1) frame-grabbing loop and (2) message loop
  1. Function passed as an argument must implement common OCV reading frames pattern (see cv::VideoCapture documentation) AND call cv::winrt_imgshow().
  2. Message processing loop required to overcome WinRT container and type conversion restrictions. OCV provides default implementation Here is how the class can be used:
    void cvMain()
    {
    Mat frame;
    VideoCapture cam;
    cam.open(0);
    while (1)
    {
    cam >> frame;
    // don't reprocess the same frame again
    if (!cam.grab()) continue;
    // your processing logic goes here
    // obligatory step to get XAML image component updated
    }
    }
    MainPage::MainPage()
    {
    InitializeComponent();
    }