-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy path1-minimal_example.cpp
More file actions
38 lines (31 loc) · 994 Bytes
/
Copy path1-minimal_example.cpp
File metadata and controls
38 lines (31 loc) · 994 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/**
* @file minimal_example.cpp
* @author wysaid (this@wysaid.org)
* @brief Example for ccap.
* @date 2025-05
*
*/
#include "utils/helper.h"
#include <ccap.h>
#include <iostream>
int main() {
ccap::Provider cameraProvider;
cameraProvider.open(selectCamera(cameraProvider), true);
cameraProvider.start();
if (!cameraProvider.isStarted()) {
std::cerr << "Failed to start camera!" << std::endl;
return -1;
}
for (int i = 0; i < 10; ++i) {
auto frame = cameraProvider.grab(3000);
if (frame) {
printf("VideoFrame %lld grabbed: width = %d, height = %d, bytes: %d, format: %s\n", frame->frameIndex, frame->width,
frame->height, frame->sizeInBytes, ccap::pixelFormatToString(frame->pixelFormat).data());
} else {
std::cerr << "Failed to grab frame!" << std::endl;
exit(-1);
}
}
std::cout << "Captured 10 frames, stopping..." << std::endl;
return 0;
}