# How to develop a system which detects if a object crosses a line.
I am developing a system, basically which tells a object crossed a line. Do I need to get the camera calibration matrix ? Do I need to understand camera calibration or we can use annotation line points(using CVAT) to calculate the math ? If yes and mandatory, I will go on that path. Please advice.
### Camera calibration matrix is required(mandatory) for below use case?
[![enter image description here][1]][1]
### I guess, No Camera Calibration matrix required, since camera is just looking from top view
[![enter image description here][2]][2]
## My approach,
1. Draw lines using CVAT
2. Write a program using opencv which uses object bouding box center and trip line intersection to calculate the crossing.
[![I draw lines using CVAT ][3]][3]
### My code -
Now when to apply camera calibration ? and How to apply ? Is it required to apply?
def where_it_is(line, cX, cY):
A, B = line
aX = A[0]
aY = A[1]
bX = B[0]
bY = B[1]
val = ((bX - aX) * (cY - aY) - (bY - aY) * (cX - aX))
thresh = 1e-9
if val >= thresh:
return -1
elif val <= -thresh:
return 1
else:
return 0
[1]: https://i.stack.imgur.com/ghRJH.jpg
[2]: https://i.stack.imgur.com/S3stH.jpg
[3]: https://i.stack.imgur.com/CV7I9.jpg
Please advise, what api and methods I need to use to calibrate the camera using opencv
↧