To achieve stable target tracking with unmanned aerial vehicles (UAVs), it is essential to generate a safe and effective trajectory that maintains clear visibility of the target. This paper proposes an active observation trajectory planning method for stable target tracking in complex and unknown environments. Firstly, a target prediction model is employed to estimate a sequence of discrete future target positions. Furthermore, based on environmental information, a visible region is determined for each target position, and initial viewpoints are generated, considering both distance and occlusion. A set of cost functions is subsequently designed to optimize these viewpoints for better tracking performance. Finally, the UAV's tracking trajectory is optimized under the constraint of the optimal viewpoint position. Simulations in complex environments demonstrate that the proposed algorithm achieves stable and real-time target tracking while effectively addressing the target occlusion problem observed in existing methods.