结构体成员赋值问题

z.phantom 2013-01-14 02:39:21
struct PicDataStruct//我自己定义的结构体
{
int width;
int height;
int widthstep;
BYTE* pData;
};

IplImage* pWeight_Destiny//这里面有图像相关数据

下面是出问题的赋值语句:

Weight_DestinyD.width = pWeight_Destiny->width;
Weight_DestinyD.height = pWeight_Destiny->height;

运行结果如下:可以发现width和height的值错位了,对应不上,求解这是为什么?


...全文
244 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
赵4老师 2013-04-11
  • 打赏
  • 举报
回复
To set a breakpoint when a variable changes value From the Edit menu, click Breakpoints. Click the Data tab of the Breakpoints dialog box. In the Expression text box, type the name of the variable. Click OK to set the breakpoint.
赵4老师 2013-01-15
  • 打赏
  • 举报
回复
推荐使用WinHex软件查看硬盘或文件或内存中的原始字节内容。
z.phantom 2013-01-14
  • 打赏
  • 举报
回复
不是,是在:Weight_DestinyD.width = pWeight_Destiny->width; Weight_DestinyD.height = pWeight_Destiny->height;
lee_鹿游原 2013-01-14
  • 打赏
  • 举报
回复


cudaMalloc((void**)&Weight_DestinyD.pData,Weight_DestinyD.width*Weight_DestinyD.height);
cudaMemcpy(Weight_DestinyD.pData,pWeight_Destiny->imageData,Weight_DestinyD.width*Weight_DestinyD.height,cudaMemcpyHostToDevice);
数值是不是在这两部改变的
z.phantom 2013-01-14
  • 打赏
  • 举报
回复
说点有用的好么?
jiaoyun007 2013-01-14
  • 打赏
  • 举报
回复
设个断点跟一下什么都清楚了..
z.phantom 2013-01-14
  • 打赏
  • 举报
回复
交谈中请勿轻信汇款、中奖信息、陌生电话,勿使用外挂软件。 For phantom 15:55:19 BOOL GPUProcess(IplImage** pSource,IplImage* pWeight_Destiny,double*** WeightTemp,double*** ResultTemp, HostDataConstant& m_data_constant) { PicDataStruct *pSourceD = NULL; PicDataStruct Weight_DestinyD; int imgheight = pWeight_Destiny->height; int imgwidth = pWeight_Destiny->width; /*Weight_DestinyD.width = pWeight_Destiny->width; Weight_DestinyD.height = pWeight_Destiny->height;*/ cudaMalloc((void**)&Weight_DestinyD.pData,Weight_DestinyD.width*Weight_DestinyD.height); cudaMemcpy(Weight_DestinyD.pData,pWeight_Destiny->imageData,Weight_DestinyD.width*Weight_DestinyD.height,cudaMemcpyHostToDevice); int size = 0; pSourceD = new PicDataStruct[m_data_constant.NumofImgs]; assert(pSourceD!=NULL); if (pSourceD == NULL) { return FALSE; } for (int i = 0;i!=m_data_constant.NumofImgs;i++) { size = pSource[i]->width*pSource[i]->height; cudaMalloc((void**)&pSourceD[i].pData,size); pSourceD[i].height = pSource[i]->height; pSourceD[i].width = pSource[i]->width; pSourceD[i].widthstep = m_data_constant.StepHighRes; cudaMemcpy(pSourceD[i].pData,(unsigned char*)pSource[i]->imageData,size,cudaMemcpyHostToDevice); } dim3 blocks(8,8); int tempt_size = (m_data_constant.HighSearchSize+m_data_constant.HighPatchSize)/2; dim3 grids(((pSource[0]->width-tempt_size)/m_data_constant.SRFactor-blocks.x+1)/blocks.x,(pSource[0]->height-tempt_size)/m_data_constant.SRFactor-blocks.y+1/blocks.y); double* WeightTempD; size_t pitchWeight; cudaMallocPitch((void**)&WeightTempD,&pitchWeight,m_data_constant.matrixwidth*sizeof(double),m_data_constant.matrixheight); double* ResultTempD=NULL; size_t pitchResult; cudaMallocPitch((void**)&WeightTemp,&pitchResult,m_data_constant.matrixwidth*sizeof(double),m_data_constant.matrixheight); kernel<<<grids,blocks>>>(pSourceD,&Weight_DestinyD,WeightTempD,pitchWeight,ResultTempD,pitchResult,&m_data_constant); cudaThreadSynchronize(); cudaMemcpy(WeightTemp,WeightTempD,m_data_constant.matrixheight*m_data_constant.matrixwidth,cudaMemcpyDeviceToHost); cudaMemcpy(ResultTemp,ResultTempD,m_data_constant.matrixheight*m_data_constant.matrixwidth,cudaMemcpyDeviceToHost); cudaFree(Weight_DestinyD.pData); for (int i = 0;i!=m_data_constant.NumofImgs;i++) { cudaFree(pSourceD[i].pData); } cudaFree(WeightTempD); cudaFree(ResultTempD); cudaFree(WeightTemp); return TRUE; }
z.phantom 2013-01-14
  • 打赏
  • 举报
回复
这个赋值代码是在cu文件中的,不知道是不是GPU字节对齐的问题。大家说要贴相关代码,其他代码太多并且没什么关系,IplImage* pWeight_Destiny,这里面有图像相关数据,说的比较明白了吧
fortunate1y 2013-01-14
  • 打赏
  • 举报
回复

IplImage* pWeight_Destiny
这之后有给pWeight_Destiny赋值或初始化的操作代码吗?贴出来看看。
jimette 2013-01-14
  • 打赏
  • 举报
回复
诡异啊。。。。。
hilter 2013-01-14
  • 打赏
  • 举报
回复
跟踪调试看看什么情况
lee_鹿游原 2013-01-14
  • 打赏
  • 举报
回复
楼主该你贴代码了。
z.phantom 2013-01-14
  • 打赏
  • 举报
回复
这就是一个简单的初始化,117不知道怎么来的,而且我直接给Weight_DestinyD.width 赋0值,它依然显示是117
sduxiaoxiang 2013-01-14
  • 打赏
  • 举报
回复
木有代码 赋值错误?
lee_鹿游原 2013-01-14
  • 打赏
  • 举报
回复
我比较怀疑,117从何而来..
Gonefar 2013-01-14
  • 打赏
  • 举报
回复
上一些相关代码吧。。

69,336

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧