TinyUVC 0.1.0
Header-only USB Video Class (UVC) device: turn an MCU into a USB webcam
Loading...
Searching...
No Matches
Classes | Namespaces | Macros
TinyGPU.h File Reference

Integration with TinyGPU (https://github.com/pschatzmann/TinyGPU): UVCDisplayDriver is a TinyGPU DisplayDriver whose "display" is the webcam. Everything that is rendered into a TinyGPU surface (2D drawing, text, sprites, WireFrame3D) and written with writeData() shows up as video on the PC. More...

#include <SPI.h>
#include <Wire.h>
#include <new>
#include <TinyGPU.h>
#include "../TinyUVC.h"
Include dependency graph for TinyGPU.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  tinyuvc::UVCTinyGPUPixel< tinygpu::RGB565 >
 TinyGPU stores RGB565 byte-swapped: the high byte comes first in memory. More...
 
struct  tinyuvc::UVCTinyGPUPixel< tinygpu::RGB888 >
 TinyGPU stores RGB888 as the bytes r, g, b. More...
 
class  tinyuvc::UVCDisplayDriver< RGB_T >
 TinyGPU DisplayDriver that sends the written surfaces as webcam frames to the USB host: uncompressed (YUY2), or compressed with TinyJPEG (MJPEG) - whichever format the host selected. More...
 
struct  tinyuvc::UVCDisplayDriver< RGB_T >::JpegSink
 Output of fmt2jpg_cb() into a frame buffer. More...
 
struct  tinyuvc::UVCDisplayDriver< RGB_T >::Size
 A resolution with the max frame size reported to the host. More...
 

Namespaces

namespace  tinyuvc
 TinyUVC: USB Video Class (UVC) device for Arduino and the desktop.
 

Macros

#define TINYUVC_JPEG_ESP32   0
 
#define TINYUVC_JPEG_TINYJPEG   0
 
#define TINYUVC_HAS_JPEG   (TINYUVC_JPEG_ESP32 || TINYUVC_JPEG_TINYJPEG)
 1 if MJPEG frames can be produced from TinyGPU surfaces
 

Detailed Description

Integration with TinyGPU (https://github.com/pschatzmann/TinyGPU): UVCDisplayDriver is a TinyGPU DisplayDriver whose "display" is the webcam. Everything that is rendered into a TinyGPU surface (2D drawing, text, sprites, WireFrame3D) and written with writeData() shows up as video on the PC.

UVCDevice uvc;
UVCDisplayDriver<RGB565> display(uvc);
FrameBufferRGB565 framebuffer(320, 240, FontRGB565);
void setup() {
display.addResolution(UVCFormat::MJPEG, 320, 240, 15);
display.addResolution(UVCFormat::YUY2, 160, 120, 15);
display.begin();
framebuffer.begin();
}
void loop() {
if (display.sizeChanged(framebuffer.width(), framebuffer.height()))
framebuffer.resize(display.width(), display.height());
framebuffer.clear(RGB565(255, 255, 255));
... // draw
display.writeData(framebuffer); // waits for the next frame slot
}

Uncompressed YUY2 needs 2 bytes per pixel: full speed USB (about 1 MB/s) carries 160x120 at 15+ fps, but 320x240 only at about 5 fps. For bigger pictures offer MJPEG, the frames are then compressed:

Macro Definition Documentation

◆ TINYUVC_HAS_JPEG

#define TINYUVC_HAS_JPEG   (TINYUVC_JPEG_ESP32 || TINYUVC_JPEG_TINYJPEG)

1 if MJPEG frames can be produced from TinyGPU surfaces

◆ TINYUVC_JPEG_ESP32

#define TINYUVC_JPEG_ESP32   0

◆ TINYUVC_JPEG_TINYJPEG

#define TINYUVC_JPEG_TINYJPEG   0