mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-05 03:21:42 +00:00
Renamed folders for consistency, using sim/athena/shared schema (#27)
Rename the following folders: hal/lib/Athena -> hal/lib/athena hal/lib/Desktop -> hal/lib/sim hal/lib/Shared -> hal/lib/shared wpilibc/Athena -> wpilibc/athena wpilibc/simulation -> wpilibc/sim Windows users may need to run gradlew clean after updating.
This commit is contained in:
committed by
Peter Johnson
parent
54092378e9
commit
e71f454b9d
83
wpilibc/athena/include/CameraServer.h
Normal file
83
wpilibc/athena/include/CameraServer.h
Normal file
@@ -0,0 +1,83 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2014-2016. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ErrorBase.h"
|
||||
#include "NIIMAQdx.h"
|
||||
#include "USBCamera.h"
|
||||
#include "nivision.h"
|
||||
|
||||
#include <condition_variable>
|
||||
#include <memory>
|
||||
#include <thread>
|
||||
#include <tuple>
|
||||
#include <vector>
|
||||
#include "HAL/cpp/priority_mutex.h"
|
||||
|
||||
class CameraServer : public ErrorBase {
|
||||
private:
|
||||
static constexpr uint16_t kPort = 1180;
|
||||
static constexpr uint8_t kMagicNumber[] = {0x01, 0x00, 0x00, 0x00};
|
||||
static constexpr uint32_t kSize640x480 = 0;
|
||||
static constexpr uint32_t kSize320x240 = 1;
|
||||
static constexpr uint32_t kSize160x120 = 2;
|
||||
static constexpr int32_t kHardwareCompression = -1;
|
||||
static constexpr uint32_t kMaxImageSize = 200000;
|
||||
|
||||
protected:
|
||||
CameraServer();
|
||||
|
||||
std::shared_ptr<USBCamera> m_camera;
|
||||
std::thread m_serverThread;
|
||||
std::thread m_captureThread;
|
||||
priority_recursive_mutex m_imageMutex;
|
||||
std::condition_variable_any m_newImageVariable;
|
||||
std::vector<uint8_t*> m_dataPool;
|
||||
unsigned int m_quality;
|
||||
bool m_autoCaptureStarted;
|
||||
bool m_hwClient;
|
||||
std::tuple<uint8_t*, unsigned int, unsigned int, bool> m_imageData;
|
||||
|
||||
void Serve();
|
||||
void AutoCapture();
|
||||
void SetImageData(uint8_t* data, unsigned int size, unsigned int start = 0,
|
||||
bool imaqData = false);
|
||||
void FreeImageData(
|
||||
std::tuple<uint8_t*, unsigned int, unsigned int, bool> imageData);
|
||||
|
||||
struct Request {
|
||||
uint32_t fps;
|
||||
int32_t compression;
|
||||
uint32_t size;
|
||||
};
|
||||
|
||||
public:
|
||||
static CameraServer* GetInstance();
|
||||
void SetImage(Image const* image);
|
||||
|
||||
void StartAutomaticCapture(
|
||||
char const* cameraName = USBCamera::kDefaultCameraName);
|
||||
|
||||
/**
|
||||
* Start automatically capturing images to send to the dashboard.
|
||||
*
|
||||
* You should call this method to just see a camera feed on the
|
||||
* dashboard without doing any vision processing on the roboRIO.
|
||||
* {@link #SetImage} should not be called after this is called.
|
||||
*
|
||||
* @param camera The camera interface (eg. USBCamera)
|
||||
*/
|
||||
void StartAutomaticCapture(std::shared_ptr<USBCamera> camera);
|
||||
|
||||
bool IsAutoCaptureStarted();
|
||||
|
||||
void SetQuality(unsigned int quality);
|
||||
unsigned int GetQuality();
|
||||
|
||||
void SetSize(unsigned int size);
|
||||
};
|
||||
Reference in New Issue
Block a user