With the development of society, water pollution has become the most serious problem in China. Therefore, real-time water quality monitoring is an important part of human activities and water pollution prevention. In this paper, the behavior of zebrafish was monitored by computer vision. Firstly, the moving target was extracted by the method of saliency detection, and tracked by fitting the ellipse model. Then the motion parameters were extracted by optical flow method, and the data were monitored in real time by means of Hinkley warning and threshold warning. We achieved classification warning through a number of dimensions by comprehensive toxicity index. The experimental results show that the system can achieve more accurate real-time monitoring.