|
@@ -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;
|