Obstacle detection is crucial for the safety and efficiency of autonomous vehicles. For mini-vehicles such as palm-sized drones, it is a challenge to implement traditional methods like Lidar due to high costs and physical constraints. Vision-based deep learning approaches, while accurate, are too resource-intensive for the mini-vehicles. To address this issue, we introduce Flowdep, a novel optical-flow-based algorithm inspired by the low-resolution but efficient motion-detection mechanisms in insects. Flowdep combines optic flow and IMU (or positioning information) to estimate the depth of every image pixel. We also generate a variant of Flowdep using the artificial neural network (Flowdep-ANN). Our tests show that Flowdep and Flowdep-ANN are 5.8 to 114.7 times faster than the DNN networks we tested, while the accuracies of Flowdep and Flowdep-ANN are on par with these networks. We further tested Flowdep and Flowdep-ANN on a small autonomous vehicle with Raspberry Pi4 as the computing platform, and both models successfully performed real-time object detection. The present work demonstrates the potential of using optical flow as an efficient approach to estimate depth and detect obstacles in resource-constrained mini-vehicles.