-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
为什么测试解码提升很小?而且与官方demo 使用的api不一样 #8
Comments
然后官方的解码demo 是这样写的,里面的api为什么跟pynvjpeg完全不一样 int decode_images(const FileData &img_data, const std::vector<size_t> &img_len, CHECK_CUDA(cudaEventCreate(&startEvent, cudaEventBlockingSync)); std::vector<const unsigned char*> batched_bitstreams; // bit-streams that batched decode cannot handle // if(params.hw_decode_available){ // if(isSupported == 0){ CHECK_CUDA(cudaEventRecord(startEvent, params.stream));
CHECK_CUDA(cudaEventRecord(stopEvent, params.stream)); CHECK_CUDA(cudaEventSynchronize(stopEvent)); return EXIT_SUCCESS; |
|
环境 20核cpu cuda 10.2 T4 单卡
def get_image(image_url):
if not image_url:
return None
try:
image_url = parse.unquote(image_url)
response = requests.get(image_url)
if response.status_code != 200:
print("get image filed!!!!!!")
return " "
return response.content
except Exception as e:
print(e)
raise
def test_load_img(image, count):
start = cv2.getTickCount()
for num in range(0, count):
np_image = np.frombuffer(bytearray(image), np.uint8)
cv_image = cv2.imdecode(np_image, cv2.IMREAD_COLOR)
end1 = cv2.getTickCount()
print("load img1 base line = %s" % ((end1 - start) / cv2.getTickFrequency()))
return cv_image
def test_load_img_nvjpeg(image, count):
from nvjpeg import NvJpeg
nj = NvJpeg()
start = cv2.getTickCount()
for num in range(0, count):
np_image = np.asarray(bytearray(image), dtype="uint8")
# cv_image = cv2.imdecode(np_image, cv2.IMREAD_COLOR)
cv_image = nj.decode(np_image)
end1 = cv2.getTickCount()
print("load img nvjpeg base line = %s" % ((end1 - start) / cv2.getTickFrequency()))
return cv_image
if name == "main":
image = get_image("http://cdn.weipaitang.com/img/20200313rli2rh7p-jdgj-7vyi-91qd-584099256046-W3024H4032")
if image != "":
count = 100
test_load_img_nvjpeg(image, count)
cv_image = test_load_img(image, count)
结果为:
opencv 14秒
pynvjpeg 12.6秒 (确定观察到GPU的使用率,没有任何报错)
The text was updated successfully, but these errors were encountered: