Kaynağa Gözat

补充细节

Casper 7 ay önce
ebeveyn
işleme
08dbff881c

+ 0 - 0
test/test-00_video_decode/README-usage.bash


+ 5 - 0
test/test-export-yuv/USAGE.bash

@@ -0,0 +1,5 @@
+## NOTE
+
+# 启动
+cd
+g++ -o zw-test0 zw-test0.cpp `pkg-config --cflags --libs opencv4` && ./zw-test0

+ 6 - 5
test/zw-test0.cpp → test/test-export-yuv/zw-test0.cpp

@@ -8,18 +8,19 @@ void writeYUV420Frame(std::ofstream &file, cv::Mat &frame) {
     cv::cvtColor(frame, yuv_frame, cv::COLOR_BGR2YUV_I420);
 
     // Write Y plane
-    file.write(reinterpret_cast<const char*>(yuv_frame.data), frame.rows * frame.cols);
+    file.write(reinterpret_cast<const char *>(yuv_frame.data), frame.rows * frame.cols);
 
     // Write U and V planes
     int uvHeight = frame.rows / 2;
     int uvWidth = frame.cols / 2;
-    file.write(reinterpret_cast<const char*>(yuv_frame.data + frame.rows * frame.cols), uvHeight * uvWidth);
-    file.write(reinterpret_cast<const char*>(yuv_frame.data + frame.rows * frame.cols + uvHeight * uvWidth), uvHeight * uvWidth);
+    file.write(reinterpret_cast<const char *>(yuv_frame.data + frame.rows * frame.cols), uvHeight * uvWidth);
+    file.write(reinterpret_cast<const char *>(yuv_frame.data + frame.rows * frame.cols + uvHeight * uvWidth),
+               uvHeight * uvWidth);
 }
 
-int main(int argc, char** argv) {
+int main(int argc, char **argv) {
     // Open the default camera
-    cv::VideoCapture cap(0, cv::CAP_V4L2); // 改成0或合适的索引
+    cv::VideoCapture cap(0, cv::CAP_V4L2); // 改成0或合适的索引 /dev/video0
     if (!cap.isOpened()) {
         std::cerr << "Error: Could not open camera" << std::endl;
         return -1;