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

Tips for cropping? #16

Closed
natevw opened this issue Nov 22, 2023 · 5 comments
Closed

Tips for cropping? #16

natevw opened this issue Nov 22, 2023 · 5 comments

Comments

@natevw
Copy link

natevw commented Nov 22, 2023

I am nearly half a kilometer from the tracks but do have a view of passing trains. But I am not getting great results (sidestepping the issues of #15 for now by passing it directly a file path instead of V4L) and wondering if you have any advice/insight.

With the annotated crop region it does detect the motion of the train:

webcam image of train with a rectangle drawn over partial view of train

But it does not combine the whole train, only small bits. This is the first image, i.e. it misses the engine completely:
train_00010101_000038 75_Z

followed by:

train_00010101_000039 75_Z

and:

train_00010101_000136 708_Z

and a nice little stretch:

train_00010101_000156 791_Z

but then that's it for the whole train!

Any tips as to what crop region I should be aiming for? For example, if I expand the box to include the train on both sides of the tree, trainbot seems to just not trigger on the motion at all.

Admittedly this is not very ideal view of the train, but it seems to be showing some promise! 🥳 Any tips as to what to try? What sorts of things matter most — would the first step be to try straighten out the camera so it's not angled? adjust the crop region bigger or smaller? use a longer telephoto lens for more pixels/meter?

@jo-m
Copy link
Owner

jo-m commented Nov 22, 2023

Hi!

  1. The crop region shown looks good IMO. Unless the trains are running much faster than the one shown here, there is little benefit in having a bigger one, especially if there are trees in the way.
  2. Yes, straightening the camera should help, I am sure the patch matching does not work well with this much rotation.
  3. Lastly, have you set the --px-per-m, --min-speed-kph, --max-speed-kph params? This influences the decisionmaking on when a train "starts" and "ends" and can also lead to this slicing you are seeing.

@clonejo
Copy link
Contributor

clonejo commented Nov 22, 2023

I have had some issues with trains being split too often as well. Mostly with ICEs and freight trains. I guess the ICEs just look to uniform in the X direction at some points. And the freight trains do have gaps, at least in the upper two thirds (empty cars).

I have tinkered with the train detection a bunch in clonejo@bed35a5 to make things work, but i need to clean that up before an MR.

@natevw
Copy link
Author

natevw commented Nov 23, 2023

@jo-m Thanks, getting much closer! I think the main thing was rotating it by about 6º anti-clockwise. (And then also had to pre-crop my sample video due to #19.)

Then with:

export INPUT=sample-crop2.mp4
export RECT_X=50
export RECT_Y=50
export RECT_W=198
export RECT_H=133
export PX_PER_M=19
export MIN_SPEED_KPH=5
export MAX_SPEED_KPH=200
./trainbot

I do get quite a bit of the train 🎉

long panorama of a freight train

from this file:

sample-crop2.mp4

but it is missing the front engines. (Which it did detect in an earlier run with some different settings which I've lost :-/ but that was still lots of smaller chunks rather than almost the whole train.)

@natevw
Copy link
Author

natevw commented Nov 23, 2023

I think this can probably be closed, as it was a discussion rather than an issue anyway!

With a little different sample and playing around with exact crop regions and stuff (still only pre-recorded files), I was able to get my first full train panorama! 🎊

train_00010101_000006 96_Z-2

Thank you, so very fun! And @clonejo thank you as well I hope to at some point test out your fork as well and maybe try some of my own changes if I have a chance in coming weeks.

Next step for me is probably get set up with even further telephoto lens and camera mounted better so it's not needing software rotation — then dial in the values better.

@natevw natevw closed this as completed Nov 23, 2023
@jo-m
Copy link
Owner

jo-m commented Nov 23, 2023

nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants