Files
allwpilib/cscore/examples/usbstream/usbstream.cpp

36 lines
1.3 KiB
C++
Raw Normal View History

2017-08-25 17:48:06 -07:00
/*----------------------------------------------------------------------------*/
2018-01-02 09:16:20 -08:00
/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */
2017-08-25 17:48:06 -07:00
/* 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. */
/*----------------------------------------------------------------------------*/
#include <cstdio>
#include <wpi/raw_ostream.h>
2017-08-25 17:48:06 -07:00
#include "cscore.h"
int main() {
wpi::outs() << "hostname: " << cs::GetHostname() << '\n';
wpi::outs() << "IPv4 network addresses:\n";
for (const auto& addr : cs::GetNetworkInterfaces())
wpi::outs() << " " << addr << '\n';
cs::UsbCamera camera{"usbcam", 0};
camera.SetVideoMode(cs::VideoMode::kMJPEG, 320, 240, 30);
cs::MjpegServer mjpegServer{"httpserver", 8081};
2016-10-15 22:44:26 -07:00
mjpegServer.SetSource(camera);
CS_Status status = 0;
2018-03-07 01:14:21 -08:00
cs::AddListener(
[&](const cs::RawEvent& event) {
wpi::outs() << "FPS=" << camera.GetActualFPS()
<< " MBPS=" << (camera.GetActualDataRate() / 1000000.0)
<< '\n';
2018-03-07 01:14:21 -08:00
},
cs::RawEvent::kTelemetryUpdated, false, &status);
cs::SetTelemetryPeriod(1.0);
2017-08-25 17:48:06 -07:00
std::getchar();
}