Media Foundation commonly delivers RGB32 bottom-up (negative MF_MT_DEFAULT_STRIDE); a flat top-down memcpy would make the preview and published feed upside-down. read_frame now copies row by row honoring the signed stride (flip when negative, handle padded strides), producing a top-down BGRA frame per the MS Image Stride spec. Orientation is logged at open.
45 lines
886 B
C++
45 lines
886 B
C++
#ifndef TRACKER_NATIVE_WIN_CAMERA_H
|
|
#define TRACKER_NATIVE_WIN_CAMERA_H
|
|
|
|
#include <cstdint>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace kinect_tracker {
|
|
|
|
struct CameraDevice {
|
|
std::wstring symbolic_link;
|
|
std::string name;
|
|
};
|
|
|
|
struct CameraResolution {
|
|
int width;
|
|
int height;
|
|
};
|
|
|
|
std::vector<CameraDevice> enumerate_cameras();
|
|
std::vector<CameraResolution> enumerate_resolutions(const std::wstring& symbolic_link);
|
|
|
|
class Camera {
|
|
public:
|
|
Camera() = default;
|
|
~Camera();
|
|
Camera(const Camera&) = delete;
|
|
Camera& operator=(const Camera&) = delete;
|
|
|
|
bool open(const std::wstring& symbolic_link, int width, int height);
|
|
bool read_frame(std::vector<uint8_t>& bgra, int& width, int& height);
|
|
void close();
|
|
bool is_open() const { return reader_ != nullptr; }
|
|
|
|
private:
|
|
void* reader_ = nullptr;
|
|
int width_ = 0;
|
|
int height_ = 0;
|
|
int stride_ = 0;
|
|
};
|
|
|
|
}
|
|
|
|
#endif
|