SUBSIM: The Web's #1 BBS for all submarine and naval simulations since 1997 
04102019, 09:02 AM  #1 
Seaman
Join Date: Jan 2013
Location: Hong Kong
Posts: 37
Downloads: 65
Uploads: 2

Automatic TMA tool based on computer vision
This is my another open sourced project on automatic TMA. (code: https://github.com/LJQCN101/AutoTMAopencv)
Instructions on how to use is in the download page: http://www.subsim.com/radioroom/down...o=file&id=5464 This program is meant to assist your manual TMA process, as in real world sub does, in an external and mathematical way. It basically takes an image as input, like this image: And it will perform cropping and line detection on the TMA display window. The program will ask you to handlabel all the detected lines numerically in chronological order, starting from 0. This will let the program know the time sequence of each bearing line. If the detected line appears not to be a bearing line, you can simply enter a negative number, such as 1, to exclude it from the TMA computation. (v0.3 update) You can also enter the speed of TMA ruler so the program can calculate proper speed of each solution. (v0.3 update) Speed constraint is added to only show solutions of specific speed. An example of output with speed constraint of 8.3 knots, if TMA ruler corresponds to 10 knots: An example of output without speed constraint, if TMA ruler corresponds to 5 knots: Another example, taken from sub command tutorial:
__________________
Automatic TMA calculator for Wolfpack Automatic TMA line detector and solver for DW/SC/688i Last edited by ljqcn101; 05242019 at 01:21 AM. 
04102019, 09:07 AM  #2 
Seaman
Join Date: Jan 2013
Location: Hong Kong
Posts: 37
Downloads: 65
Uploads: 2

For anyone who is interested in the formulas of automatic TMA:
First I set three unknown variables, 1. target distance at first bearing as "L1_distance" 2. target course as "crs" 3. target speed as "spd" Let ownship coordinate be (m,n). Y axis points to north (0 deg), and X axis points to east (90 deg). All angles start at Y axis and rotate in clockwise direction. So we can get: 1. target speed component on x axis "u" = spd * sin(crs) 2. target speed component on y axis "v" = spd * cos(crs) 3. target coordinate (a,b) at first bearing = m1+L1_distance*sin(brg1), n1+L1_distance*cos(brg1) 4. target coordinate (x,y) at time t = (a+u*t, b+v*t) 5. the vector pointing from ownship to target = (xm, yn) By knowing the bearing of this vector, we can get the bearing vector equation: (yn)*sin(brg) = (xm)*cos(brg) Since we have three unknown variables to solve, in order to make sure the left hand side of the equation is really close to the right hand side, we can use the least square method: Let formula f(t) = (yn)*sin(brg)  (xm)*cos(brg) So we need to minimise the sum of squared f(t) for all bearing vectors. I used BFGS algorithm to solve this utilising C++ Dlib library. 
05242019, 01:39 AM  #3 
Seaman
Join Date: Jan 2013
Location: Hong Kong
Posts: 37
Downloads: 65
Uploads: 2

Updated to v0.3 to include speed constraint. Check the examples in the original post.

Thread Tools  
Display Modes  

