I don't have a ton of experience with OpenCV but I've played with it enough to know that this is a pretty simple task. You open your device as an instance of the "cv::VideoCapture" class and pipe the frames to a "cv::Mat" class with the output operator (>>).
The only difference is that you seem to want to keep the frames in memory so you would want stuff the cv::Mat classes into a vector or something. There is probably a better class to use, but should be enough to get you started