Commit 7cbe83f2 authored by cudawarped's avatar cudawarped Committed by Alexander Alekhin

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
parent 763a4516
...@@ -302,7 +302,7 @@ public: ...@@ -302,7 +302,7 @@ public:
If no frames has been grabbed (there are no more frames in video file), the methods return false . If no frames has been grabbed (there are no more frames in video file), the methods return false .
The method throws Exception if error occurs. The method throws Exception if error occurs.
*/ */
CV_WRAP virtual bool nextFrame(OutputArray frame, Stream &stream = Stream::Null()) = 0; CV_WRAP virtual bool nextFrame(CV_OUT GpuMat& frame, Stream &stream = Stream::Null()) = 0;
/** @brief Returns information about video file format. /** @brief Returns information about video file format.
*/ */
......
...@@ -60,7 +60,7 @@ ...@@ -60,7 +60,7 @@
using namespace cv; using namespace cv;
using namespace cv::cudev; using namespace cv::cudev;
void videoDecPostProcessFrame(const GpuMat& decodedFrame, OutputArray _outFrame, int width, int height, cudaStream_t stream); void videoDecPostProcessFrame(const GpuMat& decodedFrame, GpuMat& _outFrame, int width, int height, cudaStream_t stream);
namespace namespace
{ {
...@@ -186,12 +186,11 @@ namespace ...@@ -186,12 +186,11 @@ namespace
} }
} }
void videoDecPostProcessFrame(const GpuMat& decodedFrame, OutputArray _outFrame, int width, int height, cudaStream_t stream) void videoDecPostProcessFrame(const GpuMat& decodedFrame, GpuMat& outFrame, int width, int height, cudaStream_t stream)
{ {
// Final Stage: NV12toARGB color space conversion // Final Stage: NV12toARGB color space conversion
_outFrame.create(height, width, CV_8UC4); outFrame.create(height, width, CV_8UC4);
GpuMat outFrame = _outFrame.getGpuMat();
dim3 block(32, 8); dim3 block(32, 8);
dim3 grid(divUp(width, 2 * block.x), divUp(height, block.y)); dim3 grid(divUp(width, 2 * block.x), divUp(height, block.y));
......
...@@ -53,7 +53,7 @@ Ptr<VideoReader> cv::cudacodec::createVideoReader(const Ptr<RawVideoSource>&) { ...@@ -53,7 +53,7 @@ Ptr<VideoReader> cv::cudacodec::createVideoReader(const Ptr<RawVideoSource>&) {
#else // HAVE_NVCUVID #else // HAVE_NVCUVID
void videoDecPostProcessFrame(const GpuMat& decodedFrame, OutputArray _outFrame, int width, int height, cudaStream_t stream); void videoDecPostProcessFrame(const GpuMat& decodedFrame, GpuMat& _outFrame, int width, int height, cudaStream_t stream);
using namespace cv::cudacodec::detail; using namespace cv::cudacodec::detail;
...@@ -65,7 +65,7 @@ namespace ...@@ -65,7 +65,7 @@ namespace
explicit VideoReaderImpl(const Ptr<VideoSource>& source); explicit VideoReaderImpl(const Ptr<VideoSource>& source);
~VideoReaderImpl(); ~VideoReaderImpl();
bool nextFrame(OutputArray frame, Stream& stream) CV_OVERRIDE; bool nextFrame(GpuMat& frame, Stream& stream) CV_OVERRIDE;
FormatInfo format() const CV_OVERRIDE; FormatInfo format() const CV_OVERRIDE;
...@@ -122,7 +122,7 @@ namespace ...@@ -122,7 +122,7 @@ namespace
CUvideoctxlock m_lock; CUvideoctxlock m_lock;
}; };
bool VideoReaderImpl::nextFrame(OutputArray frame, Stream& stream) bool VideoReaderImpl::nextFrame(GpuMat& frame, Stream& stream)
{ {
if (videoSource_->hasError() || videoParser_->hasError()) if (videoSource_->hasError() || videoParser_->hasError())
CV_Error(Error::StsUnsupportedFormat, "Unsupported video source"); CV_Error(Error::StsUnsupportedFormat, "Unsupported video source");
......
...@@ -123,8 +123,7 @@ CUDA_TEST_P(Video, Writer) ...@@ -123,8 +123,7 @@ CUDA_TEST_P(Video, Writer)
#endif // _WIN32, HAVE_NVCUVENC #endif // _WIN32, HAVE_NVCUVENC
#define VIDEO_SRC "gpu/video/768x576.avi", "gpu/video/1920x1080.avi", "highgui/video/big_buck_bunny.avi", \ #define VIDEO_SRC "gpu/video/768x576.avi", "gpu/video/1920x1080.avi", "highgui/video/big_buck_bunny.avi", \
"highgui/video/big_buck_bunny.h264", "highgui/video/big_buck_bunny.h265", "highgui/video/big_buck_bunny.mpg", \ "highgui/video/big_buck_bunny.h264", "highgui/video/big_buck_bunny.h265", "highgui/video/big_buck_bunny.mpg"
"highgui/video/big_buck_bunny.mpg"
INSTANTIATE_TEST_CASE_P(CUDA_Codec, Video, testing::Combine( INSTANTIATE_TEST_CASE_P(CUDA_Codec, Video, testing::Combine(
ALL_DEVICES, ALL_DEVICES,
testing::Values(VIDEO_SRC))); testing::Values(VIDEO_SRC)));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment