The most accurate method is direct calorimetry. This is basically a measurement (usually for 24 hours) of the heat produced by the human body. This is usually done in a sealed chamber to fully capture all heat produced.
Next up is indirect calorimetry, where the amount of oxygen consumed and CO2 produced is directly measured, which you can then use to get calories burned.
The other equations that can estimate calorie burn as as follows (For the major ones, there are other minor ones available):
- Harris-Benedict (Original)
- Harris-Benedict (Revised)
- Mifflin St Jeour
These were derived using testing and direct measurements to come up with broad based formulae. While probably not 100% accurate for everyone, they come pretty close. Most of your calorie burn calculators in various treadmills, etc., rely on one of these equations as their base.
The formulae themselves are backed by a lot of research and refinement, however because no two people are alike, they may over or under represent calories burned on an individual basis.
Personally, I like the Katch-McArdle, with the Mifflin equation being nearly equal.
These represent BMR (Basal Metabolic Rate) which accounts for 60-70% of the calories burned in a day. The other values for exercise have been usually pulled from a table, of which there are a few available. These are also somewhat generic, but they have been collated by using indirect calorimetry of individuals during various exercise bouts. So while they are general (like the BMR equations) they have been derived from direct sampling.