Combined Use of opencv and Cuda

Source: Internet
Author: User

The GPU module of opencv provides many parallel functions implemented by cuda, but sometimes you need to write parallel functions and use them with existing opencv functions. opencv is an open-source function library, we can easily see its internal implementation mechanism, and write a Cuda parallel function based on its existing functions.

The key GPU classes are gpumat and ptrstepsz. Gpumat is mainly used to upload data in the memory to the existing one, while ptrstepsz is a parameter used for GPU core functions.

1. First, design your own core function. The parameter can be a defined type or ptrstepsz. Generally, select the latter because opencv reloads the gpumat forced type conversion function.

2. Call. initialize your own gpumat and use the upload function. Then use forced type conversion to convert it to the ptrstepsz <**> type, Set grid and block, and call the kernel function, call cudafree to release the resources you have applied.

3. Call the download function of gpumat to return the processed matrix.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.