A hard X-ray pinhole camera system has been recently built at the HL-2A tokamak to measure the evolution of space-time distribution of fast electrons in the energy range of 20 to 200 keV. The camera is mainly composed of a fan-shaped detector array, an observation window, a pinhole mechanism, and a data processing system. The detector array consists of 21 CdTe detectors that are arranged in a poloidal section. The camera views the plasma perpendicularly through an observation window mounted in a horizontal port on the equatorial plane. The data processing is implemented by a fast spectrometry based on field-programmable gate array technology. The time and space resolution of the camera can reach 2 to 16 ms and 2 cm, respectively. During the HL-2A experiment campaign in 2018, measurements of fast electrons produced by lower hybrid waves using the camera were successfully performed. The performance of the camera and the first experimental results with some discussions are presented in this paper.