• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Capture support for WinRT
2 
3 // Copyright (c) Microsoft Open Technologies, Inc.
4 // All rights reserved.
5 //
6 // (3 - clause BSD License)
7 //
8 // Redistribution and use in source and binary forms, with or without modification, are permitted provided that
9 // the following conditions are met:
10 //
11 // 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the
12 // following disclaimer.
13 // 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
14 // following disclaimer in the documentation and/or other materials provided with the distribution.
15 // 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or
16 // promote products derived from this software without specific prior written permission.
17 //
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
19 // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
20 // PARTICULAR PURPOSE ARE DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
21 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES(INCLUDING, BUT NOT LIMITED TO,
22 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT(INCLUDING
24 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 // POSSIBILITY OF SUCH DAMAGE.
26 
27 #pragma once
28 
29 #include "precomp.hpp"
30 
31 #include <mutex>
32 #include <memory>
33 #include <condition_variable>
34 #include <atomic>
35 
36 #include <agile.h>
37 
38 
39 // nb. implemented the newer IVideoCapture C++ interface so that we can work
40 // directly with Mat, not the older C cv interface
41 // (which may have added overhead for IPL file conversion)
42 
43 namespace cv {
44 
45     class VideoCapture_WinRT : public IVideoCapture
46     {
47     public:
VideoCapture_WinRT()48         VideoCapture_WinRT() : started(false) {}
49         VideoCapture_WinRT(int device);
~VideoCapture_WinRT()50         virtual ~VideoCapture_WinRT() {}
51 
52         // from base class IVideoCapture
getProperty(int)53         virtual double getProperty(int) { return 0; }
54         virtual bool setProperty(int, double);
55         virtual bool grabFrame();
56         virtual bool retrieveFrame(int channel, cv::OutputArray outArray);
57 
58         // Return the type of the capture object
getCaptureDomain()59         virtual int getCaptureDomain() { return CAP_WINRT; }
60 
61         virtual bool isOpened() const;
62 
63     protected:
64 
65         bool                    started;
66         CvSize                  size;
67         int                     bytesPerPixel;
68         unsigned long           frameCurrent;
69         std::atomic<bool>       isFrameNew;
70     };
71 }