UWARG Computer Vision
DeckLinkCapture.h
1 /*
2  * DeckLinkCapture.h - Clase para capturar vídeo desde dispositivos DeckLink
3  *
4  * Copyright 2013 Jesús Torres <jmtorres@ull.es>
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 
19 #ifndef DECKLINKCAPTURE_H_
20 #define DECKLINKCAPTURE_H_
21 
22 #include <opencv2/core/core.hpp>
23 #include <opencv2/highgui/highgui.hpp>
24 
25 #include <DeckLinkAPI.h>
26 
27 #include "ComPtr.h"
28 #include "DeckLinkInputCallback.h"
29 
31 {
32  public:
34  DeckLinkCapture(DeckLinkCapture&& other) noexcept;
35  ~DeckLinkCapture();
36 
37  DeckLinkCapture& operator=(DeckLinkCapture&& other) noexcept;
38 
39  // Mirar en DeckLinkApiMode.h para ver los modos soportados
40  // DeckLinkApiMode.h look at to see the modes supported
41  bool doesSupportVideoMode(BMDDisplayMode displayMode,
42  BMDPixelFormat pixelFormat);
43 
44  std::string getDeviceModelName();
45  std::string getDeviceDisplayName();
46 
47  bool start(BMDDisplayMode displayMode = bmdModeHD1080p30, //FIXME: THIS CHANGES BASED ON THE DEVICE: CHECK THE DeckLinkAPIModes.h file and the BlackMagic Desktop Utility to get the input display mode
48  BMDPixelFormat pixelFormat = bmdFormat8BitYUV);
49  void stop();
50 
51  bool grab();
52  bool retrieve(cv::Mat& videoFrame);
53 
54  bool read(cv::Mat& videoFrame);
55  DeckLinkCapture& operator>>(cv::Mat& videoFrame);
56 
57  HRESULT error() const;
58  const std::string& errorString() const;
59 
60  private:
61  ComPtr<IDeckLink> deckLink_;
62  ComPtr<IDeckLinkInput> deckLinkInput_;
63  ComPtr<DeckLinkInputCallback> deckLinkInputCallback_;
64  ComPtr<IDeckLinkVideoInputFrame> grabbedVideoFrame_;
65 
66  HRESULT error_;
67  std::string errorString_;
68 
69  friend HRESULT DeckLinkInputCallback::VideoInputFrameArrived(
70  IDeckLinkVideoInputFrame* videoFrame,
71  IDeckLinkAudioInputPacket* audioPacket);
72 
73  DeckLinkCapture(DeckLinkCapture const&) = delete;
74  DeckLinkCapture& operator=(DeckLinkCapture const&) = delete;
75 };
76 
77 inline HRESULT DeckLinkCapture::error() const
78 {
79  return error_;
80 }
81 
82 inline const std::string& DeckLinkCapture::errorString() const
83 {
84  return errorString_;
85 }
86 
87 #endif /* DECKLINKCAPTURE_H_ */
Definition: DeckLinkCapture.h:30