mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
Cleaned up integer type usage in wpilibc (#92)
Replaced all unsigned types to signed and int32_t with int in wpilibc
This commit is contained in:
committed by
Peter Johnson
parent
ff93050b31
commit
0cd05d1a42
@@ -40,7 +40,7 @@ CameraServer::CameraServer()
|
||||
}
|
||||
|
||||
void CameraServer::FreeImageData(
|
||||
std::tuple<uint8_t*, unsigned int, unsigned int, bool> imageData) {
|
||||
std::tuple<uint8_t*, int, int, bool> imageData) {
|
||||
if (std::get<3>(imageData)) {
|
||||
imaqDispose(std::get<0>(imageData));
|
||||
} else if (std::get<0>(imageData) != nullptr) {
|
||||
@@ -49,8 +49,8 @@ void CameraServer::FreeImageData(
|
||||
}
|
||||
}
|
||||
|
||||
void CameraServer::SetImageData(uint8_t* data, unsigned int size,
|
||||
unsigned int start, bool imaqData) {
|
||||
void CameraServer::SetImageData(uint8_t* data, int size, int start,
|
||||
bool imaqData) {
|
||||
std::lock_guard<priority_recursive_mutex> lock(m_imageMutex);
|
||||
FreeImageData(m_imageData);
|
||||
m_imageData = std::make_tuple(data, size, start, imaqData);
|
||||
@@ -58,7 +58,7 @@ void CameraServer::SetImageData(uint8_t* data, unsigned int size,
|
||||
}
|
||||
|
||||
void CameraServer::SetImage(Image const* image) {
|
||||
unsigned int dataSize = 0;
|
||||
uint32_t dataSize = 0;
|
||||
uint8_t* data = reinterpret_cast<uint8_t*>(
|
||||
imaqFlatten(image, IMAQ_FLATTEN_IMAGE, IMAQ_COMPRESSION_JPEG,
|
||||
10 * m_quality, &dataSize));
|
||||
@@ -70,7 +70,7 @@ void CameraServer::SetImage(Image const* image) {
|
||||
std::lock_guard<priority_recursive_mutex> lock(m_imageMutex);
|
||||
hwClient = m_hwClient;
|
||||
}
|
||||
unsigned int start = 0;
|
||||
uint32_t start = 0;
|
||||
if (hwClient) {
|
||||
while (start < dataSize - 1) {
|
||||
if (data[start] == 0xFF && data[start + 1] == 0xD8)
|
||||
@@ -101,7 +101,7 @@ void CameraServer::AutoCapture() {
|
||||
}
|
||||
|
||||
if (hwClient) {
|
||||
unsigned int size = m_camera->GetImageData(data, kMaxImageSize);
|
||||
int size = m_camera->GetImageData(data, kMaxImageSize);
|
||||
SetImageData(data, size);
|
||||
} else {
|
||||
m_camera->GetImage(frame);
|
||||
@@ -134,7 +134,7 @@ bool CameraServer::IsAutoCaptureStarted() {
|
||||
return m_autoCaptureStarted;
|
||||
}
|
||||
|
||||
void CameraServer::SetSize(unsigned int size) {
|
||||
void CameraServer::SetSize(int size) {
|
||||
std::lock_guard<priority_recursive_mutex> lock(m_imageMutex);
|
||||
if (!m_camera) return;
|
||||
if (size == kSize160x120)
|
||||
@@ -145,12 +145,12 @@ void CameraServer::SetSize(unsigned int size) {
|
||||
m_camera->SetSize(640, 480);
|
||||
}
|
||||
|
||||
void CameraServer::SetQuality(unsigned int quality) {
|
||||
void CameraServer::SetQuality(int quality) {
|
||||
std::lock_guard<priority_recursive_mutex> lock(m_imageMutex);
|
||||
m_quality = quality > 100 ? 100 : quality;
|
||||
}
|
||||
|
||||
unsigned int CameraServer::GetQuality() {
|
||||
int CameraServer::GetQuality() {
|
||||
std::lock_guard<priority_recursive_mutex> lock(m_imageMutex);
|
||||
return m_quality;
|
||||
}
|
||||
@@ -238,7 +238,7 @@ void CameraServer::Serve() {
|
||||
auto period = std::chrono::microseconds(1000000) / req.fps;
|
||||
while (true) {
|
||||
auto startTime = std::chrono::steady_clock::now();
|
||||
std::tuple<uint8_t*, unsigned int, unsigned int, bool> imageData;
|
||||
std::tuple<uint8_t*, int, int, bool> imageData;
|
||||
{
|
||||
std::unique_lock<priority_recursive_mutex> lock(m_imageMutex);
|
||||
m_newImageVariable.wait(lock);
|
||||
@@ -246,9 +246,9 @@ void CameraServer::Serve() {
|
||||
m_imageData = std::make_tuple<uint8_t*>(nullptr, 0, 0, false);
|
||||
}
|
||||
|
||||
unsigned int size = std::get<1>(imageData);
|
||||
unsigned int netSize = htonl(size);
|
||||
unsigned int start = std::get<2>(imageData);
|
||||
int size = std::get<1>(imageData);
|
||||
int netSize = htonl(size);
|
||||
int start = std::get<2>(imageData);
|
||||
uint8_t* data = std::get<0>(imageData);
|
||||
|
||||
if (data == nullptr) continue;
|
||||
|
||||
Reference in New Issue
Block a user