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
|
|
|
|
2018-05-02 20:56:55 -07:00
|
|
|
#include <wpi/raw_ostream.h>
|
2016-10-13 00:18:16 -07:00
|
|
|
|
2017-08-25 17:48:06 -07:00
|
|
|
#include "cscore.h"
|
2016-11-18 11:44:25 -08:00
|
|
|
|
2016-10-13 00:18:16 -07:00
|
|
|
int main() {
|
2018-05-02 20:56:55 -07:00
|
|
|
wpi::outs() << "hostname: " << cs::GetHostname() << '\n';
|
|
|
|
|
wpi::outs() << "IPv4 network addresses:\n";
|
2016-11-18 11:44:25 -08:00
|
|
|
for (const auto& addr : cs::GetNetworkInterfaces())
|
2018-05-02 20:56:55 -07:00
|
|
|
wpi::outs() << " " << addr << '\n';
|
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) {
|
2018-05-02 20:56:55 -07:00
|
|
|
wpi::outs() << "FPS=" << camera.GetActualFPS()
|
|
|
|
|
<< " MBPS=" << (camera.GetActualDataRate() / 1000000.0)
|
|
|
|
|
<< '\n';
|
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
|
|
|
}
|