you probably want to use an iterator. Plus you're creating a copy of cv::Vec3f instead of using a const&