Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to develop a model to detect a point crossed a line?

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

I guess, No Camera Calibration matrix required, since camera is just looking from top view

enter image description here

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

<polyline label="entry_out" occluded="0" source="manual" points="774.68,499.77;444.65,646.45"> </polyline>
<polyline label="boundary" occluded="0" source="manual" points="406.80,349.70;1031.37,720.00"> </polyline>

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

Please advise, what api and methods I need to use to calibrate the camera using opencv

How to develop a model to detect a point crossed a line?

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

I guess, No Camera Calibration matrix required, since camera is just looking from top view

enter image description here

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

<polyline label="entry_out" occluded="0" source="manual" points="774.68,499.77;444.65,646.45"> </polyline>
<polyline label="boundary" occluded="0" source="manual" points="406.80,349.70;1031.37,720.00"> </polyline>

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

Please advise, what api and methods I need to use to calibrate the camera using opencv

How to develop a model to detect a point crossed a line?

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 hereenter image description here

I guess, No Camera Calibration matrix required, since camera is just looking from top view

enter image description hereenter image description here

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 I draw lines using CVAT

<polyline label="entry_out" occluded="0" source="manual" points="774.68,499.77;444.65,646.45"> </polyline>
<polyline label="boundary" occluded="0" source="manual" points="406.80,349.70;1031.37,720.00"> </polyline>

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

Please advise, what api and methods I need to use to calibrate the camera using opencv

Complex case

Here Trip line, and object never crosses.

complex case

How to develop a model to detect a point crossed a line?

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 hereenter image description here

I guess, No Camera Calibration matrix required, since camera is just looking from top view

enter image description hereenter image description here

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 I draw lines using CVAT

<polyline label="entry_out" occluded="0" source="manual" points="774.68,499.77;444.65,646.45"> </polyline>
<polyline label="boundary" occluded="0" source="manual" points="406.80,349.70;1031.37,720.00"> </polyline>

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

Please advise, what api and methods I need to use to calibrate the camera using opencv

Complex case

Here Trip line, and object never crosses.

complex casecomplex case