Merge pull request #554 from bitwangyaoyao:2.4_impvInterFrame
This commit is contained in:
		| @@ -45,6 +45,7 @@ | |||||||
|  |  | ||||||
| #include <iomanip> | #include <iomanip> | ||||||
| #include "precomp.hpp" | #include "precomp.hpp" | ||||||
|  | #include "mcwutil.hpp" | ||||||
|  |  | ||||||
| using namespace std; | using namespace std; | ||||||
| using namespace cv; | using namespace cv; | ||||||
| @@ -231,73 +232,10 @@ void interpolate::blendFrames(const oclMat &frame0, const oclMat &/*frame1*/, co | |||||||
|  |  | ||||||
| void interpolate::bindImgTex(const oclMat &img, cl_mem &texture) | void interpolate::bindImgTex(const oclMat &img, cl_mem &texture) | ||||||
| { | { | ||||||
|     cl_image_format format; |  | ||||||
|     int err; |  | ||||||
|     int depth    = img.depth(); |  | ||||||
|     int channels = img.channels(); |  | ||||||
|  |  | ||||||
|     switch(depth) |  | ||||||
|     { |  | ||||||
|     case CV_8U: |  | ||||||
|         format.image_channel_data_type = CL_UNSIGNED_INT8; |  | ||||||
|         break; |  | ||||||
|     case CV_32S: |  | ||||||
|         format.image_channel_data_type = CL_UNSIGNED_INT32; |  | ||||||
|         break; |  | ||||||
|     case CV_32F: |  | ||||||
|         format.image_channel_data_type = CL_FLOAT; |  | ||||||
|         break; |  | ||||||
|     default: |  | ||||||
|         throw std::exception(); |  | ||||||
|         break; |  | ||||||
|     } |  | ||||||
|     switch(channels) |  | ||||||
|     { |  | ||||||
|     case 1: |  | ||||||
|         format.image_channel_order     = CL_R; |  | ||||||
|         break; |  | ||||||
|     case 3: |  | ||||||
|         format.image_channel_order     = CL_RGB; |  | ||||||
|         break; |  | ||||||
|     case 4: |  | ||||||
|         format.image_channel_order     = CL_RGBA; |  | ||||||
|         break; |  | ||||||
|     default: |  | ||||||
|         throw std::exception(); |  | ||||||
|         break; |  | ||||||
|     } |  | ||||||
|     if(texture) |     if(texture) | ||||||
|     { |     { | ||||||
|         openCLFree(texture); |         openCLFree(texture); | ||||||
|     } |     } | ||||||
|  | 	texture = bindTexture(img); | ||||||
| #ifdef CL_VERSION_1_2 |  | ||||||
|     cl_image_desc desc; |  | ||||||
|     desc.image_type       = CL_MEM_OBJECT_IMAGE2D; |  | ||||||
|     desc.image_width      = img.step / img.elemSize(); |  | ||||||
|     desc.image_height     = img.rows; |  | ||||||
|     desc.image_depth      = 0; |  | ||||||
|     desc.image_array_size = 1; |  | ||||||
|     desc.image_row_pitch  = 0; |  | ||||||
|     desc.image_slice_pitch = 0; |  | ||||||
|     desc.buffer           = NULL; |  | ||||||
|     desc.num_mip_levels   = 0; |  | ||||||
|     desc.num_samples      = 0; |  | ||||||
|     texture = clCreateImage(Context::getContext()->impl->clContext, CL_MEM_READ_WRITE, &format, &desc, NULL, &err); |  | ||||||
| #else |  | ||||||
|     texture = clCreateImage2D( |  | ||||||
|                   Context::getContext()->impl->clContext, |  | ||||||
|                   CL_MEM_READ_WRITE, |  | ||||||
|                   &format, |  | ||||||
|                   img.step / img.elemSize(), |  | ||||||
|                   img.rows, |  | ||||||
|                   0, |  | ||||||
|                   NULL, |  | ||||||
|                   &err); |  | ||||||
| #endif |  | ||||||
|     size_t origin[] = { 0, 0, 0 }; |  | ||||||
|     size_t region[] = { img.step / img.elemSize(), img.rows, 1 }; |  | ||||||
|     clEnqueueCopyBufferToImage(img.clCxt->impl->clCmdQueue, (cl_mem)img.data, texture, 0, origin, region, 0, NULL, 0); |  | ||||||
|     openCLSafeCall(err); |  | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Andrey Kamaev
					Andrey Kamaev