Create custom main loop, or not? (Compare images to their appearance in real life)

Hey,

I am working on a project, where lot of images are projected one by one on to real-world objects and camera takes pictures of them. The main point is to capture all the projected images with the camera and pair them up with the original one, to compare the image to how it appears in real life.
The camera is synced with the projector vsync signal, so it takes pictures of every frame.
The problem is, that the main loop runs by itself. And I couldn’t organise my code nicely this way.

I think the ideal code would be something similar:

while(true){
    draw(image) // block until vsync? so it actually appears on screen
    appearance = capture() // this line of code should capture the image projected in real life
}

I was thinking about creating my custom main loop instead of using the built in of loop.
So how to make my own main loop and call of’s draw method that blocks until vsync?
Or is it a bad idea? Is there some other way to achieve this?

(I am dealing with a lot of images, so the images should run as fast as the projector can display them)