Depending upon how autonomous your system should be will determine the level of complexity of your code. I think this problem is not as easy as just measuring the brilliance of the light from the car headlights. The first problem would be detecting the headlights within the image; the simplest method would be by thresholding the image. Now with your headlights identified you could maybe measure the reflected light from the road immediately in front of the car and use this to determine if the box surrounding the lights should be red or green.
Hopefully, you can get away with thresholding. Given your camera setup, you could determine the circularity of each detected bright region; if enough circular, then and project the center of mass of the Y-axis. If a projected 'pair' exists, low enough in the image, then you're done!
I think the Y-position is more robust than the area of the circular regions. If you also need to detect motorbikes, then leave out the 'pair' constraint.