ocl.hpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. //---------------------------------------------------------------------------//
  2. // Copyright (c) 2013-2014 Kyle Lutz <kyle.r.lutz@gmail.com>
  3. //
  4. // Distributed under the Boost Software License, Version 1.0
  5. // See accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt
  7. //
  8. // See http://boostorg.github.com/compute for more information.
  9. //---------------------------------------------------------------------------//
  10. #ifndef BOOST_COMPUTE_INTEROP_OPENCV_OCL_HPP
  11. #define BOOST_COMPUTE_INTEROP_OPENCV_OCL_HPP
  12. #include <opencv2/ocl/ocl.hpp>
  13. #include <boost/compute/buffer.hpp>
  14. #include <boost/compute/context.hpp>
  15. #include <boost/compute/command_queue.hpp>
  16. namespace boost {
  17. namespace compute {
  18. context opencv_ocl_get_context()
  19. {
  20. void *ocl_context = cv::ocl::getoclContext();
  21. if(!ocl_context){
  22. return context();
  23. }
  24. return context(*(static_cast<cl_context *>(ocl_context)));
  25. }
  26. command_queue opencv_ocl_get_command_queue()
  27. {
  28. void *ocl_queue = cv::ocl::getoclCommandQueue();
  29. if(!ocl_queue){
  30. return command_queue();
  31. }
  32. return command_queue(*(static_cast<cl_command_queue *>(ocl_queue)));
  33. }
  34. buffer opencv_ocl_get_buffer(const cv::ocl::oclMat &mat)
  35. {
  36. return buffer(reinterpret_cast<cl_mem>(mat.data));
  37. }
  38. } // end compute namespace
  39. } // end boost namespace
  40. #endif // BOOST_COMPUTE_INTEROP_OPENCV_OCL_HPP