2018-08-06 19:46:46 +08:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
'''
|
|
|
|
CUDA-accelerated Computer Vision functions
|
|
|
|
'''
|
|
|
|
|
|
|
|
# Python 2/3 compatibility
|
|
|
|
from __future__ import print_function
|
|
|
|
|
|
|
|
import numpy as np
|
|
|
|
import cv2 as cv
|
2019-12-04 23:57:58 +08:00
|
|
|
import os
|
2018-08-06 19:46:46 +08:00
|
|
|
|
2019-12-04 23:57:58 +08:00
|
|
|
from tests_common import NewOpenCVTests, unittest
|
2018-08-06 19:46:46 +08:00
|
|
|
|
|
|
|
class cuda_test(NewOpenCVTests):
|
|
|
|
def setUp(self):
|
2018-08-25 04:57:24 +08:00
|
|
|
super(cuda_test, self).setUp()
|
2018-08-06 19:46:46 +08:00
|
|
|
if not cv.cuda.getCudaEnabledDeviceCount():
|
|
|
|
self.skipTest("No CUDA-capable device is detected")
|
|
|
|
|
|
|
|
def test_cuda_upload_download(self):
|
2018-08-25 04:57:24 +08:00
|
|
|
npMat = (np.random.random((128, 128, 3)) * 255).astype(np.uint8)
|
|
|
|
cuMat = cv.cuda_GpuMat()
|
|
|
|
cuMat.upload(npMat)
|
2018-08-06 19:46:46 +08:00
|
|
|
|
2018-08-25 04:57:24 +08:00
|
|
|
self.assertTrue(np.allclose(cuMat.download(), npMat))
|
2018-08-06 19:46:46 +08:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
NewOpenCVTests.bootstrap()
|