读书人

应用程序无法正常启动(0xc000007b)/

发布时间: 2012-04-23 13:17:38 作者: rapoo

应用程序无法正常启动(0xc000007b)/(0xc0150002),请单击确定关闭程序
我刚重装了win7 x64系统,在上面写了一个vs2008+cuda4.1+opencv2.3(cuda和opencv的环境都已确定配置好了)的图像像素变换的例子,代码在下面,debug版本下编译和链接都没错,运行时就提示“应用程序无法正常启动(0xc000007b)/(0xc0150002),请单击确定关闭程序”,切换到release版本运行就没错。在网上找了各种答案,都说是32位和64位间DirectX的相关dll的问题(网上出现这一问题是在玩游戏软件时,可参考:http://blog.csdn.net/vbcom/article/details/6218535,怀疑不对我的症状),照着改了dll还是没用,跪求大牛指教!



贴出一些调试输出信息:
“AIRWCtest.exe”: 已加载“H:\C++程序\AIRWCtest\x64\Debug\AIRWCtest.exe”,已加载符号。
“AIRWCtest.exe”: 已加载“C:\Windows\System32\ntdll.dll”
“AIRWCtest.exe”: 已加载“C:\Windows\System32\kernel32.dll”
“AIRWCtest.exe”: 已加载“C:\Windows\System32\KernelBase.dll”
“AIRWCtest.exe”: 已加载“D:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.1\bin\cudart64_41_28.dll”,未使用调试信息生成二进制文件。
“AIRWCtest.exe”: 已加载“D:\OpenCV2.3\build\x64\vc9\bin\opencv_highgui230d.dll”
程序“[4700] AIRWCtest.exe: 本机”已退出,返回值为 -1072365566 (0xc0150002)。


贴出源代码:

C/C++ code
#include <cutil_math.h>#include <cutil_inline.h>#include <highgui.h>#include <cv.h>#include <cxcore.h>#include <book.h>#include <cpu_bitmap.h>#define ThreadX  16#define ThreadY  16  texture<float, 2, cudaReadModeElementType> texRefSource;texture<float, 2, cudaReadModeElementType> texRefTarget;__constant__ float c_trans[9];__global__ void transformKernel(float* dev_bitmap,int width, int height){    //计算拾取坐标    unsigned int x = blockIdx.x * blockDim.x + threadIdx.x;    unsigned int y = blockIdx.y * blockDim.y + threadIdx.y;    float3 v=make_float3(x,y,1);    float3 r0=make_float3(c_trans[0],c_trans[1],c_trans[2]);    float3 r1=make_float3(c_trans[3],c_trans[4],c_trans[5]);    float3 r2=make_float3(c_trans[6],c_trans[7],c_trans[8]);    float tz=dot(r2,v);    float tx=dot(r0,v)/tz;    float ty=dot(r1,v)/tz;    //从纹理存储器中拾取数据,并写入显存    dev_bitmap[y * width + x] = tex2D(texRefTarget, tx, ty);}int main(){      // load and set source file    IplImage* source=cvLoadImage("C:\\1368.bmp");     IplImage* sourcegray =cvCreateImage(cvGetSize(source),source->depth,1);    cvCvtColor(source,sourcegray,CV_BGR2GRAY);//image1图像灰度化    int w1 = sourcegray->width;    int h1 = sourcegray->height;    int size1=w1*h1;    cudaArray* SourcecuArray;    cudaChannelFormatDesc channelDesc1 = cudaCreateChannelDesc(32, 0, 0, 0,cudaChannelFormatKindFloat);    cudaMallocArray(&SourcecuArray, &channelDesc1, w1, h1);    cudaMemcpyToArray(SourcecuArray, 0, 0, sourcegray->imageData,size1,cudaMemcpyHostToDevice);        texRefSource.addressMode[0] = cudaAddressModeWrap; //循环寻址方式    texRefSource.addressMode[1] = cudaAddressModeWrap;    texRefSource.filterMode = cudaFilterModeLinear;    cudaBindTextureToArray(texRefSource, SourcecuArray, channelDesc1);            // load and set target file    IplImage* target=cvLoadImage("C:\\1369.bmp");    IplImage* targetgray =cvCreateImage(cvGetSize(target),target->depth,1);    cvCvtColor(target,targetgray,CV_BGR2GRAY);//image1图像灰度化    cvNamedWindow("before", CV_WINDOW_AUTOSIZE );    cvShowImage("before", targetgray);    int w2 = targetgray->width;    int h2 = targetgray->height;    int size2=w2*h2;    cudaArray* TargetcuArray;    cudaChannelFormatDesc channelDesc2 = cudaCreateChannelDesc(32, 0, 0, 0,cudaChannelFormatKindFloat);    cudaMallocArray(&TargetcuArray, &channelDesc2, w2, h2);    cudaMemcpyToArray(TargetcuArray, 0, 0, targetgray->imageData,size2,cudaMemcpyHostToDevice);        texRefTarget.addressMode[0] = cudaAddressModeWrap; //循环寻址方式    texRefTarget.addressMode[1] = cudaAddressModeWrap;    texRefTarget.filterMode = cudaFilterModeLinear;    cudaBindTextureToArray(texRefTarget, TargetcuArray, channelDesc2);    //----------------------构造从image1----->image2的变换矩阵,存入常量内存c_trans----------//     float u[9]={-0.00363945, 123.461, 123.154, 1.0105, 0.868716, 1.2, 1.2, -0.000110196, 0.000174003};     float matM[3][3]={ u[3]*cos(u[0]), u[4]*sin(u[0]),  0,                                 -u[5]*sin(u[0]),  u[6]*cos(u[0]), 0,                                       u[7],             u[8],             1};      CvMat M = cvMat(3,3,CV_32FC1,matM);  //求得的是image2-->image1的M。     CvMat invM = cvMat(3,3,CV_32FC1,matM);  //求得的是image1-->image2的M。     cvInvert(&M,&invM);     for (int i=0;i<3;i++)     {         for (int j=0;j<3;j++)         {             c_trans[i*3+j]=CV_MAT_ELEM(invM,float,i,j);          }     }    //-------------------------------------------------------------//     float *dev_bitmap=NULL;     int size=size1*sizeof(float);     cudaMalloc((void**)&dev_bitmap, size);    //开始变换图像     dim3 blockSize(ThreadX, ThreadY);      dim3 gridSize( (w1+ThreadX-1) / blockSize.x, (h1+ThreadY-1) / blockSize.y);    transformKernel<<<gridSize, blockSize>>>(dev_bitmap,w1,h1);         CPUBitmap bitmap(w1,h1);     cudaMemcpy(bitmap.get_ptr(),(unsigned char*)dev_bitmap,bitmap.image_size(),cudaMemcpyDeviceToHost);     bitmap.display_and_exit();          cvWaitKey(0);     cvReleaseImage(&source);     cvReleaseImage(&sourcegray);     cvReleaseImage(&target);     cvReleaseImage(&targetgray);     cvDestroyAllWindows();     cudaFreeArray(SourcecuArray);     cudaFreeArray(TargetcuArray);     cudaFree(dev_bitmap);     return 0;}                    



[解决办法]
打补丁~~~~~~~~~~

读书人网 >C语言

热点推荐