首页 > 编程知识 正文

globalmapper测量面积(c语言坐标怎么表示)

时间:2023-05-06 04:46:20 阅读:72126 作者:4870

函数背景:假设sensor生成的图的大小为3264*2448,而选定的capture的大小(即照片的大小)为3264*1836。 此时,如果需要将传感器上的roi区域映射到捕获

操作步骤:

1 .首先判断roi是否为正方形,否则,映射到capture的roi也应该为正方形

2 .判断sensor的宽高比与capture的宽高比是否相等,如果不相等,则需要切出capture的size,与sensor的宽高比相匹配,便于以后进行坐标映射

将传感器上的roi坐标映射到捕获

如果sensor上的roi为方形,则映射到capture的roi也必须为方形

具体实施和示例:

# if1 # includeiostreamusingnamespacestd; struct img _ size { unsigned int width; unsigned int height; (; int camera _ convert _ coor _ sensor _ to _ capture (conststructimg _ size * sensor _ size,conststructimg _ size * capture sructimg _ size capture={ 3264,1836 }; unsignedintcropregion [4]={ 1042,856,2120,1590 }; camera _ convert _ coor _ sensor _ to _ capture (sensor,capture,cropRegion ); 返回0; } int camera _ convert _ coor _ sensor _ to _ capture (conststructimg_size* sensor _ size,conststructimg _ size * ) conststructimg _ size unsigned int * crop region (浮动左=0,top=0,宽度=0,高度=0,zoom宽度=0,zoomHeight=0 int ret=0; int flag_square=0; unsigned int roiW=0,roiH=0; unsigned int capture_width=0,capture_height=0; unsigned int sensor_width=0,sensor_height=0; printf (before _ crop _ rect _ calculated 3360 ) sx=%d,sy=%d,ex=%d,ey=%d )n ',cropRegion[0],rrop roih=crop region [3]-crop region [1]; if(roiw==0||roih==0) ) printf('parameterserror.' ); 返回1; }//if roi is square,itshouldbesquareaftreconversionif (roiw==roih ) flag_square=1; capture _ width=capture _ size-width; capture _ height=capture _ size-height; sensor_width=sensor_size-width; sensor _ height=sensor _ size-height; 浮动传感器aspect=(浮动) sensor_width/sensor_height; 浮动捕捉=(浮动) capture_width/capture_height; //ifsensoraspectandcaptureaspectarenotequal,//thesizeofcaptureshouldbecuttofittheaspectofsensorif (height=捕获辅助left=0; top=0(capture_height-height )/2; } else { width=sensor aspect * capture _ width/capture aspect; height=capture_height; left=0(capture_width-width )/2; top=0; } zoom width=width/(浮动) sensor_width; zoom height=height/(浮动) sensor_height; printf(sensoraspect=%f,captureAspect=%f,width=%f,height=%f,left=%f,top=%f,zoom width=% f crop ROP cropregion[1]=(unsignedint () float ) cropRegion[1] * zoomHeight top ); cropregion[2]=(unsignedint ) float ) cropRegion[2] * zoomWidth left ); cropregion[3]=(unsignedint () float () cropregion )3) *zoomheighttop ); //If it was originally square,itshouldbesquareafterconversionroiw=crop region [2]-crop region [0]; roih=crop region [3]-crop region [1]; if(flag_square==1) printf (cropcalculatedbeforecorrect (sx=% d,sy=%d,ex=%d,ey=%d,ey=%d )n }elseif(roihroiw ) cropregion(3)=crop region (1) roiw; }flag_square=0; } printf (after _ crop _ rect _ calculated 3360 ) sx=%d,sy=%d,ex=%d,ey=%d ),cropRegion[0],cro OTF RRD }#endif

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。