What opencv api is useful for me to detect is an object touched a drawed line in a image? Thanks

“semantic segmentation” or “instance segmentation”.

a deep learning technique that gives you a per-pixel mask for the object. OpenCV: samples/dnn/segmentation.cpp

you could also try background segmentation, which requires a video, and the object to move/change markedly over time. OpenCV: Tutorials for bgsegm module