@@ -38,7 +38,7 @@ def test_reader(self):
3838 # Pass VideoReaderInitParams to the decoder and initialization params to the source (cv::VideoCapture)
3939 params = cv .cudacodec .VideoReaderInitParams ()
4040 params .rawMode = True
41- params .enableHistogramOutput = True
41+ params .enableHistogram = False
4242 ms_gs = 1234
4343 post_processed_sz = (gpu_mat .size ()[0 ]* 2 , gpu_mat .size ()[1 ]* 2 )
4444 params .targetSz = post_processed_sz
@@ -48,14 +48,12 @@ def test_reader(self):
4848 ret , raw_mode = reader .getVideoReaderProps (cv .cudacodec .VideoReaderProps_PROP_RAW_MODE )
4949 self .assertTrue (ret and raw_mode )
5050
51- # Retrieve image histogram
51+ # Retrieve image histogram. Not all GPUs support histogram. Just check the method is called correctly
5252 ret , gpu_mat , hist = reader .nextFrameWithHist ()
53- self .assertTrue (ret and not gpu_mat .empty () and hist . size () == ( 256 , 1 ) )
53+ self .assertTrue (ret and not gpu_mat .empty ())
5454 ret , gpu_mat_ , hist_ = reader .nextFrameWithHist (gpu_mat , hist )
55- self .assertTrue (ret and not gpu_mat .empty () and hist .size () == (256 ,1 ))
56- self .assertTrue (gpu_mat_ .cudaPtr () == gpu_mat .cudaPtr () and hist_ .cudaPtr () == hist .cudaPtr ())
57- hist_host = cv .cudacodec .MapHist (hist )
58- self .assertTrue (hist_host .shape == (1 ,256 ) and isinstance (hist_host , np .ndarray ))
55+ self .assertTrue (ret and not gpu_mat .empty ())
56+ self .assertTrue (gpu_mat_ .cudaPtr () == gpu_mat .cudaPtr ())
5957
6058 # Check post processing applied
6159 self .assertTrue (gpu_mat .size () == post_processed_sz )
@@ -93,6 +91,12 @@ def test_reader(self):
9391 else :
9492 self .skipTest (e .err )
9593
94+ def test_map_histogram (self ):
95+ hist = cv .cuda_GpuMat ((1 ,256 ), cv .CV_8UC1 )
96+ hist .setTo (1 )
97+ hist_host = cv .cudacodec .MapHist (hist )
98+ self .assertTrue (hist_host .shape == (256 , 1 ) and isinstance (hist_host , np .ndarray ))
99+
96100 def test_writer (self ):
97101 # Test the functionality but not the results of the VideoWriter
98102
@@ -122,4 +126,4 @@ def test_writer(self):
122126 os .remove (fname )
123127
124128if __name__ == '__main__' :
125- NewOpenCVTests .bootstrap ()
129+ NewOpenCVTests .bootstrap ()
0 commit comments