Skip to content

Commit 7cbe83f

Browse files
cudawarpedalalek
authored andcommitted
Merge pull request #2362 from cudawarped:fix_cudacodec_python
Fix cudacodec::VideoReader::nextFrame python bindings * Signla to python bindings generator that nextFrame's OutputArray is a GpuMat. Also remove duplicate test in cudacodec * cudacodec: drop CV_GPU, wrap GpuMat only * Make it explicit that frame in nextFrame is GpuMat and cannot be multiple types as implied by OutputArray
1 parent 763a451 commit 7cbe83f

File tree

4 files changed

+8
-10
lines changed

4 files changed

+8
-10
lines changed

modules/cudacodec/include/opencv2/cudacodec.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ class CV_EXPORTS_W VideoReader
302302
If no frames has been grabbed (there are no more frames in video file), the methods return false .
303303
The method throws Exception if error occurs.
304304
*/
305-
CV_WRAP virtual bool nextFrame(OutputArray frame, Stream &stream = Stream::Null()) = 0;
305+
CV_WRAP virtual bool nextFrame(CV_OUT GpuMat& frame, Stream &stream = Stream::Null()) = 0;
306306

307307
/** @brief Returns information about video file format.
308308
*/

modules/cudacodec/src/cuda/nv12_to_rgb.cu

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
using namespace cv;
6161
using namespace cv::cudev;
6262

63-
void videoDecPostProcessFrame(const GpuMat& decodedFrame, OutputArray _outFrame, int width, int height, cudaStream_t stream);
63+
void videoDecPostProcessFrame(const GpuMat& decodedFrame, GpuMat& _outFrame, int width, int height, cudaStream_t stream);
6464

6565
namespace
6666
{
@@ -186,12 +186,11 @@ namespace
186186
}
187187
}
188188

189-
void videoDecPostProcessFrame(const GpuMat& decodedFrame, OutputArray _outFrame, int width, int height, cudaStream_t stream)
189+
void videoDecPostProcessFrame(const GpuMat& decodedFrame, GpuMat& outFrame, int width, int height, cudaStream_t stream)
190190
{
191191
// Final Stage: NV12toARGB color space conversion
192192

193-
_outFrame.create(height, width, CV_8UC4);
194-
GpuMat outFrame = _outFrame.getGpuMat();
193+
outFrame.create(height, width, CV_8UC4);
195194

196195
dim3 block(32, 8);
197196
dim3 grid(divUp(width, 2 * block.x), divUp(height, block.y));

modules/cudacodec/src/video_reader.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Ptr<VideoReader> cv::cudacodec::createVideoReader(const Ptr<RawVideoSource>&) {
5353

5454
#else // HAVE_NVCUVID
5555

56-
void videoDecPostProcessFrame(const GpuMat& decodedFrame, OutputArray _outFrame, int width, int height, cudaStream_t stream);
56+
void videoDecPostProcessFrame(const GpuMat& decodedFrame, GpuMat& _outFrame, int width, int height, cudaStream_t stream);
5757

5858
using namespace cv::cudacodec::detail;
5959

@@ -65,7 +65,7 @@ namespace
6565
explicit VideoReaderImpl(const Ptr<VideoSource>& source);
6666
~VideoReaderImpl();
6767

68-
bool nextFrame(OutputArray frame, Stream& stream) CV_OVERRIDE;
68+
bool nextFrame(GpuMat& frame, Stream& stream) CV_OVERRIDE;
6969

7070
FormatInfo format() const CV_OVERRIDE;
7171

@@ -122,7 +122,7 @@ namespace
122122
CUvideoctxlock m_lock;
123123
};
124124

125-
bool VideoReaderImpl::nextFrame(OutputArray frame, Stream& stream)
125+
bool VideoReaderImpl::nextFrame(GpuMat& frame, Stream& stream)
126126
{
127127
if (videoSource_->hasError() || videoParser_->hasError())
128128
CV_Error(Error::StsUnsupportedFormat, "Unsupported video source");

modules/cudacodec/test/test_video.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,7 @@ CUDA_TEST_P(Video, Writer)
123123
#endif // _WIN32, HAVE_NVCUVENC
124124

125125
#define VIDEO_SRC "gpu/video/768x576.avi", "gpu/video/1920x1080.avi", "highgui/video/big_buck_bunny.avi", \
126-
"highgui/video/big_buck_bunny.h264", "highgui/video/big_buck_bunny.h265", "highgui/video/big_buck_bunny.mpg", \
127-
"highgui/video/big_buck_bunny.mpg"
126+
"highgui/video/big_buck_bunny.h264", "highgui/video/big_buck_bunny.h265", "highgui/video/big_buck_bunny.mpg"
128127
INSTANTIATE_TEST_CASE_P(CUDA_Codec, Video, testing::Combine(
129128
ALL_DEVICES,
130129
testing::Values(VIDEO_SRC)));

0 commit comments

Comments
 (0)