2020-12-26 14:12:05 -08:00
|
|
|
// Copyright (c) FIRST and other WPILib contributors.
|
|
|
|
|
// Open Source Software; you can modify and/or share it under the terms of
|
|
|
|
|
// the WPILib BSD license file in the root directory of this project.
|
2017-08-25 17:48:06 -07:00
|
|
|
|
|
|
|
|
#include <cstdio>
|
2016-10-13 00:18:16 -07:00
|
|
|
|
2025-11-07 19:56:21 -05:00
|
|
|
#include "wpi/cs/cscore.h"
|
2025-11-07 19:57:55 -05:00
|
|
|
#include "wpi/util/print.hpp"
|
2016-11-18 11:44:25 -08:00
|
|
|
|
2016-10-13 00:18:16 -07:00
|
|
|
int main() {
|
2024-05-12 06:25:42 -07:00
|
|
|
wpi::print("hostname: {}\n", cs::GetHostname());
|
2021-06-06 16:13:58 -07:00
|
|
|
std::puts("IPv4 network addresses:");
|
2020-12-28 12:58:06 -08:00
|
|
|
for (const auto& addr : cs::GetNetworkInterfaces()) {
|
2024-05-12 06:25:42 -07:00
|
|
|
wpi::print(" {}\n", addr);
|
2020-12-28 12:58:06 -08:00
|
|
|
}
|
2018-03-04 21:01:55 -08:00
|
|
|
cs::UsbCamera camera{"usbcam", 0};
|
2016-10-13 00:18:16 -07:00
|
|
|
camera.SetVideoMode(cs::VideoMode::kMJPEG, 320, 240, 30);
|
2016-12-04 00:08:47 -08:00
|
|
|
cs::MjpegServer mjpegServer{"httpserver", 8081};
|
2016-10-15 22:44:26 -07:00
|
|
|
mjpegServer.SetSource(camera);
|
|
|
|
|
|
2018-03-04 21:01:55 -08:00
|
|
|
CS_Status status = 0;
|
2018-03-07 01:14:21 -08:00
|
|
|
cs::AddListener(
|
|
|
|
|
[&](const cs::RawEvent& event) {
|
2024-05-12 06:25:42 -07:00
|
|
|
wpi::print("FPS={} MBPS={}\n", camera.GetActualFPS(),
|
2021-06-06 16:13:58 -07:00
|
|
|
(camera.GetActualDataRate() / 1000000.0));
|
2018-03-07 01:14:21 -08:00
|
|
|
},
|
|
|
|
|
cs::RawEvent::kTelemetryUpdated, false, &status);
|
2018-03-04 21:01:55 -08:00
|
|
|
cs::SetTelemetryPeriod(1.0);
|
|
|
|
|
|
2017-08-25 17:48:06 -07:00
|
|
|
std::getchar();
|
2016-10-13 00:18:16 -07:00
|
|
|
}
|