- gray.exec(tex1, tex1_gray, width, height);
- glGenerateTextureMipmap(tex1_gray);
- glDeleteTextures(1, &tex1);
-
- GLuint final_tex = compute_flow.exec(tex0_gray, tex1_gray, DISComputeFlow::RESIZE_FLOW_TO_FULL_SIZE);
-
- schedule_read<FlowType>(final_tex, width1, height1, filename0, filename1, flow_filename, "");
- compute_flow.release_texture(final_tex);
- }
- glDeleteTextures(1, &tex0_gray);
- glDeleteTextures(1, &tex1_gray);
-
- while (!reads_in_progress.empty()) {
- finish_one_read<FlowType>(width1, height1);
- }
-}
-
-// Interpolate images based on
-//
-// Herbst, Seitz, Baker: “Occlusion Reasoning for Temporal Interpolation
-// Using Optical Flow”
-//
-// or at least a reasonable subset thereof. Unfinished.
-void interpolate_image(int argc, char **argv, int optind)
-{
- const char *filename0 = argc >= (optind + 1) ? argv[optind] : "test1499.png";
- const char *filename1 = argc >= (optind + 2) ? argv[optind + 1] : "test1500.png";
- //const char *out_filename = argc >= (optind + 3) ? argv[optind + 2] : "interpolated.png";
-
- // Load pictures.
- unsigned width1, height1, width2, height2;
- GLuint tex0 = load_texture(filename0, &width1, &height1, WITH_MIPMAPS);
- GLuint tex1 = load_texture(filename1, &width2, &height2, WITH_MIPMAPS);
-
- if (width1 != width2 || height1 != height2) {
- fprintf(stderr, "Image dimensions don't match (%dx%d versus %dx%d)\n",
- width1, height1, width2, height2);
- exit(1);
- }
-
- // Set up some PBOs to do asynchronous readback.
- GLuint pbos[5];
- glCreateBuffers(5, pbos);
- for (int i = 0; i < 5; ++i) {
- glNamedBufferData(pbos[i], width1 * height1 * 4 * sizeof(uint8_t), nullptr, GL_STREAM_READ);
- spare_pbos.push(pbos[i]);
- }
-
- DISComputeFlow compute_flow(width1, height1);
- GrayscaleConversion gray;
- Interpolate interpolate(width1, height1, finest_level);
-
- int levels = find_num_levels(width1, height1);
- GLuint tex0_gray, tex1_gray;
- glCreateTextures(GL_TEXTURE_2D, 1, &tex0_gray);
- glCreateTextures(GL_TEXTURE_2D, 1, &tex1_gray);
- glTextureStorage2D(tex0_gray, levels, GL_R8, width1, height1);
- glTextureStorage2D(tex1_gray, levels, GL_R8, width1, height1);
-
- gray.exec(tex0, tex0_gray, width1, height1);
- glGenerateTextureMipmap(tex0_gray);
-
- gray.exec(tex1, tex1_gray, width1, height1);
- glGenerateTextureMipmap(tex1_gray);
-
- GLuint forward_flow_tex = compute_flow.exec(tex0_gray, tex1_gray, DISComputeFlow::DO_NOT_RESIZE_FLOW);
- GLuint backward_flow_tex = compute_flow.exec(tex1_gray, tex0_gray, DISComputeFlow::DO_NOT_RESIZE_FLOW);
-
- for (int frameno = 1; frameno < 60; ++frameno) {
- char ppm_filename[256];
- snprintf(ppm_filename, sizeof(ppm_filename), "interp%04d.ppm", frameno);
-
- float alpha = frameno / 60.0f;
- GLuint interpolated_tex = interpolate.exec(tex0, tex1, forward_flow_tex, backward_flow_tex, width1, height1, alpha);
-
- schedule_read<RGBAType>(interpolated_tex, width1, height1, filename0, filename1, "", ppm_filename);
- interpolate.release_texture(interpolated_tex);
- }
-
- while (!reads_in_progress.empty()) {
- finish_one_read<RGBAType>(width1, height1);