Path: blob/master/modules/videoio/src/cap_winrt_video.hpp
16356 views
// Video support with XAML12// Copyright (c) Microsoft Open Technologies, Inc.3// All rights reserved.4//5// (3 - clause BSD License)6//7// Redistribution and use in source and binary forms, with or without modification, are permitted provided that8// the following conditions are met:9//10// 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the11// following disclaimer.12// 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the13// following disclaimer in the documentation and/or other materials provided with the distribution.14// 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or15// promote products derived from this software without specific prior written permission.16//17// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED18// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A19// PARTICULAR PURPOSE ARE DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY20// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES(INCLUDING, BUT NOT LIMITED TO,21// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)22// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT(INCLUDING23// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE24// POSSIBILITY OF SUCH DAMAGE.2526#pragma once2728#include "cap_winrt/CaptureFrameGrabber.hpp"2930#include <mutex>31#include <memory>3233class Video {34public:3536// non-blocking37bool initGrabber(int device, int w, int h);38void closeGrabber();39bool isStarted();4041// singleton42static Video &getInstance();4344void CopyOutput();4546private:47// singleton48Video();4950void _GrabFrameAsync(::Media::CaptureFrameGrabber^ frameGrabber);5152bool listDevices();5354Platform::Agile<Windows::Media::Capture::MediaCapture> m_capture;55Platform::Agile<Windows::Devices::Enumeration::DeviceInformationCollection> m_devices;5657::Media::CaptureFrameGrabber^ m_frameGrabber;5859bool listDevicesTask();6061bool bChooseDevice;62bool bVerbose;63bool bFlipImageX;64//std::atomic<bool> bGrabberInited;65int m_deviceID;66int attemptFramerate;67std::atomic<bool> bIsFrameNew;68std::atomic<bool> bGrabberInited;69std::atomic<bool> bGrabberInitInProgress;70unsigned int width, height;71int bytesPerPixel;7273};7475