C++ opencv2找错

opencv2找错  原来是参数位置没对齐。

#include "windows.h"
#include<iostream>
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <cuda_runtime.h>
#include <cuda.h>
#include <cuComplex.h>
#include <time.h>
#include<math.h>
#include <opencv2/opencv.hpp>#include<fstream>
#ifdef __APPLE__
#include <OpenCL/opencl.h>
#else
#include <stdlib.h>
#include <CL/cl.h>
#endif
#include <clFFT.h>
using namespace std;
using namespace cv;int main()
{Mat src1W = imread("none2.bmp", 0);if (src1W.empty()){cout << "读取图片错误,请确定目录下是否有imread函数指定图片存在~!\n" << endl;return -1;}imshow("无样品", src1W);//waitKey(0);Mat src3W = src1W(Rect(463, 169, 256, 256));src3W.convertTo(src3W, CV_64FC1);imshow("无样品1", src3W / 255);//waitKey(0);Mat src6;src6.convertTo(src6, CV_64FC1);cv::copyMakeBorder(src3W, src6, 0, 0, 0, 0, BORDER_CONSTANT, Scalar::all(0));imshow("ROItest1", src6 / 255);//waitKey(0);Mat src1D = imread("celiang2.bmp", 0);if (src1D.empty()){cout << "读取图片错误,请确定目录下是否有imread函数指定图片存在~!\n" << endl;return -1;}imshow("有样品", src1D);Mat src4W = src1D(Rect(463, 169, 256, 256));src4W.convertTo(src4W, CV_64FC1);imshow("有样品1", src4W / 255);Mat src6W;src6W.convertTo(src6W, CV_64FC1);cv::copyMakeBorder(src4W, src6W, 0, 0, 0, 0, BORDER_CONSTANT, Scalar::all(0));imshow("ROItest2", src6W / 255);Mat frame(src6.size(), CV_64FC1);int Width = frame.cols;int Height = frame.rows;Mat C1(frame.size(), CV_64FC2);Mat F(frame.size(), CV_64FC1);Mat F_re1(frame.size(), CV_64FC1);Mat dest(frame.size(), CV_64FC2);Mat B_im1(frame.size(), CV_64FC1, Scalar::all(0));Mat B_re1(frame.size(), CV_64FC1);Mat B_re2(frame.size(), CV_64FC1);Mat B_im2(frame.size(), CV_64FC1, Scalar::all(0));B_re1 = src6.clone();Mat value[2] = { B_re1,B_im1 };Mat B1;merge(value, 2, B1);B_re2 = src6W.clone();Mat value1[2] = { B_re2,B_im2 };Mat B2;merge(value1, 2, B2);cl_int err;cl_platform_id platform = 0;cl_device_id device = 0;cl_context_properties props[3] = { CL_CONTEXT_PLATFORM, 0, 0 };cl_context ctx = 0;cl_command_queue queue = 0;//cl_mem bufX;err = clGetPlatformIDs(1, &platform, NULL);err = clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 1, &device, NULL);props[1] = (cl_context_properties)platform;ctx = clCreateContext(props, 1, &device, NULL, NULL, &err);queue = clCreateCommandQueue(ctx, device, 0, &err);clfftSetupData fftSetup;err = clfftInitSetupData(&fftSetup);err = clfftSetup(&fftSetup);cl_mem B1_dev = NULL;  cl_mem A1_dev = NULL;B1_dev = clCreateBuffer(ctx, CL_MEM_READ_ONLY, frame.rows * frame.cols * sizeof(cl_double2), NULL, NULL);A1_dev = clCreateBuffer(ctx, CL_MEM_READ_WRITE, frame.rows * frame.cols * sizeof(cl_double2), NULL, NULL);err = clEnqueueWriteBuffer(queue, B1_dev, CL_TRUE, 0, frame.rows * frame.cols * sizeof(cl_double2), B1.data, 0, NULL, NULL);clfftPlanHandle planHandle;clfftDim dim = CLFFT_2D;size_t clLengths[2] = { (size_t)B1.cols,(size_t)B1.rows };err = clfftCreateDefaultPlan(&planHandle, ctx, dim, clLengths);err = clfftSetPlanPrecision(planHandle, CLFFT_DOUBLE);err = clfftSetLayout(planHandle, CLFFT_COMPLEX_INTERLEAVED, CLFFT_COMPLEX_INTERLEAVED);err = clfftSetResultLocation(planHandle, CLFFT_OUTOFPLACE);err = clfftBakePlan(planHandle, 1, &queue, NULL, NULL);err = clfftEnqueueTransform(planHandle, CLFFT_FORWARD, 1, &queue, 0, NULL, NULL, &B1_dev, &A1_dev, NULL);Mat result(frame.size(), CV_64FC2);clEnqueueReadBuffer(queue, A1_dev, CL_TRUE, 0, frame.rows * frame.cols * sizeof(cl_double2), result.data, 0, NULL, NULL);cl_mem B2_dev = NULL;  cl_mem A2_dev = NULL;B2_dev = clCreateBuffer(ctx, CL_MEM_READ_ONLY, frame.rows * frame.cols * sizeof(cl_double2), NULL, NULL);A2_dev = clCreateBuffer(ctx, CL_MEM_READ_WRITE, frame.rows * frame.cols * sizeof(cl_double2), NULL, NULL);err = clEnqueueWriteBuffer(queue, B2_dev, CL_TRUE, 0, frame.rows * frame.cols * sizeof(cl_double2), B2.data, 0, NULL, NULL);double time1 = static_cast<double>(getTickCount());err = clfftEnqueueTransform(planHandle, CLFFT_FORWARD, 1, &queue, 0, NULL, NULL, &B2_dev, &A2_dev, NULL);time1 = ((double)getTickCount() - time1) * 1000 / getTickFrequency();cout << "此方法运行时间为:" << time1 << "ms" << endl;Mat result1(frame.size(), CV_64FC2);clEnqueueReadBuffer(queue, A2_dev, CL_TRUE, 0, frame.rows * frame.cols * sizeof(cl_double2), result1.data, 0, NULL, NULL);std::ifstream kernelFile("sourse.cl", std::ios::in);std::ostringstream oss;oss << kernelFile.rdbuf();std::string srcStdStr = oss.str();const char* srcStr = srcStdStr.c_str();cl_program program = clCreateProgramWithSource(ctx, 1, (const char**)&srcStr, NULL, &err);err = clBuildProgram(program, 1, &device, NULL, NULL, NULL);cl_kernel kernel = clCreateKernel(program, "GPU_Zhengjiao", NULL);cl_mem des = clCreateBuffer(ctx, CL_MEM_READ_WRITE, frame.rows * frame.cols * sizeof(cl_double2), NULL, NULL);cl_mem src = clCreateBuffer(ctx, CL_MEM_READ_ONLY, frame.rows * frame.cols * sizeof(cl_double2), NULL, NULL);err = clEnqueueWriteBuffer(queue, src, CL_TRUE, 0, frame.rows * frame.cols * sizeof(cl_double2), result.data, 0, NULL, NULL);clSetKernelArg(kernel, 0, sizeof(cl_mem), &des);clSetKernelArg(kernel, 1, sizeof(cl_mem), &src);clSetKernelArg(kernel, 2, sizeof(int), (void*)&Height);clSetKernelArg(kernel, 3, sizeof(int), (void*)&Width);size_t globalWorkSize[2] = { frame.rows, frame.cols };clEnqueueNDRangeKernel(queue, kernel, 2, NULL, globalWorkSize, NULL, 0, NULL, NULL);Mat A11(frame.size(), CV_64FC2);err = clEnqueueReadBuffer(queue, des, CL_TRUE, 0, frame.rows * frame.cols * sizeof(cl_double2), A11.data, 0, NULL, NULL);cl_kernel kernel1 = clCreateKernel(program, "GPU_Zhengjiao", NULL);cl_mem des22 = clCreateBuffer(ctx, CL_MEM_READ_WRITE, frame.rows * frame.cols * sizeof(cl_double2), NULL, NULL);cl_mem src22 = clCreateBuffer(ctx, CL_MEM_READ_ONLY, frame.rows * frame.cols * sizeof(cl_double2), NULL, NULL);err = clEnqueueWriteBuffer(queue, src22, CL_TRUE, 0, frame.rows * frame.cols * sizeof(cl_double2), result1.data, 0, NULL, NULL);clSetKernelArg(kernel1, 0, sizeof(cl_mem), &des22);clSetKernelArg(kernel1, 1, sizeof(cl_mem), &src22);clSetKernelArg(kernel1, 2, sizeof(int), (void*)&Height);clSetKernelArg(kernel1, 3, sizeof(int), (void*)&Width);clEnqueueNDRangeKernel(queue, kernel1, 2, NULL, globalWorkSize, NULL, 0, NULL, NULL);Mat A22(frame.size(), CV_64FC2);err = clEnqueueReadBuffer(queue, des22, CL_TRUE, 0, frame.rows * frame.cols * sizeof(cl_double2), A22.data, 0, NULL, NULL);for (int i = 0; i < frame.rows; i++){for (int j = 0; j < frame.cols; j++){if ((i >= 97 && i < 160) && (j >= 147 && j < 190)){F_re1.at<double>(i, j) = 1;}else{F_re1.at<double>(i, j) = 0;}}}//F1圆形滤波器F = F_re1;imshow("矩形滤波器", F);err = clBuildProgram(program, 1, &device, NULL, NULL, NULL);cl_kernel kernel2 = clCreateKernel(program, "GPU_JvZhenDianCheng", NULL);cl_mem des_src = clCreateBuffer(ctx, CL_MEM_READ_WRITE, frame.rows * frame.cols * sizeof(cl_double2), NULL, NULL);cl_mem src1 = clCreateBuffer(ctx, CL_MEM_READ_ONLY, frame.rows * frame.cols * sizeof(cl_double2), NULL, NULL);cl_mem src2 = clCreateBuffer(ctx, CL_MEM_READ_ONLY, frame.rows * frame.cols * sizeof(double), NULL, NULL);clEnqueueWriteBuffer(queue, src1, CL_TRUE, 0, frame.rows * frame.cols * sizeof(cl_double2), A11.data, 0, NULL, NULL);clEnqueueWriteBuffer(queue, src2, CL_TRUE, 0, frame.rows * frame.cols * sizeof(double), F.data, 0, NULL, NULL);clSetKernelArg(kernel2, 0, sizeof(cl_mem), &des_src);clSetKernelArg(kernel2, 1, sizeof(cl_mem), &src1);clSetKernelArg(kernel2, 2, sizeof(cl_mem), &src2);clSetKernelArg(kernel2, 3, sizeof(int), &frame.cols);clSetKernelArg(kernel2, 4, sizeof(int), &frame.rows);clEnqueueNDRangeKernel(queue, kernel2, 2, NULL, globalWorkSize, NULL, 0, NULL, NULL);Mat SPA1(frame.size(), CV_64FC2);err = clEnqueueReadBuffer(queue, des_src, CL_TRUE, 0, frame.rows * frame.cols * sizeof(cl_double2), SPA1.data, 0, NULL, NULL);cl_kernel kernel3 = clCreateKernel(program, "GPU_JvZhenDianCheng", NULL);cl_mem des_src1 = clCreateBuffer(ctx, CL_MEM_READ_WRITE, frame.rows * frame.cols * sizeof(cl_double2), NULL, NULL);cl_mem src15 = clCreateBuffer(ctx, CL_MEM_READ_ONLY, frame.rows * frame.cols * sizeof(cl_double2), NULL, NULL);cl_mem src25 = clCreateBuffer(ctx, CL_MEM_READ_ONLY, frame.rows * frame.cols * sizeof(double), NULL, NULL);clEnqueueWriteBuffer(queue, src15, CL_TRUE, 0, frame.rows * frame.cols * sizeof(cl_double2), A22.data, 0, NULL, NULL);clEnqueueWriteBuffer(queue, src25, CL_TRUE, 0, frame.rows * frame.cols * sizeof(double), F.data, 0, NULL, NULL);clSetKernelArg(kernel3, 0, sizeof(cl_mem), &des_src1);clSetKernelArg(kernel3, 1, sizeof(cl_mem), &src15);clSetKernelArg(kernel3, 2, sizeof(cl_mem), &src25);clSetKernelArg(kernel3, 3, sizeof(int), &frame.cols);clSetKernelArg(kernel3, 4, sizeof(int), &frame.rows);clEnqueueNDRangeKernel(queue, kernel3, 2, NULL, globalWorkSize, NULL, 0, NULL, NULL);Mat SPB1(frame.size(), CV_64FC2);err = clEnqueueReadBuffer(queue, des_src1, CL_TRUE, 0, frame.rows * frame.cols * sizeof(cl_double2), SPB1.data, 0, NULL, NULL);cl_kernel kernel4 = clCreateKernel(program, "GPU_Zhengjiao", NULL);cl_mem dre = clCreateBuffer(ctx, CL_MEM_READ_WRITE, frame.rows * frame.cols * sizeof(cl_double2), NULL, NULL);cl_mem src11 = clCreateBuffer(ctx, CL_MEM_READ_ONLY, frame.rows * frame.cols * sizeof(cl_double2), NULL, NULL);err = clEnqueueWriteBuffer(queue, src11, CL_TRUE, 0, frame.rows * frame.cols * sizeof(cl_double2), SPA1.data, 0, NULL, NULL);clSetKernelArg(kernel4, 0, sizeof(cl_mem), &dre);clSetKernelArg(kernel4, 1, sizeof(cl_mem), &src11);clSetKernelArg(kernel4, 2, sizeof(int), (void*)&Height);clSetKernelArg(kernel4, 3, sizeof(int), (void*)&Width);clEnqueueNDRangeKernel(queue, kernel4, 2, NULL, globalWorkSize, NULL, 0, NULL, NULL);Mat A14(frame.size(), CV_64FC2);err = clEnqueueReadBuffer(queue, dre, CL_TRUE, 0, frame.rows * frame.cols * sizeof(cl_double2), A14.data, 0, NULL, NULL);cl_kernel kernel5 = clCreateKernel(program, "GPU_Zhengjiao", NULL);cl_mem dre33 = clCreateBuffer(ctx, CL_MEM_READ_WRITE, frame.rows * frame.cols * sizeof(cl_double2), NULL, NULL);cl_mem src33 = clCreateBuffer(ctx, CL_MEM_READ_ONLY, frame.rows * frame.cols * sizeof(cl_double2), NULL, NULL);err = clEnqueueWriteBuffer(queue, src33, CL_TRUE, 0, frame.rows * frame.cols * sizeof(cl_double2), SPB1.data, 0, NULL, NULL);clSetKernelArg(kernel5, 0, sizeof(cl_mem), &dre33);clSetKernelArg(kernel5, 1, sizeof(cl_mem), &src33);clSetKernelArg(kernel5, 2, sizeof(int), (void*)&Height);clSetKernelArg(kernel5, 3, sizeof(int), (void*)&Width);clEnqueueNDRangeKernel(queue, kernel5, 2, NULL, globalWorkSize, NULL, 0, NULL, NULL);Mat A44(frame.size(), CV_64FC2);err = clEnqueueReadBuffer(queue, dre33, CL_TRUE, 0, frame.rows * frame.cols * sizeof(cl_double2), A44.data, 0, NULL, NULL);cl_mem imageA1_dev = NULL;  cl_mem A11_dev = NULL;imageA1_dev = clCreateBuffer(ctx, CL_MEM_READ_WRITE, frame.rows * frame.cols * sizeof(cl_double2), NULL, NULL);A11_dev = clCreateBuffer(ctx, CL_MEM_READ_ONLY, frame.rows * frame.cols * sizeof(cl_double2), NULL, NULL);err = clEnqueueWriteBuffer(queue, A11_dev, CL_TRUE, 0, frame.rows * frame.cols * sizeof(cl_double2), A14.data, 0, NULL, NULL);err = clfftEnqueueTransform(planHandle, CLFFT_BACKWARD, 1, &queue, 0, NULL, NULL, &A11_dev, &imageA1_dev, NULL);Mat imageA1(frame.size(), CV_64FC2);clEnqueueReadBuffer(queue, imageA1_dev, CL_TRUE, 0, frame.rows * frame.cols * sizeof(cl_double2), imageA1.data, 0, NULL, NULL);cl_mem imageB1_dev = NULL;  cl_mem A55_dev = NULL;imageB1_dev = clCreateBuffer(ctx, CL_MEM_READ_WRITE, frame.rows * frame.cols * sizeof(cl_double2), NULL, NULL);A55_dev = clCreateBuffer(ctx, CL_MEM_READ_ONLY, frame.rows * frame.cols * sizeof(cl_double2), NULL, NULL);err = clEnqueueWriteBuffer(queue, A55_dev, CL_TRUE, 0, frame.rows * frame.cols * sizeof(cl_double2), A44.data, 0, NULL, NULL);err = clfftEnqueueTransform(planHandle, CLFFT_BACKWARD, 1, &queue, 0, NULL, NULL, &A55_dev, &imageB1_dev, NULL);Mat imageB1(frame.size(), CV_64FC2);clEnqueueReadBuffer(queue, imageB1_dev, CL_TRUE, 0, frame.rows * frame.cols * sizeof(cl_double2), imageB1.data, 0, NULL, NULL);err = clfftDestroyPlan(&planHandle);clfftTeardown();clReleaseMemObject(B1_dev);clReleaseMemObject(A1_dev);clReleaseMemObject(B2_dev);clReleaseMemObject(A2_dev);clReleaseMemObject(A11_dev);clReleaseMemObject(imageA1_dev);clReleaseMemObject(A55_dev);clReleaseMemObject(imageB1_dev);cl_kernel kernel6 = clCreateKernel(program, "GPU_DianChu", NULL);cl_mem des_src11 = clCreateBuffer(ctx, CL_MEM_READ_WRITE, frame.rows * frame.cols * sizeof(cl_double2), NULL, NULL);cl_mem src16 = clCreateBuffer(ctx, CL_MEM_READ_ONLY, frame.rows * frame.cols * sizeof(cl_double2), NULL, NULL);cl_mem src26 = clCreateBuffer(ctx, CL_MEM_READ_ONLY, frame.rows * frame.cols * sizeof(cl_double2), NULL, NULL);clEnqueueWriteBuffer(queue, src16, CL_TRUE, 0, frame.rows * frame.cols * sizeof(cl_double2), imageB1.data, 0, NULL, NULL);clEnqueueWriteBuffer(queue, src26, CL_TRUE, 0, frame.rows * frame.cols * sizeof(cl_double2), imageA1.data, 0, NULL, NULL);clSetKernelArg(kernel6, 0, sizeof(cl_mem), &des_src11);clSetKernelArg(kernel6, 1, sizeof(cl_mem), &src16);clSetKernelArg(kernel6, 2, sizeof(cl_mem), &src26);clSetKernelArg(kernel6, 3, sizeof(int), &frame.cols);clSetKernelArg(kernel6, 4, sizeof(int), &frame.rows);clEnqueueNDRangeKernel(queue, kernel6, 2, NULL, globalWorkSize, NULL, 0, NULL, NULL);Mat res1(frame.size(), CV_64FC2);err = clEnqueueReadBuffer(queue, des_src11, CL_TRUE, 0, frame.rows * frame.cols * sizeof(cl_double2), res1.data, 0, NULL, NULL);cl_kernel kernel7 = clCreateKernel(program, "GPU_atan", NULL);cl_mem res1_phase_dev = clCreateBuffer(ctx, CL_MEM_READ_WRITE, frame.rows * frame.cols * sizeof(double), NULL, NULL);cl_mem src88 = clCreateBuffer(ctx, CL_MEM_READ_ONLY, frame.rows * frame.cols * sizeof(cl_double2), NULL, NULL);err = clEnqueueWriteBuffer(queue, src88, CL_TRUE, 0, frame.rows * frame.cols * sizeof(cl_double2), res1.data, 0, NULL, NULL);clSetKernelArg(kernel7, 0, sizeof(cl_mem), &res1_phase_dev);clSetKernelArg(kernel7, 1, sizeof(cl_mem), &src88);clSetKernelArg(kernel7, 2, sizeof(int), (void*)&Height);clSetKernelArg(kernel7, 3, sizeof(int), (void*)&Width);clEnqueueNDRangeKernel(queue, kernel7, 2, NULL, globalWorkSize, NULL, 0, NULL, NULL);Mat phase(frame.size(), CV_64FC1);err = clEnqueueReadBuffer(queue, res1_phase_dev, CL_TRUE, 0, frame.rows * frame.cols * sizeof(double), phase.data, 0, NULL, NULL);imshow("wrappedphase", phase);cl_kernel kernel8 = clCreateKernel(program, "dxanddy_OpenCL", NULL);cl_mem dstx_dev = clCreateBuffer(ctx, CL_MEM_READ_WRITE, frame.rows * frame.cols * sizeof(double), NULL, NULL);cl_mem dsty_dev = clCreateBuffer(ctx, CL_MEM_READ_WRITE, frame.rows * frame.cols * sizeof(double), NULL, NULL);cl_mem src_dev = clCreateBuffer(ctx, CL_MEM_READ_ONLY, frame.rows * frame.cols * sizeof(double), NULL, NULL);err = clEnqueueWriteBuffer(queue, src_dev, CL_TRUE, 0, frame.rows * frame.cols * sizeof(double), phase.data, 0, NULL, NULL);clSetKernelArg(kernel8, 0, sizeof(cl_mem), &dstx_dev);clSetKernelArg(kernel8, 1, sizeof(cl_mem), &dsty_dev);clSetKernelArg(kernel8, 2, sizeof(cl_mem), &src_dev);clSetKernelArg(kernel8, 3, sizeof(int), (void*)&Height);clSetKernelArg(kernel8, 4, sizeof(int), (void*)&Width);clEnqueueNDRangeKernel(queue, kernel8, 2, NULL, globalWorkSize, NULL, 0, NULL, NULL);Mat dstx(frame.size(), CV_64FC1);Mat dsty(frame.size(), CV_64FC1);err = clEnqueueReadBuffer(queue, dstx_dev, CL_TRUE, 0, frame.rows * frame.cols * sizeof(double), dstx.data, 0, NULL, NULL);err = clEnqueueReadBuffer(queue, dsty_dev, CL_TRUE, 0, frame.rows * frame.cols * sizeof(double), dsty.data, 0, NULL, NULL);cl_kernel kernel9 = clCreateKernel(program, "tmpsndderivative_OpenCL", NULL);cl_mem dstxx_dev = clCreateBuffer(ctx, CL_MEM_READ_WRITE, frame.rows * frame.cols * sizeof(double), NULL, NULL);cl_mem dstyy_dev = clCreateBuffer(ctx, CL_MEM_READ_WRITE, frame.rows * frame.cols * sizeof(double), NULL, NULL);cl_mem srcx_dev = clCreateBuffer(ctx, CL_MEM_READ_ONLY, frame.rows * frame.cols * sizeof(double), NULL, NULL);cl_mem srcy_dev = clCreateBuffer(ctx, CL_MEM_READ_ONLY, frame.rows * frame.cols * sizeof(double), NULL, NULL);err = clEnqueueWriteBuffer(queue, srcx_dev, CL_TRUE, 0, frame.rows * frame.cols * sizeof(double), dstx.data, 0, NULL, NULL);err = clEnqueueWriteBuffer(queue, srcy_dev, CL_TRUE, 0, frame.rows * frame.cols * sizeof(double), dsty.data, 0, NULL, NULL);clSetKernelArg(kernel9, 0, sizeof(cl_mem), &dstxx_dev);clSetKernelArg(kernel9, 1, sizeof(cl_mem), &dstyy_dev);clSetKernelArg(kernel9, 2, sizeof(cl_mem), &srcx_dev);clSetKernelArg(kernel9, 3, sizeof(cl_mem), &srcy_dev);clSetKernelArg(kernel9, 4, sizeof(int), (void*)&Height);clSetKernelArg(kernel9, 5, sizeof(int), (void*)&Width);clEnqueueNDRangeKernel(queue, kernel9, 2, NULL, globalWorkSize, NULL, 0, NULL, NULL);Mat dstxx(frame.size(), CV_64FC1);Mat dstyy(frame.size(), CV_64FC1);err = clEnqueueReadBuffer(queue, dstxx_dev, CL_TRUE, 0, frame.rows * frame.cols * sizeof(double), dstxx.data, 0, NULL, NULL);err = clEnqueueReadBuffer(queue, dstyy_dev, CL_TRUE, 0, frame.rows * frame.cols * sizeof(double), dstyy.data, 0, NULL, NULL);cl_kernel kernel10 = clCreateKernel(program, "gmpsndderivative_OpenCL", NULL);cl_mem dstxx4_dev = clCreateBuffer(ctx, CL_MEM_READ_ONLY, frame.rows * frame.cols * sizeof(double), NULL, NULL);cl_mem dstyy4_dev = clCreateBuffer(ctx, CL_MEM_READ_ONLY, frame.rows * frame.cols * sizeof(double), NULL, NULL);cl_mem srcxx_dev = clCreateBuffer(ctx, CL_MEM_READ_ONLY, frame.rows * frame.cols * sizeof(double), NULL, NULL);cl_mem srcyy_dev = clCreateBuffer(ctx, CL_MEM_READ_ONLY, frame.rows * frame.cols * sizeof(double), NULL, NULL);cl_mem dstp_dev = clCreateBuffer(ctx, CL_MEM_READ_WRITE, frame.rows * frame.cols * sizeof(double), NULL, NULL);err = clEnqueueWriteBuffer(queue, dstxx4_dev, CL_TRUE, 0, frame.rows * frame.cols * sizeof(double), dstxx.data, 0, NULL, NULL);err = clEnqueueWriteBuffer(queue, dstyy4_dev, CL_TRUE, 0, frame.rows * frame.cols * sizeof(double), dstyy.data, 0, NULL, NULL);err = clEnqueueWriteBuffer(queue, srcxx_dev, CL_TRUE, 0, frame.rows * frame.cols * sizeof(double), dstx.data, 0, NULL, NULL);err = clEnqueueWriteBuffer(queue, srcyy_dev, CL_TRUE, 0, frame.rows * frame.cols * sizeof(double), dsty.data, 0, NULL, NULL);clSetKernelArg(kernel10, 0, sizeof(cl_mem), &dstxx4_dev);clSetKernelArg(kernel10, 1, sizeof(cl_mem), &dstyy4_dev);clSetKernelArg(kernel10, 0, sizeof(cl_mem), &srcxx_dev);clSetKernelArg(kernel10, 1, sizeof(cl_mem), &srcyy_dev);clSetKernelArg(kernel10, 2, sizeof(cl_mem), &dstp_dev);clSetKernelArg(kernel10, 3, sizeof(int), (void*)&Height);clSetKernelArg(kernel10, 4, sizeof(int), (void*)&Width);clEnqueueNDRangeKernel(queue, kernel10, 2, NULL, globalWorkSize, NULL, 0, NULL, NULL);Mat dst(frame.size(), CV_64FC1);err = clEnqueueReadBuffer(queue, dstp_dev, CL_TRUE, 0, frame.rows * frame.cols * sizeof(double), dst.data, 0, NULL, NULL);for (int i = 0; i < phase.rows; i++) {for (int j = 0; j < phase.cols; j++) {cout << "result(" << i << "," << j << "): " << dstyy.ptr<double>(i)[j] << endl;}}/*cl_kernel kernel11 = clCreateKernel(program, "GetAMAndAMT_OpenCL", NULL);cl_mem A_dev = clCreateBuffer(ctx, CL_MEM_READ_WRITE, frame.rows * frame.cols * sizeof(double), NULL, NULL);cl_mem AT_dev = clCreateBuffer(ctx, CL_MEM_READ_WRITE, frame.rows * frame.cols * sizeof(double), NULL, NULL);clSetKernelArg(kernel11, 0, sizeof(cl_mem), &A_dev);clSetKernelArg(kernel11, 1, sizeof(cl_mem), &AT_dev);clSetKernelArg(kernel11, 2, sizeof(int), (void*)&Height);clSetKernelArg(kernel11, 3, sizeof(int), (void*)&Width);clEnqueueNDRangeKernel(queue, kernel11, 2, NULL, globalWorkSize, NULL, 0, NULL, NULL);Mat A(frame.size(), CV_64FC1);Mat AT(frame.size(), CV_64FC1);err = clEnqueueReadBuffer(queue, A_dev, CL_TRUE, 0, frame.rows * frame.cols * sizeof(double), A.data, 0, NULL, NULL);err = clEnqueueReadBuffer(queue, AT_dev, CL_TRUE, 0, frame.rows * frame.cols * sizeof(double), AT.data, 0, NULL, NULL);cl_kernel kernel12 = clCreateKernel(program, "LINETRANS_OpenCL", NULL);cl_mem dst44_dev = clCreateBuffer(ctx, CL_MEM_READ_WRITE, frame.rows * frame.cols * sizeof(double), NULL, NULL);cl_mem src55_dev = clCreateBuffer(ctx, CL_MEM_READ_ONLY, frame.rows * frame.cols * sizeof(double), NULL, NULL);err = clEnqueueWriteBuffer(queue, src55_dev, CL_TRUE, 0, frame.rows * frame.cols * sizeof(double), dstxx.data, 0, NULL, NULL);clSetKernelArg(kernel12, 0, sizeof(cl_mem), &dst44_dev);clSetKernelArg(kernel12, 1, sizeof(cl_mem), &src55_dev);clSetKernelArg(kernel12, 2, sizeof(int), (void*)&Height);clSetKernelArg(kernel12, 3, sizeof(int), (void*)&Width);clEnqueueNDRangeKernel(queue, kernel12, 2, NULL, globalWorkSize, NULL, 0, NULL, NULL);Mat D(frame.size(), CV_64FC1);err = clEnqueueReadBuffer(queue, dst44_dev, CL_TRUE, 0, frame.rows * frame.cols * sizeof(double),D.data, 0, NULL, NULL);*//*cl_kernel kernel13 = clCreateKernel(program, "matrixMulOpenCL", NULL);cl_mem des_src18 = clCreateBuffer(ctx, CL_MEM_READ_WRITE, frame.rows * frame.cols * sizeof(double), NULL, NULL);cl_mem src17 = clCreateBuffer(ctx, CL_MEM_READ_ONLY, frame.rows * frame.cols * sizeof(double), NULL, NULL);cl_mem src27 = clCreateBuffer(ctx, CL_MEM_READ_ONLY, frame.rows * frame.cols * sizeof(double), NULL, NULL);clEnqueueWriteBuffer(queue, src17, CL_TRUE, 0, frame.rows * frame.cols * sizeof(double), A.data, 0, NULL, NULL);clEnqueueWriteBuffer(queue, src27, CL_TRUE, 0, frame.rows * frame.cols * sizeof(double), D.data, 0, NULL, NULL);clSetKernelArg(kernel13, 0, sizeof(cl_mem), &des_src18);clSetKernelArg(kernel13, 1, sizeof(cl_mem), &src17);clSetKernelArg(kernel13, 2, sizeof(cl_mem), &src27);clSetKernelArg(kernel13, 3, sizeof(int), &frame.cols);clSetKernelArg(kernel13, 4, sizeof(int), &frame.rows);clEnqueueNDRangeKernel(queue, kernel13, 2, NULL, globalWorkSize, NULL, 0, NULL, NULL);Mat res145(frame.size(), CV_64FC1);err = clEnqueueReadBuffer(queue, des_src18, CL_TRUE, 0, frame.rows * frame.cols * sizeof(double), res145.data, 0, NULL, NULL);*//*for (int i = 0; i < A11.rows; i++) {for (int j = 0; j < A11.cols; j++) {cout << "result(" << i << "," << j << "): " << res1.ptr<cv::Vec2d>(i)[j][0] << " + " << res1.ptr<cv::Vec2d>(i)[j][1] << "i" << endl;}}*//*ofstream Fs("D:\\test10.xls");if (!Fs.is_open()){cout << "error!" << endl;return 0;}int height = F.rows;int width =F.cols;for (int i = 0; i < height; i++){for (int j = 0; j < width; j++){Fs << AT.ptr<double>(i)[j] << '\t';}Fs << endl;}Fs.close();*//*ofstream Fs("D:\\test9.xls");if (!Fs.is_open()){cout << "error!" << endl;return 0;}int height = result.rows;int width = result.cols;for (int i = 0; i < height; i++){for (int j = 0; j < width; j++){Fs << result.ptr<cv::Vec2d>(i)[j][0] << " + " << result.ptr<cv::Vec2d>(i)[j][1] << "i" << '\t';}Fs << endl;}Fs.close();*/waitKey(0);return 0;
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/754662.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

视频技术2:把rtsp转为各种格式,包括webrtc

前题是启动ABLMediaServer&#xff0c;把ini里的hls_enable1 1、添加rtsp到视频服务器 http://127.0.0.1:7088/index/api/addStreamProxy?secret035c73f7-bb6b-4889-a715-d9eb2d1925cc&vhost_defaultVhost_&appMedia&streamCamera_00001&enable_hls1&ur…

音视频开发之旅——音频基础概念、交叉编译原理和实践(LAME的交叉编译)(iOS)

本文主要讲解的是音频基础概念、交叉编译原理和实践&#xff08;LAME的交叉编译&#xff09;&#xff0c;是基于iOS平台&#xff0c;示例代码如下所示&#xff1a; iOSAudioDemo 另外&#xff0c;Android平台也有相关的文章&#xff0c;如下所示&#xff1a; 音视频开发之旅…

443端口用于安全Web通信服务

443端口主要用于提供安全Web通信。通常通过HTTPS&#xff08;安全超文本传输协议&#xff09;实现&#xff0c;这是一种加密的HTTP协议。 443端口即网页浏览端口&#xff0c;主要是用于HTTPS服务&#xff0c;提供加密和通过安全端口传输服务。 HTTPS使用SSL&#xff08;安全套…

【数据结构与算法】设计循环队列

&#x1f9d1;‍&#x1f393;个人主页&#xff1a;简 料 &#x1f3c6;所属专栏&#xff1a;C &#x1f3c6;个人社区&#xff1a;越努力越幸运社区 &#x1f3c6;简 介&#xff1a;简料简料&#xff0c;简单有料~在校大学生一枚&#xff0c;专注C/C/GO的干货分…

2022年第十三届蓝桥杯比赛Java B组 【全部真题答案解析-第一部分】

最近回顾了Java B组的试题&#xff0c;深有感触&#xff1a;脑子长时间不用会锈住&#xff0c;很可怕。 兄弟们&#xff0c;都给我从被窝里爬起来&#xff0c;赶紧开始卷&#xff01;&#xff01;&#xff01; 2022年第十三届蓝桥杯Java B组(第一部分 A~F题) 目录 一、填空题 …

详解基于快速排序算法的qsort的模拟实现

目录 1. 快速排序 1.1 快速排序理论分析 1.2 快速排序的模拟实现 2. qsort的模拟实现 2.1 qsort的理论分析 2.2 qsort的模拟实现 qsort函数是基于快速排序思想设计的可以针对任意数据类型的c语言函数。要对qsort进行模拟实现&#xff0c;首先就要理解快速排序。 1. 快…

MQ横向对比:RocketMQ、Kafka、RabbitMQ、ActiveMQ、ZeroMQ

前言 本文将从多个角度全方位对比目前比较常用的几个MQ&#xff1a; RocketMQKafkaRabbitMQActiveMQZeroMQ将单独说明。 表格对比 特性RocketMQKafkaRabbitMQActiveMQ单机吞吐量10 万级&#xff0c;支撑高吞吐10 几万级&#xff0c;吞吐量非常高&#xff0c;甚至有文献称&a…

【数据结构】堆的创建

文章目录 一、堆的概念及结构1、什么是堆2、堆的性质3、堆的结构及分类 二、堆的创建1、堆向下调整算法2、堆向上调整算法3、堆的创建&#xff08;向上调整算法&#xff09; 一、堆的概念及结构 1、什么是堆 堆就是以二叉树的顺序存储方式来存储元素&#xff0c;同时又要满足父…

Java复习05 Spring 概念

Java复习05 Spring 概念 初学 Spring 的时候 我的问题是 什么是Spring&#xff1f; Spring的底层实现是什么&#xff1f;为什么现在Java都在用sping框架&#xff1f; 1.把Spring类比成乐高说明书 想象一下你有一个超级大的乐高积木盒子&#xff0c;里面有各种各样的积木。你…

智慧城市中的智慧生活:便捷、舒适与高效

目录 一、智慧城市中的智慧生活概述 二、智慧生活带来的便捷性 1、智慧交通的便捷出行 2、智慧购物的轻松体验 3、智慧政务的一站式服务 三、智慧生活带来的舒适性 1、智慧环境的绿色宜居 2、智慧医疗的健康保障 3、智慧教育的均衡发展 四、智慧生活带来的高效性 1、…

CSS案例-5.margin产品模块练习

效果1 相关数据 整体长&#xff1a;298px&#xff0c;高&#xff1a;415px 效果2 知识点 外边距margin 块级盒子水平居中 条件&#xff1a; 必须有宽度左右外边距设为auto 三种写法&#xff1a; margin-left&#xff1a;auto&#xff1b;margin-right&#xff1a;auto&…

高架学习笔记之信息安全基础

目录 一、信息安全基础 1.1. 概念 1.2. 信息存储安全 1.3. 网络安全 二、信息安全系统的组成框架 三、信息加解密技术和数字签名 四、访问控制技术 五、信息安全的保障体系与评估方法 5.1. 计算机信息系统安全保护等级 5.2. 安全风险管理 一、信息安全基础 1.1. 概念 …

linux安装WordPress问题汇总,老是提示无法连接到FTP服务器解决方案

最近在做一些建站相关的事情&#xff0c;遇到一些大大小小的问题都整理在这里 1.数据库密码和端口&#xff0c;千万要复杂一点&#xff0c;不要使用默认的3306端口 2.wordpress算是一个php应用吧&#xff0c;所以安装流程一般是 apache http/nginx——php——mysql——ftp &…

MQTT和Modbus的物联网网关协议区别分析

MQTT和Modbus的物联网网关协议区别分析 MQTT&#xff08;Message Queuing Telemetry Transport&#xff09;与Modbus是两种广泛应用在物联网环境中的通信协议&#xff0c;它们各自具有独特的优势和适用场景&#xff0c;下面将从多个维度对这两种网关协议进行详细区别分析。 首…

win10 使用 IIS 搭建 FTP

0. 背景 首先描述一下需求&#xff0c;大概情况就是&#xff0c;视频文件是存储在笔记本电脑里面&#xff0c;然后偶尔需要投屏到电视上。之前考虑过是否可以通过U盘拷贝的方式&#xff0c;后来发现不行&#xff0c;这样太局限了&#xff0c;需要先明确可能用到的教程&#xf…

docker+k8s相关面试题

dockerk8s k8s详细介绍docker的工作原理docker的组成docker与传统虚拟机的区别docker技术的三大核心概念centos镜像几个G&#xff0c;但是docker centos镜像才几百兆镜像的分层结构以及为什么要使用镜像的分层结构容器的copy-on-write特性&#xff0c;修改容器里面的内容会修改…

汽车功能安全整体方法

摘 要 ISO26262道路车辆功能安全标准已经制定实践了多年&#xff0c;主要目标是应对车辆的电子和电气&#xff08;E/E&#xff09;系统失效。该方法践行至今&#xff0c;有些系统功能安全方法已经成熟&#xff0c;例如电池管理系统&#xff08;BMS&#xff09;&#xff0c;并且…

MATLAB中的cell数组和结构体

MATLAB中的Cell数组和结构体 MATLAB作为一种高级编程语言和数值计算环境&#xff0c;为用户提供了多种数据结构&#xff0c;以便更灵活、高效地处理数据。其中&#xff0c;cell数组和结构体是两种非常重要的数据结构&#xff0c;它们在MATLAB编程和数据管理中发挥着关键作用。…

Latex插入pdf图片,去除空白部分

目录 参考链接&#xff1a; 流程&#xff1a; 参考链接&#xff1a; ​科研锦囊之Latex-如何插入图片、表格、参考文献 http://t.csdnimg.cn/vpSJ3 流程&#xff1a; Latex的图片插入支持PDF文件&#xff0c;这里笔者建议都使用PDF文件进行图片的插入&#xff0c;因为PDF作…

基于spring boot实现接口管理平台

数据库结构 /* Navicat MySQL Data TransferSource Server : localhost_3306 Source Server Version : 50724 Source Host : localhost:3306 Source Database : interfaceTarget Server Type : MYSQL Target Server Version : 50724 File Encoding…