#python #numpy #opencv #matrix #computer-vision
Вопрос:
Я пытаюсь восстановить 3D-траекторию теннисного мяча по видео с использованием (x, y, size)
мяча с плоскости изображения, которое я получил с помощью OpenCV.
Ниже x,y, size
приведены из каждого кадра.
x,y
координаты представлены в следующем формате
значения в sizes
радиусе * 2 от кадров
time.time()
когда были получены значения
t = [7.496499538421631, 7.850451707839966, 10.156059503555298, 10.50879454612732, 10.864300012588501, 11.313080787658691, 11.6687593460083, 12.122213363647461, 12.479694128036499, 12.92769169807434, 13.375515222549438, 13.730540037155151, 14.091347217559814, 14.452015161514282, 14.810662269592285, 15.256910562515259, 15.619643449783325, 15.975050210952759, 16.423943042755127, 16.780176639556885, 17.145923614501953, 17.50660252571106, 17.864928722381592, 18.21721386909485, 18.576296091079712, 18.930899143218994, 19.28333020210266, 19.645721435546875, 20.00530505180359, 20.36150360107422, 20.719110012054443, 21.074109315872192, 21.530359983444214, 21.884960651397705, 22.236478567123413, 22.69081163406372, 23.140888452529907, 23.50391912460327, 23.855976581573486, 24.5749454498291, 25.023399591445923, 27.65239953994751, 27.993334770202637, 28.33793020248413, 28.68245577812195, 29.02262020111084, 29.366384029388428, 29.70753526687622, 30.049993753433228, 30.50245428085327, 30.94552731513977, 31.29472589492798, 31.636634349822998, 31.979126453399658, 32.32540941238403, 32.669862270355225, 33.106009006500244, 33.45296859741211, 33.79248762130737, 34.13498330116272, 34.47323536872864, 34.8149938583374, 35.15388774871826, 35.50695562362671, 35.862143993377686, 36.222965717315674, 36.575770139694214, 36.92580533027649, 37.28360939025879, 37.636208057403564, 37.99072217941284, 38.44252562522888, 38.90587043762207, 39.27215385437012, 39.627511978149414, 39.981825828552246, 40.3544557094574, 40.71557831764221, 41.07069659233093, 41.424887895584106, 41.78512668609619, 42.157304763793945, 42.514429330825806, 42.87095236778259, 43.233510971069336, 43.589449644088745, 43.94545102119446, 44.30169463157654, 44.65605926513672, 45.021549224853516, 45.37787103652954, 45.73382925987244, 46.18420886993408, 46.54928183555603, 46.90508675575256, 47.2662935256958, 47.627479791641235, 47.99049496650696, 48.347691774368286, 48.796091079711914, 49.15229034423828, 49.51176309585571, 49.869632720947266, 50.22170853614807, 50.58596849441528, 50.94659471511841, 51.39380884170532, 51.748629331588745, 52.10246920585632, 52.458303928375244, 52.81634449958801, 53.26560068130493, 53.62460446357727, 53.9804573059082, 54.33838200569153, 54.69152641296387, 55.138548135757446, 55.49510908126831, 55.852046251297, 56.20829153060913, 56.56600499153137, 56.92573261260986, 57.28101634979248, 57.638078927993774, 58.0868079662323, 58.454062700271606, 58.808533668518066, 59.254809856414795, 59.61760401725769, 59.977479696273804, 60.4226393699646, 60.774834632873535, 61.119502782821655, 61.468727350234985, 61.81100821495056, 62.156970262527466, 62.50189566612244, 62.86543416976929, 63.211872816085815, 63.65777039527893, 66.56348037719727, 66.9060275554657, 67.24572396278381, 67.58906579017639, 67.93238496780396, 68.2796630859375, 68.64013481140137, 68.98136949539185, 69.32397174835205, 69.66651654243469, 70.0057213306427, 70.34815430641174, 70.69030833244324, 71.03715467453003, 71.39530515670776, 71.73881483078003, 72.17542695999146, 72.51880168914795, 72.86576080322266, 73.20830631256104, 73.64789915084839, 74.0846049785614, 74.43674635887146, 74.78190159797668, 75.21775507926941, 75.55932974815369, 75.90355777740479, 76.24558329582214, 76.60497736930847, 76.95546174049377, 77.30329155921936, 77.65041661262512, 78.09042739868164, 78.43406462669373, 78.78033447265625, 79.12190103530884, 79.4682343006134, 79.81462240219116, 80.16579580307007, 80.5103530883789, 80.85592150688171, 81.20738458633423, 81.55015110969543, 81.89337992668152, 82.23701810836792, 82.58906650543213, 82.93483018875122, 83.27931666374207, 83.62409901618958, 83.9668025970459, 84.31098365783691, 84.65649175643921, 85.00426530838013, 85.35023474693298, 86.71479296684265, 87.73814988136292, 88.08582091331482, 88.8767557144165, 89.2208161354065, 89.56678795814514, 89.90915584564209, 90.25209140777588, 90.69564080238342, 91.03988814353943, 91.4918475151062, 91.93087577819824, 92.27469205856323, 92.6243257522583, 93.06708312034607, 93.41192436218262, 93.7593138217926, 94.10233926773071, 94.45294785499573, 94.80518102645874, 95.15791010856628, 95.5038914680481, 95.85219383239746, 96.20215797424316, 96.54865288734436, 96.99234533309937, 97.44004368782043, 97.78739833831787, 98.13831734657288, 98.58321046829224, 98.93109822273254, 99.27674841880798, 99.62561821937561, 99.97729778289795, 100.32962393760681, 100.67496037483215, 101.1169593334198, 101.4795172214508, 101.8450665473938, 102.20916604995728, 102.57039976119995, 102.92979311943054, 103.30900287628174, 103.67478704452515, 104.13423919677734, 104.50529885292053, 104.87890672683716, 105.33758568763733, 105.70465755462646, 106.07614278793335, 106.43789339065552, 110.22630333900452, 110.59510350227356, 110.95964646339417, 111.32857298851013, 111.69277930259705, 112.07809662818909, 112.45327115058899, 112.81687498092651, 113.18791604042053, 113.6506757736206, 114.01629567146301, 114.3819568157196, 114.75284481048584, 115.12969303131104, 115.49874901771545, 115.86149621009827, 116.2248785495758, 116.59563279151917, 117.05101346969604, 117.50972700119019, 117.9667615890503, 118.33537912368774, 118.7894880771637, 119.15469646453857, 119.52530407905579, 119.89570713043213, 120.26743245124817, 120.72539758682251, 121.0987241268158, 121.4688708782196, 121.83620524406433, 122.19835376739502, 122.57680606842041, 122.94515824317932, 123.40483140945435, 123.77484440803528, 124.86721444129944, 125.23350787162781, 125.69888591766357, 126.06336522102356, 129.57759952545166, 129.93161368370056, 130.28909873962402, 130.6507019996643, 131.00200486183167, 131.36231565475464, 131.71674036979675, 132.16318821907043, 132.52415227890015, 132.88539958000183, 133.33458137512207, 133.6990361213684, 134.05325651168823, 138.457213640213, 138.81403851509094, 139.17069935798645, 139.5293426513672, 139.88367676734924, 140.258780002594, 140.61957693099976, 141.06794500350952, 141.4254596233368, 141.78603053092957, 142.14273405075073, 142.5921230316162, 142.94584894180298, 143.29989528656006, 143.75052547454834, 144.10311102867126, 144.45799708366394, 144.8167495727539, 145.2640564441681, 145.61926436424255, 146.4121425151825, 146.76787757873535, 147.12069296836853, 147.47639417648315, 147.83501505851746, 148.19163298606873, 148.54842925071716, 148.91030311584473, 149.2667863368988, 152.50165915489197, 152.8566837310791, 153.21057629585266, 153.58861231803894, 153.94817519187927, 154.39429426193237, 154.75218105316162, 155.10568284988403, 155.45838260650635, 155.90659427642822, 156.26209616661072, 156.6191589832306, 156.98392629623413, 157.34586000442505, 157.70414447784424, 158.05646109580994, 158.4114511013031, 158.76921486854553, 159.21990633010864, 159.57633662223816, 159.93330645561218, 160.292804479599, 160.74809503555298, 161.10018014907837, 161.45520281791687, 161.8074288368225, 162.16139316558838, 162.51492738723755, 162.87123250961304, 163.56995368003845, 163.93421244621277, 164.29032468795776, 164.64463329315186, 165.00259399414062, 165.36093926429749, 165.71976137161255, 166.07440733909607, 166.4291741847992, 166.78981184959412, 167.14930272102356, 167.5172712802887, 167.89028906822205, 168.3480236530304, 168.72719883918762, 169.09498286247253, 169.46337842941284, 169.8385045528412, 170.20485424995422, 170.5783452987671, 170.95369505882263, 209.9890570640564, 210.34396481513977, 210.70494294166565, 211.05670738220215, 211.41911053657532, 211.77681732177734, 212.1311593055725, 212.4903109073639, 212.84964513778687, 213.29897618293762, 213.75879740715027, 214.20626950263977, 214.56157064437866, 214.92095065116882, 215.28263092041016, 215.64041137695312, 215.9967017173767, 216.35489964485168, 216.70854473114014, 217.06462955474854, 217.42621898651123, 217.78833532333374, 218.14310836791992, 218.5069088935852, 218.86846899986267, 219.2320795059204, 219.5904746055603, 219.94178199768066, 220.39040732383728, 220.74806547164917, 221.10225534439087, 221.45985054969788, 221.81625390052795, 222.1755301952362, 222.53068089485168, 222.88919591903687, 223.24546194076538, 223.69736766815186, 224.14715147018433, 224.5049023628235, 224.86229014396667, 225.66709280014038, 226.11631321907043, 226.4704031944275, 226.83094835281372, 227.1881766319275, 227.54472398757935, 227.90180826187134, 228.3516321182251, 234.1062867641449, 234.48081612586975, 234.85122060775757, 239.1573405265808, 239.5301160812378, 239.90506672859192, 240.27938318252563, 240.65224981307983, 241.02111220359802, 241.392564535141, 241.7696831226349, 242.87701797485352, 243.25386333465576, 243.62756776809692, 244.001690864563, 244.3769428730011, 244.75583577156067, 245.21810936927795, 245.59341597557068, 250.9321641921997, 251.31201124191284, 251.68518018722534, 252.42320275306702, 254.71933460235596, 255.46912670135498, 255.8403823375702, 256.47953701019287, 256.8445625305176, 257.21128273010254, 257.58152079582214, 257.9451186656952, 258.3094742298126, 258.6665196418762, 259.1103286743164, 259.5599584579468, 259.91075587272644, 260.26442551612854, 260.62672662734985, 260.9833071231842, 261.33869886398315, 261.69354271888733, 262.04518699645996, 262.40880584716797, 262.7651152610779, 263.11873841285706, 263.47067952156067, 263.8213052749634, 264.17590260505676, 264.52845525741577, 264.969274520874, 265.328111410141, 265.6780436038971, 266.12116265296936, 266.4845154285431, 266.8438367843628, 267.19678235054016, 267.6364893913269, 267.98600339889526, 268.3431317806244, 268.69347381591797, 269.04137897491455, 269.3908302783966, 269.7418715953827, 270.088504076004, 270.43607234954834, 270.78791308403015, 271.48425030708313, 271.8381781578064, 272.18798303604126, 272.5392792224884, 272.8858263492584, 273.2407259941101, 273.59041142463684, 273.9450714588165, 274.29717540740967, 274.6476204395294, 274.9991331100464, 278.54890036582947, 278.90326857566833, 279.2499089241028, 279.61018419265747, 279.95723819732666, 280.30503511428833, 280.65934920310974, 281.0075707435608, 281.7027370929718, 282.0499703884125, 282.
sizes = [10.399999618530273, 6.599999904632568, 9.199999809265137, 12.800000190734863, 12.800000190734863, 12.800000190734863, 10.399999618530273, 12.800000190734863, 11.800000190734863, 10.0, 11.800000190734863, 11.800000190734863, 10.399999618530273, 10.399999618530273, 10.399999618530273, 10.399999618530273, 12.800000190734863, 12.800000190734863, 11.0, 10.399999618530273, 10.399999618530273, 10.399999618530273, 12.800000190734863, 12.800000190734863, 12.800000190734863, 12.0, 10.399999618530273, 6.599999904632568, 12.800000190734863, 12.800000190734863, 12.800000190734863, 10.399999618530273, 10.399999618530273, 7.599999904632568, 12.800000190734863, 12.800000190734863, 10.0, 10.399999618530273, 10.399999618530273, 12.0, 12.0, 10.399999618530273, 12.0, 11.800000190734863, 12.0, 12.800000190734863, 12.800000190734863, 12.0, 12.800000190734863, 10.0, 12.800000190734863, 10.0, 10.399999618530273, 11.800000190734863, 10.0, 9.199999809265137, 10.0, 12.0, 12.0, 11.0, 8.399999618530273, 9.199999809265137, 11.0, 11.800000190734863, 11.800000190734863, 10.0, 9.199999809265137, 12.0, 12.800000190734863, 12.0, 12.0, 11.0, 10.0, 10.399999618530273, 10.399999618530273, 12.800000190734863, 12.800000190734863, 12.399999618530273, 10.399999618530273, 11.0, 10.399999618530273, 9.199999809265137, 11.0, 11.800000190734863, 11.800000190734863, 8.800000190734863, 11.800000190734863, 10.399999618530273, 10.399999618530273, 11.800000190734863, 10.0, 10.0, 10.399999618530273, 12.800000190734863, 12.800000190734863, 12.399999618530273, 10.399999618530273, 11.0, 11.0, 9.199999809265137, 10.0, 9.199999809265137, 12.800000190734863, 10.399999618530273, 9.199999809265137, 9.199999809265137, 9.199999809265137, 11.800000190734863, 9.199999809265137, 10.0, 12.800000190734863, 10.0, 10.399999618530273, 12.800000190734863, 12.0, 10.399999618530273, 10.399999618530273, 9.199999809265137, 9.199999809265137, 10.0, 12.800000190734863, 10.399999618530273, 10.0, 9.199999809265137, 9.199999809265137, 10.399999618530273, 12.800000190734863, 10.399999618530273, 8.0, 11.0, 11.0, 11.0, 11.800000190734863, 12.800000190734863, 12.0, 10.399999618530273, 10.399999618530273, 10.399999618530273, 11.0, 12.0, 10.399999618530273, 10.399999618530273, 12.800000190734863, 10.399999618530273, 10.399999618530273, 12.800000190734863, 6.599999904632568, 6.599999904632568, 12.800000190734863, 10.399999618530273, 10.399999618530273, 12.800000190734863, 10.0, 10.0, 10.0, 10.0, 9.199999809265137, 8.0, 8.0, 10.399999618530273, 11.0, 11.800000190734863, 10.399999618530273, 8.0, 8.0, 8.0, 10.399999618530273, 9.199999809265137, 12.800000190734863, 11.0, 12.800000190734863, 12.800000190734863, 12.0, 10.399999618530273, 10.0, 10.399999618530273, 10.0, 10.0, 10.399999618530273, 10.0, 9.199999809265137, 10.399999618530273, 12.800000190734863, 12.800000190734863, 6.599999904632568, 6.599999904632568, 7.599999904632568, 10.399999618530273, 9.199999809265137, 6.599999904632568, 12.800000190734863, 9.199999809265137, 10.399999618530273, 10.399999618530273, 8.800000190734863, 10.0, 10.0, 12.399999618530273, 8.800000190734863, 10.399999618530273, 12.800000190734863, 12.800000190734863, 12.800000190734863, 8.399999618530273, 11.800000190734863, 12.0, 11.0, 11.0, 9.199999809265137, 10.399999618530273, 9.199999809265137, 12.0, 11.0, 11.0, 10.399999618530273, 9.199999809265137, 7.599999904632568, 11.0, 10.0, 10.0, 12.800000190734863, 10.0, 10.399999618530273, 10.399999618530273, 12.0, 10.0, 9.199999809265137, 10.399999618530273, 10.399999618530273, 12.800000190734863, 12.0, 10.399999618530273, 8.0, 12.0, 12.0, 8.0, 10.0, 10.0, 7.599999904632568, 10.0, 10.0, 10.399999618530273, 12.800000190734863, 10.0, 12.800000190734863, 8.0, 8.0, 12.0, 11.800000190734863, 12.0, 10.0, 11.800000190734863, 11.800000190734863, 11.800000190734863, 10.399999618530273, 10.399999618530273, 9.199999809265137, 9.199999809265137, 9.199999809265137, 11.800000190734863, 11.800000190734863, 12.399999618530273, 10.399999618530273, 9.199999809265137, 10.399999618530273, 10.399999618530273, 9.199999809265137, 10.0, 10.0, 12.800000190734863, 12.800000190734863, 8.800000190734863, 12.0, 9.199999809265137, 8.800000190734863, 12.800000190734863, 12.800000190734863, 12.399999618530273, 10.0, 12.399999618530273, 12.0, 10.399999618530273, 12.0, 12.800000190734863, 10.399999618530273, 12.800000190734863, 10.0, 10.399999618530273, 10.399999618530273, 12.800000190734863, 12.0, 10.399999618530273, 12.399999618530273, 10.399999618530273, 10.399999618530273, 10.399999618530273, 12.399999618530273, 12.800000190734863, 12.800000190734863, 9.199999809265137, 12.800000190734863, 9.199999809265137, 9.199999809265137, 10.0, 10.399999618530273, 11.800000190734863, 10.399999618530273, 8.0, 8.0, 9.199999809265137, 11.0, 11.0, 8.800000190734863, 11.0, 11.0, 10.0, 10.0, 12.0, 10.399999618530273, 10.399999618530273, 12.800000190734863, 10.399999618530273, 9.199999809265137, 10.399999618530273, 10.399999618530273, 10.399999618530273, 12.800000190734863, 10.399999618530273, 10.399999618530273, 10.399999618530273, 10.0, 10.0, 12.0, 10.399999618530273, 12.0, 12.0, 12.0, 10.0, 10.399999618530273, 11.800000190734863, 12.0, 12.0, 10.0, 12.800000190734863, 11.0, 10.399999618530273, 8.0, 8.0, 10.0, 9.199999809265137, 11.800000190734863, 9.199999809265137, 10.399999618530273, 10.399999618530273, 12.399999618530273, 10.0, 12.800000190734863, 10.399999618530273, 10.399999618530273, 10.0, 12.0, 10.399999618530273, 10.0, 10.399999618530273, 10.399999618530273, 10.399999618530273, 10.399999618530273, 8.0, 12.800000190734863, 10.399999618530273, 11.0, 9.199999809265137, 10.399999618530273, 8.0, 8.0, 12.800000190734863, 12.800000190734863, 11.0, 12.800000190734863, 10.399999618530273, 10.0, 12.800000190734863, 8.800000190734863, 10.0, 11.0, 10.399999618530273, 12.399999618530273, 12.800000190734863, 10.399999618530273, 12.800000190734863, 10.399999618530273, 10.399999618530273, 10.399999618530273, 10.399999618530273, 12.800000190734863, 10.0, 10.0, 10.0, 10.0, 11.800000190734863, 12.800000190734863, 10.399999618530273, 9.199999809265137, 10.399999618530273, 10.399999618530273, 10.0, 12.0, 10.399999618530273, 12.0, 8.0, 8.0, 12.800000190734863, 12.800000190734863, 10.399999618530273, 12.800000190734863, 10.0, 12.399999618530273, 10.0, 10.399999618530273, 11.800000190734863, 8.800000190734863, 8.800000190734863, 10.399999618530273, 12.800000190734863, 10.0, 10.399999618530273, 9.199999809265137, 10.399999618530273, 6.0, 10.399999618530273, 9.199999809265137, 12.800000190734863, 10.399999618530273, 10.399999618530273, 10.399999618530273, 10.399999618530273, 10.399999618530273, 10.0, 9.199999809265137, 10.399999618530273, 10.399999618530273, 12.800000190734863, 12.800000190734863, 10.399999618530273, 6.599999904632568, 9.199999809265137, 12.800000190734863, 12.800000190734863, 12.800000190734863, 6.599999904632568, 7.599999904632568, 10.399999618530273, 10.399999618530273, 10.0, 12.0, 10.0, 8.0, 9.199999809265137, 9.199999809265137, 12.399999618530273, 10.399999618530273, 12.800000190734863, 10.0, 12.399999618530273, 12.399999618530273, 10.0, 10.0, 10.0, 9.199999809265137, 11.0, 11.0, 12.800000190734863, 12.0, 8.0, 11.800000190734863, 11.800000190734863, 11.800000190734863, 10.0, 9.199999809265137, 9.199999809265137, 10.0, 10.0, 10.0, 9.199999809265137, 9.199999809265137, 12.800000190734863, 8.800000190734863, 7.599999904632568, 7.599999904632568, 10.0, 10.0, 10.399999618530273, 10.399999618530273, 10.399999618530273, 8.0, 12.0, 10.399999618530273, 12.800000190734863, 10.0, 10.0, 11.800000190734863, 11.800000190734863, 12.399999618530273, 9.199999809265137, 10.399999618530273, 10.399999618530273, 8.0, 9.199999809265137, 9.199999809265137, 11.800000190734863, 12.800000190734863, 10.399999618530273, 10.399999618530273, 10.399999618530273, 10.0, 11.800000190734863, 12.0, 10.399999618530273, 10.399999618530273, 10.399999618530273, 9.199999809265137, 9.199999809265137, 10.0, 10.399999618530273, 10.0, 10.399999618530273, 12.0, 9.199999809265137, 11.0, 12.0, 12.0, 11.800000190734863, 12.800000190734863, 10.399999618530273, 8.0, 8.0, 8.0, 10.399999618530273, 10.399999618530273, 10.399999618530273, 10.0, 12.800000190734863, 12.0, 12.0, 10.399999618530273, 7.599999904632568, 9.199999809265137, 10.399999618530273, 10.0, 12.800000190734863, 10.399999618530273, 10.0, 12.800000190734863, 8.0, 8.0, 8.0, 12.0, 9.199999809265137, 12.0, 10.0, 10.0, 11.800000190734863, 12.399999618530273, 7.599999904632568, 9.199999809265137, 10.399999618530273, 10.399999618530273, 12.800000190734863, 10.0, 11.800000190734863, 10.0, 9.199999809265137, 12.0, 11.0, 10.0, 12.800000190734863, 9.199999809265137, 10.399999618530273, 10.399999618530273, 12.0, 10.399999618530273, 10.399999618530273, 10.399999618530273, 12.0, 12.0, 12.800000190734863, 12.800000190734863, 12.0, 12.399999618530273, 8.0, 8.0, 12.800000190734863]
coords = [[985, 325], [978, 345], [1098, 238], [921, 555], [918, 574], [918, 574], [904, 613], [895, 644], [886, 649], [877, 654], [870, 658], [870, 658], [861, 664], [853, 672], [846, 679], [837, 688], [827, 695], [827, 695], [821, 707], [812, 716], [803, 729], [1051, 313], [786, 755], [786, 755], [782, 769], [782, 746], [786, 730], [793, 700], [800, 677], [800, 677], [803, 656], [807, 640], [814, 620], [819, 593], [819, 579], [819, 579], [825, 562], [831, 546], [834, 532], [833, 805], [833, 805], [865, 427], [867, 418], [871, 409], [872, 400], [877, 392], [877, 392], [877, 385], [883, 377], [883, 369], [887, 366], [890, 358], [890, 357], [892, 352], [894, 346], [897, 340], [898, 336], [900, 332], [900, 332], [902, 329], [905, 325], [905, 322], [908, 320], [910, 316], [910, 316], [912, 315], [914, 314], [916, 310], [919, 308], [919, 306], [919, 306], [920, 305], [924, 306], [922, 306], [926, 305], [928, 305], [926, 307], [930, 306], [930, 305], [932, 305], [933, 307], [935, 310], [935, 308], [936, 310], [937, 313], [938, 314], [940, 316], [942, 319], [942, 319], [942, 322], [943, 323], [945, 324], [946, 316], [945, 306], [945, 306], [945, 298], [946, 291], [947, 284], [947, 278], [950, 272], [949, 273], [950, 266], [951, 261], [950, 255], [950, 251], [951, 245], [951, 245], [953, 241], [952, 237], [950, 236], [945, 237], [939, 240], [938, 239], [934, 242], [928, 244], [922, 250], [917, 252], [911, 256], [911, 256], [905, 263], [899, 267], [896, 274], [890, 278], [883, 286], [883, 286], [878, 293], [873, 300], [869, 309], [863, 318], [858, 329], [858, 329], [851, 338], [846, 349], [840, 359], [835, 371], [830, 384], [830, 384], [825, 397], [818, 410], [812, 424], [774, 535], [773, 537], [768, 550], [761, 572], [754, 592], [750, 615], [748, 624], [748, 624], [739, 652], [733, 674], [728, 698], [727, 718], [718, 733], [718, 733], [714, 732], [709, 729], [705, 728], [702, 729], [694, 728], [696, 728], [692, 728], [688, 730], [684, 730], [678, 731], [675, 734], [675, 734], [673, 737], [667, 741], [664, 743], [659, 749], [653, 755], [653, 755], [650, 759], [647, 765], [642, 774], [636, 780], [633, 786], [633, 787], [630, 796], [625, 804], [629, 769], [634, 737], [633, 718], [633, 718], [640, 697], [644, 657], [649, 640], [651, 616], [655, 592], [654, 591], [654, 578], [656, 560], [659, 544], [662, 525], [668, 482], [675, 448], [675, 448], [677, 427], [677, 419], [678, 410], [678, 404], [678, 404], [679, 394], [682, 394], [682, 385], [682, 380], [683, 374], [683, 374], [684, 370], [684, 367], [684, 364], [685, 361], [686, 359], [686, 359], [686, 357], [686, 356], [687, 353], [686, 353], [687, 352], [687, 352], [688, 350], [687, 339], [685, 329], [687, 318], [686, 309], [687, 309], [681, 300], [686, 293], [688, 283], [689, 273], [688, 268], [689, 270], [689, 261], [688, 256], [688, 250], [689, 243], [688, 238], [688, 238], [690, 237], [690, 231], [690, 228], [691, 226], [696, 227], [699, 226], [705, 227], [758, 234], [758, 234], [762, 239], [769, 241], [775, 243], [780, 246], [787, 250], [787, 250], [793, 253], [800, 256], [806, 261], [812, 263], [820, 266], [820, 266], [826, 271], [832, 274], [840, 279], [845, 283], [851, 289], [852, 289], [858, 296], [866, 299], [874, 306], [879, 312], [888, 318], [888, 318], [893, 323], [900, 330], [908, 338], [914, 344], [922, 350], [922, 350], [928, 360], [937, 367], [945, 378], [950, 384], [967, 402], [974, 411], [980, 421], [989, 428], [1054, 518], [1061, 533], [1066, 543], [1076, 557], [1077, 558], [1087, 569], [1093, 585], [1101, 601], [1110, 614], [1119, 629], [1119, 629], [1128, 642], [1136, 662], [1211, 723], [1216, 718], [1220, 719], [1226, 719], [1227, 718], [1232, 718], [1238, 719], [1243, 721], [1252, 721], [1256, 721], [1256, 721], [1262, 725], [1268, 728], [1273, 731], [1280, 734], [1286, 737], [1286, 737], [1293, 742], [1298, 746], [1305, 749], [1299, 691], [1299, 691], [1295, 668], [1295, 649], [1288, 623], [1285, 597], [1280, 571], [1280, 571], [1277, 552], [1254, 430], [1249, 417], [1249, 417], [1246, 409], [1242, 399], [1239, 392], [1237, 384], [1234, 379], [1234, 379], [1231, 373], [1230, 367], [1227, 364], [1225, 361], [1222, 358], [1222, 358], [1220, 356], [1219, 353], [1214, 353], [1212, 352], [1209, 350], [1209, 350], [1207, 351], [1206, 350], [1204, 352], [1202, 350], [1202, 335], [1202, 335], [1200, 324], [1198, 313], [1194, 292], [1195, 281], [1195, 281], [1194, 273], [1191, 263], [1191, 256], [1191, 247], [1190, 239], [1190, 239], [1189, 234], [1189, 228], [1189, 221], [1188, 216], [1186, 213], [1187, 212], [1184, 209], [1183, 205], [1182, 200], [1181, 195], [1181, 195], [1181, 195], [908, 212], [906, 222], [901, 235], [900, 235], [898, 249], [893, 263], [888, 276], [883, 292], [878, 303], [879, 303], [876, 321], [857, 673], [866, 349], [863, 365], [859, 384], [859, 384], [855, 398], [851, 411], [849, 412], [845, 413], [841, 414], [841, 414], [837, 414], [835, 413], [830, 415], [828, 416], [825, 416], [825, 416], [821, 419], [817, 421], [816, 424], [813, 425], [809, 423], [809, 423], [805, 405], [804, 378], [803, 360], [799, 340], [800, 324], [800, 324], [838, 625], [793, 274], [791, 259], [788, 248], [788, 248], [787, 235], [783, 224], [783, 214], [781, 204], [856, 617], [857, 617], [860, 617], [808, 210], [814, 226], [818, 239], [820, 238], [824, 250], [830, 260], [836, 275], [839, 286], [852, 321], [858, 334], [860, 350], [868, 366], [875, 383], [875, 383], [880, 402], [885, 418], [975, 558], [991, 561], [991, 561], [997, 579], [1017, 577], [1028, 565], [942, 433], [942, 433], [943, 424], [944, 420], [946, 412], [949, 407], [948, 401], [948, 401], [948, 397], [949, 391], [950, 391], [952, 385], [954, 381], [954, 381], [954, 378], [954, 375], [955, 372], [956, 371], [956, 368], [956, 368], [956, 368], [960, 365], [959, 363], [960, 364], [961, 364], [961, 364], [963, 363], [963, 364], [962, 364], [965, 365], [967, 367], [967, 367], [967, 367], [966, 370], [966, 371], [968, 374], [969, 377], [969, 377], [969, 381], [969, 384], [969, 388], [972, 394], [972, 394], [971, 399], [972, 404], [973, 409], [972, 414], [973, 418], [973, 418], [973, 424], [973, 430], [972, 437], [973, 430], [974, 423], [974, 416], [974, 411], [974, 407], [974, 407], [973, 403], [972, 396], [971, 389], [973, 385], [973, 385], [972, 384], [973, 379], [972, 377], [971, 374], [972, 373], [973, 373], [957, 372], [946, 412], [941, 413], [935, 414], [936, 414], [929, 414], [922, 413], [914, 414], [908, 416], [902, 417], [902, 417], [894, 418], [889, 422], [882, 424], [873, 425], [867, 428], [867, 428], [861, 436], [853, 437], [743, 536], [738, 543], [732, 552], [732, 545], [732, 545], [734, 532], [701, 583], [766, 425], [770, 413], [769, 414], [774, 405], [776, 392], [780, 384], [783, 374], [788, 363], [788, 363], [791, 354], [794, 346], [799, 339], [802, 331], [805, 324], [805, 324], [808, 319], [813, 312], [814, 304], [818, 299], [824, 295], [824, 295], [828, 288], [828, 285], [832, 280], [835, 276], [838, 274], [838, 274], [842, 269], [846, 266], [848, 265], [852, 262], [855, 260], [855, 260], [857, 259], [861, 256], [868, 253], [1081, 594], [1091, 586], [1091, 586], [1103, 573], [1113, 564], [1126, 553], [1140, 542], [1150, 533], [1150, 533], [1163, 523]], [972, 396], None, [971, 389], [973, 385], [973, 385], [972, 384], [973, 379], [972, 377], [971, 374], [972, 373], [973, 373], None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, [957, 372], None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, [946, 412], [941, 413], [935, 414], [936, 414], [929, 414], [922, 413], [914, 414], [908, 416], [902, 417], [902, 417], [894, 418], [889, 422], [882, 424], [873, 425], [867, 428], [867, 428], [861, 436], [853, 437], None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, [743, 536], [738, 543], [732, 552], [732, 545], [732, 545], [734, 532], None, None, [701, 583], None, None, None, None, None, [766, 425], [770, 413], [769, 414], [774, 405], [776, 392], [780, 384], [783, 374], [788, 363], [788, 363], [791, 354], [794, 346], [799, 339], [802, 331], [805, 324], [805, 324], [808, 319], [813, 312], [814, 304], [818, 299], [824, 295], [824, 295], [828, 288], [828, 285], [832, 280], [835, 276], [838, 274], [838, 274], [842, 269], [846, 266], [848, 265], [852, 262], [855, 260], [855, 260], [857, 259], [861, 256], None, [868, 253], None, None, None, None, None, None, None, None, None, None, None, [1081, 594], [1091, 586], [1091, 586], [1103, 573], [1113, 564], [1126, 553], [1140, 542], [1150, 533], [1150, 533], [1163, 523]]
Используя эту бумагу в качестве руководства, я получил предположительно откалиброванную камеру
используя 6 точек из одного из кадров, ниже приведен код для этого
# Camera Calibration
import numpy as np
# 4 x,y coordinates of court corners and 2 points under the net
imgPts = [[577, 303], [1333, 303], [495, 517], [1422, 517], [366, 857], [1562, 857]]
# Assuming the top left corner is origin
# Moving to the right is x, and down is y, z is 0
objPts = [[0, 0, 0], [10.97, 0, 0], [0, 11.8, 0], [10.97, 11.8, 0], [0, 23.77, 0], [10.97, 23.77, 0]]
objPts = np.array(objPts)
objPts = objPts.astype('float32')
imgPts = np.array(imgPts)
imgPts = imgPts.astype('float32')
w = frame.shape[1]
h = frame.shape[0]
size = (w,h)
camera_matrix = cv2.initCameraMatrix2D([objPts],[imgPts], size)
rms, camera_matrix, dist_coefs, rvecs, tvecs = cv2.calibrateCamera([objPts], [imgPts], size, None, None)
и нашел омографию, используя следующую функцию
def warpImage(img, points, w, h, pad=20):
pts1 = np.float32(points)
pts2 = np.float32([[0, 0], [w, 0], [0, h], [w, h]])
matrix = cv2.getPerspectiveTransform(pts1, pts2)
imgWarp = cv2.warpPerspective(img, matrix, (w, h))
imgWarp = imgWarp[pad:imgWarp.shape[0]-pad, pad:imgWarp.shape[1]-pad]
return matrix, imgWarp
angles = np.array([[577 , 303], [1333, 303], [366, 857], [1565 ,857]]).reshape(4,1,2)
courtW = 1097 # court width = 10.97 meters in cm
courtH = 2377 # court length = 23.77 meters in cv
homMat, img = warpImage(frame, angles, courtW, courtH, pad=0)
Но теперь я не знаю, что делать дальше, пожалуйста, помогите, если есть решение!