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

Function WriteFloFile

cpp/5_Domain_Specific/HSOpticalFlow/main.cpp:49–73  ·  view source on GitHub ↗

////////////////////////////////////////////////////////////////////////// \brief save optical flow in format described on vision.middlebury.edu/flow \param[in] name output file name \param[in] w optical flow field width \param[in] h optical flow field height \param[in] s optical flow field row stride \param[in] u horizontal displacement \param[in] v vertical displacement //////////

Source from the content-addressed store, hash-verified

47/// \param[in] v vertical displacement
48///////////////////////////////////////////////////////////////////////////////
49void WriteFloFile(const char *name, int w, int h, int s, const float *u, const float *v)
50{
51 FILE *stream;
52 stream = fopen(name, "wb");
53
54 if (stream == 0) {
55 printf("Could not save flow to \"%s\"\n", name);
56 return;
57 }
58
59 float data = 202021.25f;
60 fwrite(&data, sizeof(float), 1, stream);
61 fwrite(&w, sizeof(w), 1, stream);
62 fwrite(&h, sizeof(h), 1, stream);
63
64 for (int i = 0; i < h; ++i) {
65 for (int j = 0; j < w; ++j) {
66 const int pos = j + i * s;
67 fwrite(u + pos, sizeof(float), 1, stream);
68 fwrite(v + pos, sizeof(float), 1, stream);
69 }
70 }
71
72 fclose(stream);
73}
74
75///////////////////////////////////////////////////////////////////////////////
76/// \brief

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected