Skip to content

Commit 582fe44

Browse files
committed
NVIDIA_OPTICAL_FLOW_2_0_INTEGRATION
1 parent 0b6b8ff commit 582fe44

File tree

9 files changed

+1238
-110
lines changed

9 files changed

+1238
-110
lines changed

modules/cudaoptflow/CMakeLists.txt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,21 @@ ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4127 /wd4324 /wd4512 -Wundef -Wmissing-d
88

99
ocv_define_module(cudaoptflow opencv_video opencv_optflow opencv_cudaarithm opencv_cudawarping opencv_cudaimgproc OPTIONAL opencv_cudalegacy WRAP python)
1010

11-
set(NVIDIA_OPTICAL_FLOW_1_0_HEADERS_COMMIT "79c6cee80a2df9a196f20afd6b598a9810964c32")
12-
set(NVIDIA_OPTICAL_FLOW_1_0_HEADERS_MD5 "ca5acedee6cb45d0ec610a6732de5c15")
13-
set(NVIDIA_OPTICAL_FLOW_1_0_HEADERS_PATH "${OpenCV_BINARY_DIR}/3rdparty/NVIDIAOpticalFlowSDK_1_0_Headers")
14-
ocv_download(FILENAME "${NVIDIA_OPTICAL_FLOW_1_0_HEADERS_COMMIT}.zip"
15-
HASH ${NVIDIA_OPTICAL_FLOW_1_0_HEADERS_MD5}
11+
set(NVIDIA_OPTICAL_FLOW_2_0_HEADERS_COMMIT "edb50da3cf849840d680249aa6dbef248ebce2ca")
12+
set(NVIDIA_OPTICAL_FLOW_2_0_HEADERS_MD5 "a73cd48b18dcc0cc8933b30796074191")
13+
set(NVIDIA_OPTICAL_FLOW_2_0_HEADERS_PATH "${OpenCV_BINARY_DIR}/3rdparty/NVIDIAOpticalFlowSDK_2_0_Headers")
14+
ocv_download(FILENAME "${NVIDIA_OPTICAL_FLOW_2_0_HEADERS_COMMIT}.zip"
15+
HASH ${NVIDIA_OPTICAL_FLOW_2_0_HEADERS_MD5}
1616
URL
1717
"https://github.com/NVIDIA/NVIDIAOpticalFlowSDK/archive/"
18-
DESTINATION_DIR "${NVIDIA_OPTICAL_FLOW_1_0_HEADERS_PATH}"
19-
STATUS NVIDIA_OPTICAL_FLOW_1_0_HEADERS_DOWNLOAD_SUCCESS
18+
DESTINATION_DIR "${NVIDIA_OPTICAL_FLOW_2_0_HEADERS_PATH}"
19+
STATUS NVIDIA_OPTICAL_FLOW_2_0_HEADERS_DOWNLOAD_SUCCESS
2020
ID "NVIDIA_OPTICAL_FLOW"
2121
UNPACK RELATIVE_URL)
2222

23-
if(NOT NVIDIA_OPTICAL_FLOW_1_0_HEADERS_DOWNLOAD_SUCCESS)
24-
message(STATUS "Failed to download NVIDIA_Optical_Flow_1_0 Headers")
23+
if(NOT NVIDIA_OPTICAL_FLOW_2_0_HEADERS_DOWNLOAD_SUCCESS)
24+
message(STATUS "Failed to download NVIDIA_Optical_Flow_2_0 Headers")
2525
else()
2626
add_definitions(-DHAVE_NVIDIA_OPTFLOW=1)
27-
ocv_include_directories(SYSTEM "${NVIDIA_OPTICAL_FLOW_1_0_HEADERS_PATH}/NVIDIAOpticalFlowSDK-${NVIDIA_OPTICAL_FLOW_1_0_HEADERS_COMMIT}")
27+
ocv_include_directories(SYSTEM "${NVIDIA_OPTICAL_FLOW_2_0_HEADERS_PATH}/NVIDIAOpticalFlowSDK-${NVIDIA_OPTICAL_FLOW_2_0_HEADERS_COMMIT}")
2828
endif()

modules/cudaoptflow/include/opencv2/cudaoptflow.hpp

Lines changed: 140 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -392,9 +392,9 @@ class CV_EXPORTS_W OpticalFlowDual_TVL1 : public DenseOpticalFlow
392392
/** @brief Class for computing the optical flow vectors between two images using NVIDIA Optical Flow hardware and Optical Flow SDK 1.0.
393393
@note
394394
- A sample application demonstrating the use of NVIDIA Optical Flow can be found at
395-
opencv_source_code/samples/gpu/nvidia_optical_flow.cpp
395+
opencv_contrib_source_code/modules/cudaoptflow/samples/nvidia_optical_flow.cpp
396396
- An example application comparing accuracy and performance of NVIDIA Optical Flow with other optical flow algorithms in OpenCV can be found at
397-
opencv_source_code/samples/gpu/optical_flow.cpp
397+
opencv_contrib_source_code/modules/cudaoptflow/samples/optical_flow.cpp
398398
*/
399399

400400
class CV_EXPORTS_W NvidiaOpticalFlow_1_0 : public NvidiaHWOpticalFlow
@@ -417,18 +417,16 @@ class CV_EXPORTS_W NvidiaOpticalFlow_1_0 : public NvidiaHWOpticalFlow
417417
* using nearest neighbour upsampling method.
418418
419419
@param flow Buffer of type CV_16FC2 containing flow vectors generated by calc().
420-
@param width Width of the input image in pixels for which these flow vectors were generated.
421-
@param height Height of the input image in pixels for which these flow vectors were generated.
420+
@param imageSize Size of the input image in pixels for which these flow vectors were generated.
422421
@param gridSize Granularity of the optical flow vectors returned by calc() function. Can be queried using getGridSize().
423422
@param upsampledFlow Buffer of type CV_32FC2, containing upsampled flow vectors, each flow vector for 1 pixel, in the pitch-linear layout.
424423
*/
425-
CV_WRAP virtual void upSampler(InputArray flow, int width, int height,
424+
CV_WRAP virtual void upSampler(InputArray flow, cv::Size imageSize,
426425
int gridSize, InputOutputArray upsampledFlow) = 0;
427426

428427
/** @brief Instantiate NVIDIA Optical Flow
429428
430-
@param width Width of input image in pixels.
431-
@param height Height of input image in pixels.
429+
@param imageSize Size of input image in pixels.
432430
@param perfPreset Optional parameter. Refer [NV OF SDK documentation](https://developer.nvidia.com/opticalflow-sdk) for details about presets.
433431
Defaults to NV_OF_PERF_LEVEL_SLOW.
434432
@param enableTemporalHints Optional parameter. Flag to enable temporal hints. When set to true, the hardware uses the flow vectors
@@ -445,10 +443,142 @@ class CV_EXPORTS_W NvidiaOpticalFlow_1_0 : public NvidiaHWOpticalFlow
445443
If output stream is not set, the execute function will use default stream which is NULL stream;
446444
*/
447445
CV_WRAP static Ptr<NvidiaOpticalFlow_1_0> create(
448-
int width,
449-
int height,
446+
cv::Size imageSize,
450447
cv::cuda::NvidiaOpticalFlow_1_0::NVIDIA_OF_PERF_LEVEL perfPreset
451-
= cv::cuda::NvidiaOpticalFlow_1_0::NVIDIA_OF_PERF_LEVEL::NV_OF_PERF_LEVEL_SLOW,
448+
= cv::cuda::NvidiaOpticalFlow_1_0::NV_OF_PERF_LEVEL_SLOW,
449+
bool enableTemporalHints = false,
450+
bool enableExternalHints = false,
451+
bool enableCostBuffer = false,
452+
int gpuId = 0,
453+
Stream& inputStream = Stream::Null(),
454+
Stream& outputStream = Stream::Null());
455+
};
456+
457+
/** @brief Class for computing the optical flow vectors between two images using NVIDIA Optical Flow hardware and Optical Flow SDK 2.0.
458+
@note
459+
- A sample application demonstrating the use of NVIDIA Optical Flow can be found at
460+
opencv_contrib_source_code/modules/cudaoptflow/samples/nvidia_optical_flow.cpp
461+
- An example application comparing accuracy and performance of NVIDIA Optical Flow with other optical flow algorithms in OpenCV can be found at
462+
opencv_contrib_source_code/modules/cudaoptflow/samples/optical_flow.cpp
463+
*/
464+
465+
class CV_EXPORTS_W NvidiaOpticalFlow_2_0 : public NvidiaHWOpticalFlow
466+
{
467+
public:
468+
/**
469+
* Supported optical flow performance levels.
470+
*/
471+
enum NVIDIA_OF_PERF_LEVEL
472+
{
473+
NV_OF_PERF_LEVEL_UNDEFINED,
474+
NV_OF_PERF_LEVEL_SLOW = 5, /**< Slow perf level results in lowest performance and best quality */
475+
NV_OF_PERF_LEVEL_MEDIUM = 10, /**< Medium perf level results in low performance and medium quality */
476+
NV_OF_PERF_LEVEL_FAST = 20, /**< Fast perf level results in high performance and low quality */
477+
NV_OF_PERF_LEVEL_MAX
478+
};
479+
480+
/**
481+
* Supported grid size for output buffer.
482+
*/
483+
enum NVIDIA_OF_OUTPUT_VECTOR_GRID_SIZE
484+
{
485+
NV_OF_OUTPUT_VECTOR_GRID_SIZE_UNDEFINED,
486+
NV_OF_OUTPUT_VECTOR_GRID_SIZE_1 = 1, /**< Output buffer grid size is 1x1 */
487+
NV_OF_OUTPUT_VECTOR_GRID_SIZE_2 = 2, /**< Output buffer grid size is 2x2 */
488+
NV_OF_OUTPUT_VECTOR_GRID_SIZE_4 = 4, /**< Output buffer grid size is 4x4 */
489+
NV_OF_OUTPUT_VECTOR_GRID_SIZE_MAX
490+
};
491+
492+
/**
493+
* Supported grid size for hint buffer.
494+
*/
495+
enum NVIDIA_OF_HINT_VECTOR_GRID_SIZE
496+
{
497+
NV_OF_HINT_VECTOR_GRID_SIZE_UNDEFINED,
498+
NV_OF_HINT_VECTOR_GRID_SIZE_1 = 1, /**< Hint buffer grid size is 1x1.*/
499+
NV_OF_HINT_VECTOR_GRID_SIZE_2 = 2, /**< Hint buffer grid size is 2x2.*/
500+
NV_OF_HINT_VECTOR_GRID_SIZE_4 = 4, /**< Hint buffer grid size is 4x4.*/
501+
NV_OF_HINT_VECTOR_GRID_SIZE_8 = 8, /**< Hint buffer grid size is 8x8.*/
502+
NV_OF_HINT_VECTOR_GRID_SIZE_MAX
503+
};
504+
505+
/** @brief convertToFloat() helper function converts the hardware-generated flow vectors to floating point representation (1 flow vector for gridSize).
506+
* gridSize can be queried via function getGridSize().
507+
508+
@param flow Buffer of type CV_16FC2 containing flow vectors generated by calc().
509+
@param floatFlow Buffer of type CV_32FC2, containing flow vectors in floating point representation, each flow vector for 1 pixel per gridSize, in the pitch-linear layout.
510+
*/
511+
CV_WRAP virtual void convertToFloat(InputArray flow, InputOutputArray floatFlow) = 0;
512+
513+
/** @brief Instantiate NVIDIA Optical Flow
514+
515+
@param imageSize Size of input image in pixels.
516+
@param perfPreset Optional parameter. Refer [NV OF SDK documentation](https://developer.nvidia.com/opticalflow-sdk) for details about presets.
517+
Defaults to NV_OF_PERF_LEVEL_SLOW.
518+
@param outputGridSize Optional parameter. Refer [NV OF SDK documentation](https://developer.nvidia.com/opticalflow-sdk) for details about output grid sizes.
519+
Defaults to NV_OF_OUTPUT_VECTOR_GRID_SIZE_1.
520+
@param hintGridSize Optional parameter. Refer [NV OF SDK documentation](https://developer.nvidia.com/opticalflow-sdk) for details about hint grid sizes.
521+
Defaults to NV_OF_HINT_VECTOR_GRID_SIZE_1.
522+
@param enableTemporalHints Optional parameter. Flag to enable temporal hints. When set to true, the hardware uses the flow vectors
523+
generated in previous call to calc() as internal hints for the current call to calc().
524+
Useful when computing flow vectors between successive video frames. Defaults to false.
525+
@param enableExternalHints Optional Parameter. Flag to enable passing external hints buffer to calc(). Defaults to false.
526+
@param enableCostBuffer Optional Parameter. Flag to enable cost buffer output from calc(). Defaults to false.
527+
@param gpuId Optional parameter to select the GPU ID on which the optical flow should be computed. Useful in multi-GPU systems. Defaults to 0.
528+
@param inputStream Optical flow algorithm may optionally involve cuda preprocessing on the input buffers.
529+
The input cuda stream can be used to pipeline and synchronize the cuda preprocessing tasks with OF HW engine.
530+
If input stream is not set, the execute function will use default stream which is NULL stream;
531+
@param outputStream Optical flow algorithm may optionally involve cuda post processing on the output flow vectors.
532+
The output cuda stream can be used to pipeline and synchronize the cuda post processing tasks with OF HW engine.
533+
If output stream is not set, the execute function will use default stream which is NULL stream;
534+
*/
535+
CV_WRAP static Ptr<NvidiaOpticalFlow_2_0> create(
536+
cv::Size imageSize,
537+
cv::cuda::NvidiaOpticalFlow_2_0::NVIDIA_OF_PERF_LEVEL perfPreset
538+
= cv::cuda::NvidiaOpticalFlow_2_0::NV_OF_PERF_LEVEL_SLOW,
539+
cv::cuda::NvidiaOpticalFlow_2_0::NVIDIA_OF_OUTPUT_VECTOR_GRID_SIZE outputGridSize
540+
= cv::cuda::NvidiaOpticalFlow_2_0::NV_OF_OUTPUT_VECTOR_GRID_SIZE_1,
541+
cv::cuda::NvidiaOpticalFlow_2_0::NVIDIA_OF_HINT_VECTOR_GRID_SIZE hintGridSize
542+
= cv::cuda::NvidiaOpticalFlow_2_0::NV_OF_HINT_VECTOR_GRID_SIZE_1,
543+
bool enableTemporalHints = false,
544+
bool enableExternalHints = false,
545+
bool enableCostBuffer = false,
546+
int gpuId = 0,
547+
Stream& inputStream = Stream::Null(),
548+
Stream& outputStream = Stream::Null());
549+
550+
/** @brief Instantiate NVIDIA Optical Flow with ROI Feature
551+
552+
@param imageSize Size of input image in pixels.
553+
@param roiData Pointer to ROI data.
554+
@param perfPreset Optional parameter. Refer [NV OF SDK documentation](https://developer.nvidia.com/opticalflow-sdk) for details about presets.
555+
Defaults to NV_OF_PERF_LEVEL_SLOW.
556+
@param outputGridSize Optional parameter. Refer [NV OF SDK documentation](https://developer.nvidia.com/opticalflow-sdk) for details about output grid sizes.
557+
Defaults to NV_OF_OUTPUT_VECTOR_GRID_SIZE_1.
558+
@param hintGridSize Optional parameter. Refer [NV OF SDK documentation](https://developer.nvidia.com/opticalflow-sdk) for details about hint grid sizes.
559+
Defaults to NV_OF_HINT_VECTOR_GRID_SIZE_1.
560+
@param enableTemporalHints Optional parameter. Flag to enable temporal hints. When set to true, the hardware uses the flow vectors
561+
generated in previous call to calc() as internal hints for the current call to calc().
562+
Useful when computing flow vectors between successive video frames. Defaults to false.
563+
@param enableExternalHints Optional Parameter. Flag to enable passing external hints buffer to calc(). Defaults to false.
564+
@param enableCostBuffer Optional Parameter. Flag to enable cost buffer output from calc(). Defaults to false.
565+
@param gpuId Optional parameter to select the GPU ID on which the optical flow should be computed. Useful in multi-GPU systems. Defaults to 0.
566+
@param inputStream Optical flow algorithm may optionally involve cuda preprocessing on the input buffers.
567+
The input cuda stream can be used to pipeline and synchronize the cuda preprocessing tasks with OF HW engine.
568+
If input stream is not set, the execute function will use default stream which is NULL stream;
569+
@param outputStream Optical flow algorithm may optionally involve cuda post processing on the output flow vectors.
570+
The output cuda stream can be used to pipeline and synchronize the cuda post processing tasks with OF HW engine.
571+
If output stream is not set, the execute function will use default stream which is NULL stream;
572+
*/
573+
CV_WRAP static Ptr<NvidiaOpticalFlow_2_0> create(
574+
cv::Size imageSize,
575+
std::vector<Rect> roiData,
576+
cv::cuda::NvidiaOpticalFlow_2_0::NVIDIA_OF_PERF_LEVEL perfPreset
577+
= cv::cuda::NvidiaOpticalFlow_2_0::NV_OF_PERF_LEVEL_SLOW,
578+
cv::cuda::NvidiaOpticalFlow_2_0::NVIDIA_OF_OUTPUT_VECTOR_GRID_SIZE outputGridSize
579+
= cv::cuda::NvidiaOpticalFlow_2_0::NV_OF_OUTPUT_VECTOR_GRID_SIZE_1,
580+
cv::cuda::NvidiaOpticalFlow_2_0::NVIDIA_OF_HINT_VECTOR_GRID_SIZE hintGridSize
581+
= cv::cuda::NvidiaOpticalFlow_2_0::NV_OF_HINT_VECTOR_GRID_SIZE_1,
452582
bool enableTemporalHints = false,
453583
bool enableExternalHints = false,
454584
bool enableCostBuffer = false,
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import os
2+
import cv2 as cv
3+
import numpy as np
4+
5+
from tests_common import NewOpenCVTests, unittest
6+
7+
class nvidiaopticalflow_test(NewOpenCVTests):
8+
def setUp(self):
9+
super(nvidiaopticalflow_test, self).setUp()
10+
if not cv.cuda.getCudaEnabledDeviceCount():
11+
self.skipTest("No CUDA-capable device is detected")
12+
13+
@unittest.skipIf('OPENCV_TEST_DATA_PATH' not in os.environ,
14+
"OPENCV_TEST_DATA_PATH is not defined")
15+
def test_calc(self):
16+
frame1 = os.environ['OPENCV_TEST_DATA_PATH'] + '/gpu/opticalflow/frame0.png'
17+
frame2 = os.environ['OPENCV_TEST_DATA_PATH'] + '/gpu/opticalflow/frame1.png'
18+
19+
npMat1 = cv.cvtColor(cv.imread(frame1),cv.COLOR_BGR2GRAY)
20+
npMat2 = cv.cvtColor(cv.imread(frame2),cv.COLOR_BGR2GRAY)
21+
22+
cuMat1 = cv.cuda_GpuMat(npMat1)
23+
cuMat2 = cv.cuda_GpuMat(npMat2)
24+
try:
25+
nvof = cv.cuda_NvidiaOpticalFlow_1_0.create(cuMat1.shape[1], cuMat1.shape[0], 5, False, False, False, 0)
26+
flow = nvof.calc(cuMat1, cuMat2, None)
27+
self.assertTrue(flow.shape[1] > 0 and flow.shape[0] > 0)
28+
flowUpSampled = nvof.upSampler(flow[0], cuMat1.shape[1], cuMat1.shape[0], nvof.getGridSize(), None)
29+
nvof.collectGarbage()
30+
except cv.error as e:
31+
if e.code == cv.Error.StsBadFunc or e.code == cv.Error.StsBadArg or e.code == cv.Error.StsNullPtr:
32+
self.skipTest("Algorithm is not supported in the current environment")
33+
self.assertTrue(flowUpSampled.shape[1] > 0 and flowUpSampled.shape[0] > 0)
34+
35+
if __name__ == '__main__':
36+
NewOpenCVTests.bootstrap()

modules/cudaoptflow/perf/perf_optflow.cpp

Lines changed: 61 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -339,13 +339,8 @@ PERF_TEST_P(ImagePair, NvidiaOpticalFlow_1_0,
339339

340340
const cv::Mat frame1 = readImage(GetParam().second, cv::IMREAD_GRAYSCALE);
341341
ASSERT_FALSE(frame1.empty());
342-
343-
const int width = frame0.size().width;
344-
const int height = frame0.size().height;
345-
const bool enableTemporalHints = false;
346-
const bool enableExternalHints = false;
347-
const bool enableCostBuffer = false;
348-
const int gpuid = 0;
342+
Stream inputStream;
343+
Stream outputStream;
349344

350345
if (PERF_RUN_CUDA())
351346
{
@@ -355,9 +350,9 @@ PERF_TEST_P(ImagePair, NvidiaOpticalFlow_1_0,
355350
cv::Ptr<cv::cuda::NvidiaOpticalFlow_1_0> d_nvof;
356351
try
357352
{
358-
d_nvof = cv::cuda::NvidiaOpticalFlow_1_0::create(width, height,
353+
d_nvof = cv::cuda::NvidiaOpticalFlow_1_0::create(frame0.size(),
359354
cv::cuda::NvidiaOpticalFlow_1_0::NVIDIA_OF_PERF_LEVEL::NV_OF_PERF_LEVEL_FAST,
360-
enableTemporalHints, enableExternalHints, enableCostBuffer, gpuid);
355+
false, false, false, 0, inputStream, outputStream);
361356
}
362357
catch (const cv::Exception& e)
363358
{
@@ -376,6 +371,63 @@ PERF_TEST_P(ImagePair, NvidiaOpticalFlow_1_0,
376371

377372
CUDA_SANITY_CHECK(u, 1e-10);
378373
CUDA_SANITY_CHECK(v, 1e-10);
374+
375+
d_nvof->collectGarbage();
376+
}
377+
}
378+
379+
//////////////////////////////////////////////////////
380+
// NvidiaOpticalFlow_2_0
381+
382+
PERF_TEST_P(ImagePair, NvidiaOpticalFlow_2_0,
383+
Values<pair_string>(make_pair("gpu/opticalflow/frame0.png", "gpu/opticalflow/frame1.png")))
384+
{
385+
declare.time(10);
386+
387+
const cv::Mat frame0 = readImage(GetParam().first, cv::IMREAD_GRAYSCALE);
388+
ASSERT_FALSE(frame0.empty());
389+
390+
const cv::Mat frame1 = readImage(GetParam().second, cv::IMREAD_GRAYSCALE);
391+
ASSERT_FALSE(frame1.empty());
392+
393+
const cv::cuda::NvidiaOpticalFlow_2_0::NVIDIA_OF_OUTPUT_VECTOR_GRID_SIZE outGridSize
394+
= cv::cuda::NvidiaOpticalFlow_2_0::NVIDIA_OF_OUTPUT_VECTOR_GRID_SIZE::NV_OF_OUTPUT_VECTOR_GRID_SIZE_1;
395+
const cv::cuda::NvidiaOpticalFlow_2_0::NVIDIA_OF_HINT_VECTOR_GRID_SIZE hintGridSize
396+
= cv::cuda::NvidiaOpticalFlow_2_0::NVIDIA_OF_HINT_VECTOR_GRID_SIZE::NV_OF_HINT_VECTOR_GRID_SIZE_1;
397+
Stream inputStream;
398+
Stream outputStream;
399+
400+
if (PERF_RUN_CUDA())
401+
{
402+
const cv::cuda::GpuMat d_frame0(frame0);
403+
const cv::cuda::GpuMat d_frame1(frame1);
404+
cv::cuda::GpuMat d_flow;
405+
cv::Ptr<cv::cuda::NvidiaOpticalFlow_2_0> d_nvof;
406+
try
407+
{
408+
d_nvof = cv::cuda::NvidiaOpticalFlow_2_0::create(frame0.size(),
409+
cv::cuda::NvidiaOpticalFlow_2_0::NVIDIA_OF_PERF_LEVEL::NV_OF_PERF_LEVEL_FAST, outGridSize, hintGridSize,
410+
false, false, false, 0, inputStream, outputStream);
411+
}
412+
catch (const cv::Exception& e)
413+
{
414+
if (e.code == Error::StsBadFunc || e.code == Error::StsBadArg || e.code == Error::StsNullPtr)
415+
throw SkipTestException("Current configuration is not supported");
416+
throw;
417+
}
418+
419+
TEST_CYCLE() d_nvof->calc(d_frame0, d_frame1, d_flow);
420+
421+
cv::cuda::GpuMat flow[2];
422+
cv::cuda::split(d_flow, flow);
423+
424+
cv::cuda::GpuMat u = flow[0];
425+
cv::cuda::GpuMat v = flow[1];
426+
427+
CUDA_SANITY_CHECK(u, 1e-10);
428+
CUDA_SANITY_CHECK(v, 1e-10);
429+
430+
d_nvof->collectGarbage();
379431
}
380432
}
381433

0 commit comments

Comments
 (0)