Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

possible mistake in apply_camera_motion #19

Open
arnaud-nt2i opened this issue Jan 28, 2024 · 2 comments
Open

possible mistake in apply_camera_motion #19

arnaud-nt2i opened this issue Jan 28, 2024 · 2 comments
Assignees
Labels
bug Something isn't working enhancement New feature or request

Comments

@arnaud-nt2i
Copy link

arnaud-nt2i commented Jan 28, 2024

Hi @viplix3

Your code in track.cpp/apply_camera_motion is different than the official
Botsort https://github.com/NirAharon/BoT-SORT/blob/main/tracker/bot_sort.py#L68
and yolo_tracking repo https://github.com/mikel-brostrom/yolo_tracking/blob/master/boxmot/trackers/botsort/bot_sort.py#L96

your code:
Eigen::Matrix<float, 8, 8> R8x8 = Eigen::Matrix<float, 8, 8>::Identity();
R8x8.block(0, 0, 2, 2) = R;
mean = R8x8 * mean.transpose();
mean.head(2) += t;
covariance = R8x8 * covariance * R8x8.transpose();

The other:
R = H[:2, :2]
R8x8 = np.kron(np.eye(4, dtype=float), R)
t = H[:2, 2]
for i, (mean, cov) in enumerate(zip(multi_mean, multi_covariance)):
mean = R8x8.dot(mean)
mean[:2] += t
cov = R8x8.dot(cov).dot(R8x8.transpose())
stracks[i].mean = mean
stracks[i].covariance = cov

So it seems you are applying camera motion compensation only to x,y ( and not w,h) while original code apply rotation and shear transform to x,y, w and h.
See np.kron() for Kronecker product.
Is it a mistake, or there is something else ?

Sorry for editing, code writing is broken in github

@arnaud-nt2i
Copy link
Author

arnaud-nt2i commented Jan 29, 2024

Correct code should be :

Eigen::Matrix<float, 8, 8> R8x8 = Eigen::Matrix<float, 8, 8>::Identity();
R8x8.block(0, 0, 2, 2) = R;
R8x8.block(2, 2, 2, 2) = R;
R8x8.block(4, 4, 2, 2) = R;
R8x8.block(6, 6, 2, 2) = R;
mean = R8x8 * mean.transpose();
mean.head(2) += t;
covariance = R8x8 * covariance * R8x8.transpose();

@viplix3
Copy link
Owner

viplix3 commented Feb 19, 2024

I will look into it this weekend

@viplix3 viplix3 self-assigned this Feb 19, 2024
@viplix3 viplix3 added bug Something isn't working enhancement New feature or request labels Feb 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants