Ask Your Question

biaspoint's profile - activity

2015-11-13 02:48:07 -0600 received badge  Student (source)
2015-09-11 05:02:29 -0600 received badge  Self-Learner (source)
2015-09-10 21:14:34 -0600 answered a question What are the equivalent functions of cv::ocl in 3.0?

@LBerger was correct this functionality was not included in my version of OpenCV 3.0. I downloaded the most recent version and the functions were there. Additionally if you plan on using this function, you must first call:

  cv::ocl::attachContext

Thanks for the help!

2015-09-10 21:11:29 -0600 asked a question Is there an OpenCV equivalent function to OpenCL's clEnqueueAcquireGLObjects?

There seems to be a method to convert OpenGL renderings (from the video buffer) to an OpenCL cl_mem (clEnqueueAcquireGLObjects). It is then also possible to transfer the cl_mem images to OpenCV UMats using

  cv::ocl::convertFromImage

Is there a shortcut for GL to CV direct?

I know OpenCV has the cv::ogl capability, however I have some complicated renderings with 2 different shaders (GLSL) being used, I haven't found too much discussion of cv::ogl and shaders.

Thanks!

2015-09-09 02:44:10 -0600 received badge  Self-Learner (source)
2015-09-09 00:25:12 -0600 answered a question What's causing the assertion fail in cv::ocl::convertFromImage

It turns out that LBerger was on the right track. You have to use

cv::ocl::attachContext(PlatformName, platforms[0], context(), devices[0]());  // C++

or for C code of OpenCL:

cv::ocl::attachContext(PlatformName, platform, context, device);   // C

to use the context created by OpenCL, I was able to do it using the c++ code from my comment and I had to borrow some code to get the first 2 values, I'm sure there is a more efficient method (and one that doesn't assume you only have 1 platform):

// C Code Changes from my original Question
    cl_image_desc desc_src;
    desc_src.image_type        = CL_MEM_OBJECT_IMAGE2D;
    desc_src.image_width       = mat.cols;
    desc_src.image_height      = mat.rows;
    desc_src.image_depth       = 0;
    desc_src.image_array_size  = 0;
    desc_src.image_row_pitch   = mat.step[0];
    desc_src.image_slice_pitch = 0;
    desc_src.num_mip_levels    = 0;
    desc_src.num_samples       = 0;
    desc_src.buffer            = 0;

    size_t sz = 0;
    clGetPlatformInfo(platform, CL_PLATFORM_NAME, 0, 0, &sz);
    char PlatformName[sz+1];
    clGetPlatformInfo(platform, CL_PLATFORM_NAME, sz, PlatformName, 0);
    cv::ocl::attachContext(PlatformName, platform, context, device);
    IDKmem = clCreateImage(context, CL_MEM_READ_WRITE |  CL_MEM_COPY_HOST_PTR,&tif_format,&desc_src,mat.ptr(),&err);

Hope that helps someone else.

2015-09-07 19:51:17 -0600 commented question What's causing the assertion fail in cv::ocl::convertFromImage

I also tried:

    cv::ocl::Context cvContext;
    cl::Image2D IDKmem(cvContext, CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR, format, mat.cols, mat.rows, 0,mat.data,&err);

and I got "no matching function for call to cl::Image2d::Image2D(cv::ocl::Context&, ... error

2015-09-07 19:47:26 -0600 commented question What's causing the assertion fail in cv::ocl::convertFromImage

I tried it this way and got a segmentation fault instead of an assertion fail, so I assume I can not use the OpenCL C++ to create the cl::image2D

cl::Platform platform;
cl::Platform::get(&platform);
vector<cl::Device> devices;
platform.getDevices(CL_DEVICE_TYPE_GPU, &devices);
cl::Context context(devices[0]);

cl::ImageFormat format (CL_RGBA, CL_FLOAT);
cl::Image2D IDKmem(context, CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR, format, mat.cols, mat.rows, 0,mat.data,&err);

cv::UMat Umat;
cv::ocl::convertFromImage(&IDKmem, Umat);
2015-09-07 19:11:05 -0600 commented question What's causing the assertion fail in cv::ocl::convertFromImage

I'll give it a shot, thanks! The one problem I see (and yes, it is a problem of my own doing), is that I have combined the C++ of OpenCV with the C of OpenCL. Granted I can use the C++ wrapper for OpenCL but I have not gotten that smart yet! Thanks!

2015-09-04 14:42:39 -0600 asked a question What's causing the assertion fail in cv::ocl::convertFromImage

I'm getting an assertion fail in the last assertion in ocl.cpp (line 5466?),

OpenCV Error: Assertion failed (clEnqueueCopyImageToBuffer(q, clImage, clBuffer, src_origin, region, offset, 0, NULL, NULL) == CL_SUCCESS) in convertFromImage, file /home/xxxxx/opencv-3.0.0/modules/core/src/ocl.cpp, line 5466

This line:

CV_Assert(clEnqueueCopyImageToBuffer(q, clImage, clBuffer, src_origin, region, offset, 0, NULL, NULL) == CL_SUCCESS);

which I would have thought it wouldn't have made it all the way through the function and then fault there. Here is the code, I'm probably mixing up the library notation somehow.

int main()
{
cv::Mat mat(480, 640, CV_32FC4);
mat.setTo(cv::Scalar(0,1,1,0));
cv::imshow("CVforCLimage", mat);
cv::waitKey(0);

cl_platform_id platform;
cl_device_id device;
cl_context context;
cl_int err;
clGetPlatformIDs(1, &platform, NULL);
clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 1, &device, NULL);
context = clCreateContext(NULL, 1, &device, NULL, NULL, &err);

cl_mem IDKmem;
cl_image_format tif_format;
tif_format.image_channel_order =   CL_RGBA;
tif_format.image_channel_data_type =   CL_FLOAT;

IDKmem = clCreateImage2D(context, CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR,&tif_format,mat.cols, mat.rows, 0,mat.data,&err);
cv::UMat Umat;
cv::ocl::convertFromImage(IDKmem, Umat);
cv::imshow("CVforCLimage", Umat);
cv::waitKey(0);

return 0;
}

The function convertFromImage is causing the problem, I tried to make it as basic as I could to try and understand the numenclautre. Thanks!

2015-09-04 09:50:45 -0600 commented question What are the equivalent functions of cv::ocl in 3.0?

You were right... how many hours I spent on that!! now of course I'm getting a segmentation fault with that function anyway... the work never ends! Thanks!

2015-09-04 09:47:57 -0600 received badge  Enthusiast
2015-09-03 20:02:59 -0600 commented question What are the equivalent functions of cv::ocl in 3.0?

I can try, I built it using just the downloaded files... I sense that is not the best way to build it.

2015-09-03 08:26:56 -0600 commented question What are the equivalent functions of cv::ocl in 3.0?

The one interop example in fact calls cv::ocl::convertFromImage(image, u); directly, so there has to be something that I am doing wrong to prohibit it from be there. I'm using this call:

#include <opencv2/core/ocl.hpp>

and it is finding that ocl.hpp at /usr/local/include/opencv2

I receive this error:

/home/xxxxx/main.cpp:252: error: 'convertFromImage' is not a member of 'cv::ocl'
  cv::ocl::convertFromImage(IDKmem, Umike);
  ^
2015-09-03 08:25:11 -0600 commented question What are the equivalent functions of cv::ocl in 3.0?

Thanks... I've looked through those, but I still see that the functions are available at least in some versions of ocl.cpp on-line, so I'm wondering why those functions did not make it in to my installed ocl.cpp. Thanks, I will look through those pages again and see if there is something I missed, Thanks!

2015-09-03 08:17:54 -0600 received badge  Editor (source)
2015-09-02 21:56:15 -0600 asked a question What are the equivalent functions of cv::ocl in 3.0?

For whatever reason I cannot access some functions of cv::ocl, such as cv::ocl::convertfromimage. The compiler is telling me it is not a function of cv::ocl, and when I look at ocl.cpp it isn't there, but I've seen it in the online repositories for ocl.cpp... why would it not show up in my local installation? Is there something I need to do when I build 3.0? an option I missed, or is there an equivalent function that does the same thing? Thanks!

I noticed in the build info that OpenCL is using a 1.2 folder from within OpenCV 3.0, I could not find a way to specify another location... does that need to be changed?

Here is the build information:videoio: Removing WinRT API headers by default

General configuration for OpenCV 3.0.0 ===================================== Version control: unknown

Platform: Host: Linux 3.19.0-25-generic x86_64

CMake: 2.8.12.2

CMake generator: Unix Makefiles

CMake build tool: /usr/bin/make

Configuration: Release

C/C++:

Built as dynamic libs?: YES

C++ Compiler: /usr/bin/c++ (ver 4.8.4)

Linker flags (Debug):

Precompiled headers: YES

OpenCV modules: To be built: hal core flann imgproc ml photo video imgcodecs shape videoio highgui objdetect superres ts features2d calib3d stitching videostab Disabled: world Disabled by dependency: - Unavailable: cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev java python2 python3 viz

Other third-party libraries: Use OpenCL: YES

OpenCL:

Version: dynamic

Include path: /home/xxxxx/opencv-3.0.0/3rdparty/include/opencl/1.2

Use AMDFFT: NO

Use AMDBLAS: NO

Tests and samples:

Tests: YES

Performance tests: YES

C/C++ Examples: YES

Install path: /usr/local

cvconfig.h is in: /home/xxxxx/opencv-3.0.0/build

2015-07-18 15:01:39 -0600 commented answer openCV 3.0 beta and OpenCL setDevice

perhaps cv::ocl::Device(current_device); ?

2015-07-11 09:38:48 -0600 received badge  Supporter (source)
2014-12-30 11:41:27 -0600 commented answer LIBTIFF_4.0 link errors

I now realize that I had an old PATH after my re-install of 14.04 that I thought was gone and it was linking to an older OpenCV (2.4) folder/file that was within the ROS install. I removed the PATH and also upgraded ROS to OpenCV 3.0. I think either would have worked alone.

sudo apt-get install ros-hydro-opencv3
2014-12-30 11:40:35 -0600 answered a question LIBTIFF_4.0 link errors

I now realize that I had an old PATH after my re-install of 14.04 that I thought was gone and it was linking to an older OpenCV (2.4) folder/file that was within the ROS install. I removed the PATH and also upgraded ROS to OpenCV 3.0. I think either would have worked alone.

2014-12-30 03:28:47 -0600 commented answer LIBTIFF_4.0 link errors

I tried this, re-did cmake with that option (-DBUILD_TIFF=ON) included and the cmake return showed: -- TIFF: build (ver 42 - 4.0.2) however when I tried to run the demo I still got ./facedetect: error while loading shared libraries: libtiff.so.4: cannot open shared object file: No such file or directory