# Adjusting Viz camera parameters yields stuttering effect

I am trying to make an animation with OpenCV's viz module (version 3.3; but 3.2 seems to have the same issue). More precisely, I am adjusting the intrinsic camera parameters programmatically to illustrate their effect. So far, everything works fine, except for the fact that the animation yields a strange stuttering effect. For example, when adjusting the focal length, there is a slight up-and-down movement in every second step of the animation. The movement is reproducible (albeit unwanted) and always between the same two (relative) positions. I reduced my animation code to the following minimum:

#include <iostream>
#include <opencv2/viz.hpp>

using namespace std;
using namespace cv;
using namespace cv::viz;

int main()
{
Viz3d window("Test");
window.showWidget("Test object", WCone(1, 0.5, 100));
window.spinOnce(1, true); //If this is not called here, getCamera returns different values and setCamera below throws a stack underflow exception!?
const auto camera = window.getCamera();
const auto focal_length = camera.getFocalLength();
const int fx = focal_length[0]; //Deliberate round to int
const int fy = focal_length[1];
const auto principal_point = camera.getPrincipalPoint();
const int px = principal_point[0];
const int py = principal_point[1];

for (int i = 1; i <= 30; i++)
{
cout << "Iteration " << i << endl;
const auto old_camera = window.getCamera();
Matx44d matrix;
old_camera.computeProjectionMatrix(matrix);
cout << "Old proj. matrix: " << matrix << endl;
Camera new_camera(fx - 10 * i, fy, px, py, old_camera.getWindowSize());
new_camera.computeProjectionMatrix(matrix);
cout << "New proj. matrix: " << matrix << endl;
window.setCamera(new_camera);
window.spinOnce(500, true);
}
return 0;
}


I am aware that numerical inaccuracies could be to blame for this, but the effect is far to severe for it only being that. The effect becomes even stronger for larger deviations from the initial parameters and increases when I change multiple parameters at once.

How can I reduce this stuttering effect? It remains (to the same extent) even when I change 10 * i to i for very small animation steps.

Remark: I also posted this here a while ago, but did not get any replies

edit retag close merge delete
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.1892460435628891, "perplexity": 5806.440665009513}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2017-34/segments/1502886106779.68/warc/CC-MAIN-20170820150632-20170820170632-00468.warc.gz"}