1 | initial version |
It looks like your problem is that the target has rotational symmetry. So if you rotate 180 degrees it'll look the same. That's what OpenCV is doing, it has no way of telling which way is up or down, so it will flip the order now and then.
You can fix it by add one extra column giving you a 4x9 target. Or you could black tape over a column giving you 4x7. But more points are typically best.
The answer to this question has quite a good description of doing a good calibration. Although some might be a bit over-the-top depending on your needs.