cudacvtfloat.cpp
1021 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <iostream>
#include <unistd.h>
using namespace std;
#include <opencv2/opencv.hpp>
using namespace cv;
#include <openbr/plugins/openbr_internal.h>
#include "cudacvtfloat.hpp"
namespace br
{
/*!
* \ingroup transforms
* \brief Converts byte to floating point
* \author Colin Heinzmann \cite DepthDeluxe
*/
class CUDACvtFloatTransform : public UntrainableTransform
{
Q_OBJECT
public:
void project(const Template &src, Template &dst) const
{
// assume the image type is 256-monochrome
// TODO(colin): real exception handling
if (src.m().type() != CV_8UC1) {
cout << "ERR: Invalid memory format" << endl;
return;
}
int rows = src.m().rows;
int cols = src.m().cols;
dst = Mat(rows, cols, CV_32FC1);
br::cuda::cudacvtfloat::wrapper((const unsigned char*)src.m().ptr<unsigned char>(), dst.m().ptr<float>(), rows, cols);
}
};
BR_REGISTER(Transform, CUDACvtFloatTransform)
} // namespace br
#include "cuda/cudacvtfloat.moc"