opencv test

This commit is contained in:
2026-04-29 02:28:18 -05:00
parent 68b4902ecb
commit 9b92546622
2 changed files with 35 additions and 3 deletions

View File

@@ -84,10 +84,34 @@ void Rubiks::run() {
static cv::VideoWriter video;
static bool rolling = false;
static int frames = 0;
static int frames = 30 * 15;
if(rolling) {
frames++;
frames--;
rolling = frames > 0;
uint32_t rowStride = ((1920 + 63) & 0xFFFFFFC0) * sizeof(uint32_t);
long screenBufferSize = rowStride * 1080;
cv::Mat f(1080, 1920, CV_8UC4);
glReadPixels(0, 0, 1920, 1080, GL_RGB, GL_UNSIGNED_BYTE, f.data);
cv::Mat cv_pixels( 1080, 1920, CV_8UC3 );
for( int y=0; y<1080; y++ ) for( int x=0; x<1920; x++ ) {
cv_pixels.at<cv::Vec3b>(y,x)[2] = f.at<cv::Vec3b>(height-y-1,x)[0];
cv_pixels.at<cv::Vec3b>(y,x)[1] = f.at<cv::Vec3b>(height-y-1,x)[1];
cv_pixels.at<cv::Vec3b>(y,x)[0] = f.at<cv::Vec3b>(height-y-1,x)[2];
}
video << cv_pixels;
} else if(frames <= 0) {
video.release();
//UpdateVideoStatus(WM_VIDEO_STATUS_FILE_CLOSED);
}
static float scale = 0.96f;
@@ -196,7 +220,13 @@ void Rubiks::run() {
rubiksCube.solve();
video.open();
video.open("Rubiks.mp4", cv::VideoWriter::fourcc('x', '2', '6', '4'), 30.0, cv::Size(1920, 1080), true);
if(!video.isOpened()) {
std::cout << "VIDEO DID NOT OPEN!\n";
std::abort();
}
//UpdateVideoStatus(WM_VIDEO_STATUS_FILE_OPENED);
}
if(ImGui::Button("randomize")) {

View File

@@ -25,6 +25,7 @@
stb
opencv
pkg-config
];
buildPhase = ''
@@ -44,6 +45,7 @@
-lEGL -lglfw -lGLEW \
$(curl-config --cflags) \
$(curl-config --libs) \
$(pkg-config --cflags --libs opencv4) \
-Wall \
-o $name -DIMGUI_IMPL_GLFW_DISABLE_X11
'';