1
0
mirror of https://github.com/opencv/opencv_contrib.git synced 2025-10-20 04:25:42 +08:00

Fix compilation warnings about type-punned pointer

dereferencing type-punned pointer will break strict-aliasing rules
This commit is contained in:
Marcin Tolysz
2019-10-06 22:49:01 +01:00
committed by GitHub
parent a8c7a56b89
commit a9639b2ba5

View File

@@ -84,10 +84,11 @@ struct HaarFeature64
__host__ NCVStatus setRect(Ncv32u rectX, Ncv32u rectY, Ncv32u rectWidth, Ncv32u rectHeight, Ncv32u /*clsWidth*/, Ncv32u /*clsHeight*/) __host__ NCVStatus setRect(Ncv32u rectX, Ncv32u rectY, Ncv32u rectWidth, Ncv32u rectHeight, Ncv32u /*clsWidth*/, Ncv32u /*clsHeight*/)
{ {
ncvAssertReturn(rectWidth <= HaarFeature64_CreateCheck_MaxRectField && rectHeight <= HaarFeature64_CreateCheck_MaxRectField, NCV_HAAR_TOO_LARGE_FEATURES); ncvAssertReturn(rectWidth <= HaarFeature64_CreateCheck_MaxRectField && rectHeight <= HaarFeature64_CreateCheck_MaxRectField, NCV_HAAR_TOO_LARGE_FEATURES);
((NcvRect8u*)&(this->_ui2.x))->x = (Ncv8u)rectX; NcvRect8u* tmpRect = (NcvRect8u*)&this->_ui2.x;
((NcvRect8u*)&(this->_ui2.x))->y = (Ncv8u)rectY; tmpRect->x = (Ncv8u)rectX;
((NcvRect8u*)&(this->_ui2.x))->width = (Ncv8u)rectWidth; tmpRect->y = (Ncv8u)rectY;
((NcvRect8u*)&(this->_ui2.x))->height = (Ncv8u)rectHeight; tmpRect->width = (Ncv8u)rectWidth;
tmpRect->height = (Ncv8u)rectHeight;
return NCV_SUCCESS; return NCV_SUCCESS;
} }
@@ -99,11 +100,11 @@ struct HaarFeature64
__device__ __host__ void getRect(Ncv32u *rectX, Ncv32u *rectY, Ncv32u *rectWidth, Ncv32u *rectHeight) __device__ __host__ void getRect(Ncv32u *rectX, Ncv32u *rectY, Ncv32u *rectWidth, Ncv32u *rectHeight)
{ {
NcvRect8u tmpRect = *(NcvRect8u*)(&this->_ui2.x); NcvRect8u* tmpRect = (NcvRect8u*)&this->_ui2.x;
*rectX = tmpRect.x; *rectX = tmpRect->x;
*rectY = tmpRect.y; *rectY = tmpRect->y;
*rectWidth = tmpRect.width; *rectWidth = tmpRect->width;
*rectHeight = tmpRect.height; *rectHeight = tmpRect->height;
} }
__device__ __host__ Ncv32f getWeight(void) __device__ __host__ Ncv32f getWeight(void)