Sample exhaled gases and count up the CO2 molecules. This number has a strict relationship to the amount of calories expended. The relationship lags a bit and if you generate a large amount of lactic acid that represents energy expended which does not generate CO2 immediately. But as the lactic acid is metabolized the CO2 debt is paid and can be accounted for. This is why it takes a while to catch your breath after stopping strenuous exercise.