Real-time counting of pedestrians traveling through a transport system are increasingly required for traffic control and management by the companies operating such systems. One of the most widely used systems for counting passengers consists of a mechanical gate equipped with a counter. Such simple systems, however, are not able to count passengers jumping above the gates. Moreover, passengers carrying large luggage or bags may meet some difficulties when going through such gates. The ideal solution is a contact-free counting system that would bring more comfort of use for the passengers. For these reasons, we propose to use a video processing system instead of these mechanical gates. The optical sensors discussed offer several advantages, including well-defined detection areas, fast response time, and reliable counting capability. A new technology is developed and tested, based on linear cameras. For the algorithms, thanks to the principle of our system, no assumption is made about the scene being analyzed and the nature of pedestrian movements to enable the system to run in real time. We also consider the problems presented by crowded scenes, when a high incidence of pedestrians occlusions occurs. Preliminary results have shown that this system is very efficient when the passengers crossing the optical gate are well separated. In other cases, such as in compact crowd conditions, good accuracy in terms of counting in real time is demonstrated. These results are illustrated by means of a number of sequences shot in field conditions.