  Active feedback control in magnetic confinement fusion devices is desirable
to mitigate plasma instabilities and enable robust operation. Optical
high-speed cameras provide a powerful, non-invasive diagnostic and can be
suitable for these applications. In this study, we process fast camera data, at
rates exceeding 100kfps, on $\textit{in situ}$ Field Programmable Gate Array
(FPGA) hardware to track magnetohydrodynamic (MHD) mode evolution and generate
control signals in real-time. Our system utilizes a convolutional neural
network (CNN) model which predicts the $n$=1 MHD mode amplitude and phase using
camera images with better accuracy than other tested non-deep-learning-based
methods. By implementing this model directly within the standard FPGA readout
hardware of the high-speed camera diagnostic, our mode tracking system achieves
a total trigger-to-output latency of 17.6$\mu$s and a throughput of up to
120kfps. This study at the High Beta Tokamak-Extended Pulse (HBT-EP) experiment
demonstrates an FPGA-based high-speed camera data acquisition and processing
system, enabling application in real-time machine-learning-based tokamak
diagnostic and control as well as potential applications in other scientific
domains.
