MCPcopy Create free account
hub / github.com/NVIDIA/cuda-samples / CompareWithGold

Function CompareWithGold

cpp/5_Domain_Specific/HSOpticalFlow/main.cpp:135–157  ·  view source on GitHub ↗

////////////////////////////////////////////////////////////////////////// \brief compare given flow field with gold (L1 norm) \param[in] width optical flow field width \param[in] height optical flow field height \param[in] stride optical flow field row stride \param[in] h_uGold horizontal displacement, gold \param[in] h_vGold vertical displacement, gold \param[in] h_u horizontal dis

Source from the content-addressed store, hash-verified

133/// \return true if discrepancy is lower than a given threshold
134///////////////////////////////////////////////////////////////////////////////
135bool CompareWithGold(int width,
136 int height,
137 int stride,
138 const float *h_uGold,
139 const float *h_vGold,
140 const float *h_u,
141 const float *h_v)
142{
143 float error = 0.0f;
144
145 for (int i = 0; i < height; ++i) {
146 for (int j = 0; j < width; ++j) {
147 const int pos = j + i * stride;
148 error += fabsf(h_u[pos] - h_uGold[pos]) + fabsf(h_v[pos] - h_vGold[pos]);
149 }
150 }
151
152 error /= (float)(width * height);
153
154 printf("L1 error : %.6f\n", error);
155
156 return (error < THRESHOLD);
157}
158
159///////////////////////////////////////////////////////////////////////////////
160/// application entry point

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected