Imath::Box2f does what you need.
you don't need count, or keeping track of the min / max values yourself.

Imath::Box2f box; // empty
box.extendBy( box2);
box.extendBy( box3);
...

now box is the bounding box of box2, box3, ...

then you can say viewport_.scroll_to_center_point( box.center());