Calib3d.cs 866 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487
  1. using OpenCVForUnity.CoreModule;
  2. using OpenCVForUnity.UtilsModule;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Runtime.InteropServices;
  6. namespace OpenCVForUnity.Calib3dModule
  7. {
  8. // C++: class Calib3d
  9. public class Calib3d
  10. {
  11. // C++: enum <unnamed>
  12. public const int CV_ITERATIVE = 0;
  13. public const int CV_EPNP = 1;
  14. public const int CV_P3P = 2;
  15. public const int CV_DLS = 3;
  16. public const int CvLevMarq_DONE = 0;
  17. public const int CvLevMarq_STARTED = 1;
  18. public const int CvLevMarq_CALC_J = 2;
  19. public const int CvLevMarq_CHECK_ERR = 3;
  20. public const int LMEDS = 4;
  21. public const int RANSAC = 8;
  22. public const int RHO = 16;
  23. public const int USAC_DEFAULT = 32;
  24. public const int USAC_PARALLEL = 33;
  25. public const int USAC_FM_8PTS = 34;
  26. public const int USAC_FAST = 35;
  27. public const int USAC_ACCURATE = 36;
  28. public const int USAC_PROSAC = 37;
  29. public const int USAC_MAGSAC = 38;
  30. public const int CALIB_CB_ADAPTIVE_THRESH = 1;
  31. public const int CALIB_CB_NORMALIZE_IMAGE = 2;
  32. public const int CALIB_CB_FILTER_QUADS = 4;
  33. public const int CALIB_CB_FAST_CHECK = 8;
  34. public const int CALIB_CB_EXHAUSTIVE = 16;
  35. public const int CALIB_CB_ACCURACY = 32;
  36. public const int CALIB_CB_LARGER = 64;
  37. public const int CALIB_CB_MARKER = 128;
  38. public const int CALIB_CB_SYMMETRIC_GRID = 1;
  39. public const int CALIB_CB_ASYMMETRIC_GRID = 2;
  40. public const int CALIB_CB_CLUSTERING = 4;
  41. public const int CALIB_NINTRINSIC = 18;
  42. public const int CALIB_USE_INTRINSIC_GUESS = 0x00001;
  43. public const int CALIB_FIX_ASPECT_RATIO = 0x00002;
  44. public const int CALIB_FIX_PRINCIPAL_POINT = 0x00004;
  45. public const int CALIB_ZERO_TANGENT_DIST = 0x00008;
  46. public const int CALIB_FIX_FOCAL_LENGTH = 0x00010;
  47. public const int CALIB_FIX_K1 = 0x00020;
  48. public const int CALIB_FIX_K2 = 0x00040;
  49. public const int CALIB_FIX_K3 = 0x00080;
  50. public const int CALIB_FIX_K4 = 0x00800;
  51. public const int CALIB_FIX_K5 = 0x01000;
  52. public const int CALIB_FIX_K6 = 0x02000;
  53. public const int CALIB_RATIONAL_MODEL = 0x04000;
  54. public const int CALIB_THIN_PRISM_MODEL = 0x08000;
  55. public const int CALIB_FIX_S1_S2_S3_S4 = 0x10000;
  56. public const int CALIB_TILTED_MODEL = 0x40000;
  57. public const int CALIB_FIX_TAUX_TAUY = 0x80000;
  58. public const int CALIB_USE_QR = 0x100000;
  59. public const int CALIB_FIX_TANGENT_DIST = 0x200000;
  60. public const int CALIB_FIX_INTRINSIC = 0x00100;
  61. public const int CALIB_SAME_FOCAL_LENGTH = 0x00200;
  62. public const int CALIB_ZERO_DISPARITY = 0x00400;
  63. public const int CALIB_USE_LU = (1 << 17);
  64. public const int CALIB_USE_EXTRINSIC_GUESS = (1 << 22);
  65. public const int FM_7POINT = 1;
  66. public const int FM_8POINT = 2;
  67. public const int FM_LMEDS = 4;
  68. public const int FM_RANSAC = 8;
  69. public const int fisheye_CALIB_USE_INTRINSIC_GUESS = 1 << 0;
  70. public const int fisheye_CALIB_RECOMPUTE_EXTRINSIC = 1 << 1;
  71. public const int fisheye_CALIB_CHECK_COND = 1 << 2;
  72. public const int fisheye_CALIB_FIX_SKEW = 1 << 3;
  73. public const int fisheye_CALIB_FIX_K1 = 1 << 4;
  74. public const int fisheye_CALIB_FIX_K2 = 1 << 5;
  75. public const int fisheye_CALIB_FIX_K3 = 1 << 6;
  76. public const int fisheye_CALIB_FIX_K4 = 1 << 7;
  77. public const int fisheye_CALIB_FIX_INTRINSIC = 1 << 8;
  78. public const int fisheye_CALIB_FIX_PRINCIPAL_POINT = 1 << 9;
  79. public const int fisheye_CALIB_ZERO_DISPARITY = 1 << 10;
  80. public const int fisheye_CALIB_FIX_FOCAL_LENGTH = 1 << 11;
  81. // C++: enum cv.CirclesGridFinderParameters.GridType
  82. public const int CirclesGridFinderParameters_SYMMETRIC_GRID = 0;
  83. public const int CirclesGridFinderParameters_ASYMMETRIC_GRID = 1;
  84. // C++: enum cv.HandEyeCalibrationMethod
  85. public const int CALIB_HAND_EYE_TSAI = 0;
  86. public const int CALIB_HAND_EYE_PARK = 1;
  87. public const int CALIB_HAND_EYE_HORAUD = 2;
  88. public const int CALIB_HAND_EYE_ANDREFF = 3;
  89. public const int CALIB_HAND_EYE_DANIILIDIS = 4;
  90. // C++: enum cv.LocalOptimMethod
  91. public const int LOCAL_OPTIM_NULL = 0;
  92. public const int LOCAL_OPTIM_INNER_LO = 1;
  93. public const int LOCAL_OPTIM_INNER_AND_ITER_LO = 2;
  94. public const int LOCAL_OPTIM_GC = 3;
  95. public const int LOCAL_OPTIM_SIGMA = 4;
  96. // C++: enum cv.NeighborSearchMethod
  97. public const int NEIGH_FLANN_KNN = 0;
  98. public const int NEIGH_GRID = 1;
  99. public const int NEIGH_FLANN_RADIUS = 2;
  100. // C++: enum cv.PolishingMethod
  101. public const int NONE_POLISHER = 0;
  102. public const int LSQ_POLISHER = 1;
  103. public const int MAGSAC = 2;
  104. public const int COV_POLISHER = 3;
  105. // C++: enum cv.RobotWorldHandEyeCalibrationMethod
  106. public const int CALIB_ROBOT_WORLD_HAND_EYE_SHAH = 0;
  107. public const int CALIB_ROBOT_WORLD_HAND_EYE_LI = 1;
  108. // C++: enum cv.SamplingMethod
  109. public const int SAMPLING_UNIFORM = 0;
  110. public const int SAMPLING_PROGRESSIVE_NAPSAC = 1;
  111. public const int SAMPLING_NAPSAC = 2;
  112. public const int SAMPLING_PROSAC = 3;
  113. // C++: enum cv.ScoreMethod
  114. public const int SCORE_METHOD_RANSAC = 0;
  115. public const int SCORE_METHOD_MSAC = 1;
  116. public const int SCORE_METHOD_MAGSAC = 2;
  117. public const int SCORE_METHOD_LMEDS = 3;
  118. // C++: enum cv.SolvePnPMethod
  119. public const int SOLVEPNP_ITERATIVE = 0;
  120. public const int SOLVEPNP_EPNP = 1;
  121. public const int SOLVEPNP_P3P = 2;
  122. public const int SOLVEPNP_DLS = 3;
  123. public const int SOLVEPNP_UPNP = 4;
  124. public const int SOLVEPNP_AP3P = 5;
  125. public const int SOLVEPNP_IPPE = 6;
  126. public const int SOLVEPNP_IPPE_SQUARE = 7;
  127. public const int SOLVEPNP_SQPNP = 8;
  128. public const int SOLVEPNP_MAX_COUNT = 8 + 1;
  129. // C++: enum cv.UndistortTypes
  130. public const int PROJ_SPHERICAL_ORTHO = 0;
  131. public const int PROJ_SPHERICAL_EQRECT = 1;
  132. //
  133. // C++: void cv::Rodrigues(Mat src, Mat& dst, Mat& jacobian = Mat())
  134. //
  135. /**
  136. * Converts a rotation matrix to a rotation vector or vice versa.
  137. *
  138. * param src Input rotation vector (3x1 or 1x3) or rotation matrix (3x3).
  139. * param dst Output rotation matrix (3x3) or rotation vector (3x1 or 1x3), respectively.
  140. * param jacobian Optional output Jacobian matrix, 3x9 or 9x3, which is a matrix of partial
  141. * derivatives of the output array components with respect to the input array components.
  142. *
  143. * \(\begin{array}{l} \theta \leftarrow norm(r) \\ r \leftarrow r/ \theta \\ R = \cos(\theta) I + (1- \cos{\theta} ) r r^T + \sin(\theta) \vecthreethree{0}{-r_z}{r_y}{r_z}{0}{-r_x}{-r_y}{r_x}{0} \end{array}\)
  144. *
  145. * Inverse transformation can be also done easily, since
  146. *
  147. * \(\sin ( \theta ) \vecthreethree{0}{-r_z}{r_y}{r_z}{0}{-r_x}{-r_y}{r_x}{0} = \frac{R - R^T}{2}\)
  148. *
  149. * A rotation vector is a convenient and most compact representation of a rotation matrix (since any
  150. * rotation matrix has just 3 degrees of freedom). The representation is used in the global 3D geometry
  151. * optimization procedures like REF: calibrateCamera, REF: stereoCalibrate, or REF: solvePnP .
  152. *
  153. * <b>Note:</b> More information about the computation of the derivative of a 3D rotation matrix with respect to its exponential coordinate
  154. * can be found in:
  155. * <ul>
  156. * <li>
  157. * A Compact Formula for the Derivative of a 3-D Rotation in Exponential Coordinates, Guillermo Gallego, Anthony J. Yezzi CITE: Gallego2014ACF
  158. * </li>
  159. * </ul>
  160. *
  161. * <b>Note:</b> Useful information on SE(3) and Lie Groups can be found in:
  162. * <ul>
  163. * <li>
  164. * A tutorial on SE(3) transformation parameterizations and on-manifold optimization, Jose-Luis Blanco CITE: blanco2010tutorial
  165. * </li>
  166. * <li>
  167. * Lie Groups for 2D and 3D Transformation, Ethan Eade CITE: Eade17
  168. * </li>
  169. * <li>
  170. * A micro Lie theory for state estimation in robotics, Joan Solà, Jérémie Deray, Dinesh Atchuthan CITE: Sol2018AML
  171. * </li>
  172. * </ul>
  173. */
  174. public static void Rodrigues(Mat src, Mat dst, Mat jacobian)
  175. {
  176. if (src != null) src.ThrowIfDisposed();
  177. if (dst != null) dst.ThrowIfDisposed();
  178. if (jacobian != null) jacobian.ThrowIfDisposed();
  179. calib3d_Calib3d_Rodrigues_10(src.nativeObj, dst.nativeObj, jacobian.nativeObj);
  180. }
  181. /**
  182. * Converts a rotation matrix to a rotation vector or vice versa.
  183. *
  184. * param src Input rotation vector (3x1 or 1x3) or rotation matrix (3x3).
  185. * param dst Output rotation matrix (3x3) or rotation vector (3x1 or 1x3), respectively.
  186. * derivatives of the output array components with respect to the input array components.
  187. *
  188. * \(\begin{array}{l} \theta \leftarrow norm(r) \\ r \leftarrow r/ \theta \\ R = \cos(\theta) I + (1- \cos{\theta} ) r r^T + \sin(\theta) \vecthreethree{0}{-r_z}{r_y}{r_z}{0}{-r_x}{-r_y}{r_x}{0} \end{array}\)
  189. *
  190. * Inverse transformation can be also done easily, since
  191. *
  192. * \(\sin ( \theta ) \vecthreethree{0}{-r_z}{r_y}{r_z}{0}{-r_x}{-r_y}{r_x}{0} = \frac{R - R^T}{2}\)
  193. *
  194. * A rotation vector is a convenient and most compact representation of a rotation matrix (since any
  195. * rotation matrix has just 3 degrees of freedom). The representation is used in the global 3D geometry
  196. * optimization procedures like REF: calibrateCamera, REF: stereoCalibrate, or REF: solvePnP .
  197. *
  198. * <b>Note:</b> More information about the computation of the derivative of a 3D rotation matrix with respect to its exponential coordinate
  199. * can be found in:
  200. * <ul>
  201. * <li>
  202. * A Compact Formula for the Derivative of a 3-D Rotation in Exponential Coordinates, Guillermo Gallego, Anthony J. Yezzi CITE: Gallego2014ACF
  203. * </li>
  204. * </ul>
  205. *
  206. * <b>Note:</b> Useful information on SE(3) and Lie Groups can be found in:
  207. * <ul>
  208. * <li>
  209. * A tutorial on SE(3) transformation parameterizations and on-manifold optimization, Jose-Luis Blanco CITE: blanco2010tutorial
  210. * </li>
  211. * <li>
  212. * Lie Groups for 2D and 3D Transformation, Ethan Eade CITE: Eade17
  213. * </li>
  214. * <li>
  215. * A micro Lie theory for state estimation in robotics, Joan Solà, Jérémie Deray, Dinesh Atchuthan CITE: Sol2018AML
  216. * </li>
  217. * </ul>
  218. */
  219. public static void Rodrigues(Mat src, Mat dst)
  220. {
  221. if (src != null) src.ThrowIfDisposed();
  222. if (dst != null) dst.ThrowIfDisposed();
  223. calib3d_Calib3d_Rodrigues_11(src.nativeObj, dst.nativeObj);
  224. }
  225. //
  226. // C++: Mat cv::findHomography(vector_Point2f srcPoints, vector_Point2f dstPoints, int method = 0, double ransacReprojThreshold = 3, Mat& mask = Mat(), int maxIters = 2000, double confidence = 0.995)
  227. //
  228. /**
  229. * Finds a perspective transformation between two planes.
  230. *
  231. * param srcPoints Coordinates of the points in the original plane, a matrix of the type CV_32FC2
  232. * or vector&lt;Point2f&gt; .
  233. * param dstPoints Coordinates of the points in the target plane, a matrix of the type CV_32FC2 or
  234. * a vector&lt;Point2f&gt; .
  235. * param method Method used to compute a homography matrix. The following methods are possible:
  236. * <ul>
  237. * <li>
  238. * <b>0</b> - a regular method using all the points, i.e., the least squares method
  239. * </li>
  240. * <li>
  241. * REF: RANSAC - RANSAC-based robust method
  242. * </li>
  243. * <li>
  244. * REF: LMEDS - Least-Median robust method
  245. * </li>
  246. * <li>
  247. * REF: RHO - PROSAC-based robust method
  248. * </li>
  249. * </ul>
  250. * param ransacReprojThreshold Maximum allowed reprojection error to treat a point pair as an inlier
  251. * (used in the RANSAC and RHO methods only). That is, if
  252. * \(\| \texttt{dstPoints} _i - \texttt{convertPointsHomogeneous} ( \texttt{H} \cdot \texttt{srcPoints} _i) \|_2 &gt; \texttt{ransacReprojThreshold}\)
  253. * then the point \(i\) is considered as an outlier. If srcPoints and dstPoints are measured in pixels,
  254. * it usually makes sense to set this parameter somewhere in the range of 1 to 10.
  255. * param mask Optional output mask set by a robust method ( RANSAC or LMeDS ). Note that the input
  256. * mask values are ignored.
  257. * param maxIters The maximum number of RANSAC iterations.
  258. * param confidence Confidence level, between 0 and 1.
  259. *
  260. * The function finds and returns the perspective transformation \(H\) between the source and the
  261. * destination planes:
  262. *
  263. * \(s_i \vecthree{x'_i}{y'_i}{1} \sim H \vecthree{x_i}{y_i}{1}\)
  264. *
  265. * so that the back-projection error
  266. *
  267. * \(\sum _i \left ( x'_i- \frac{h_{11} x_i + h_{12} y_i + h_{13}}{h_{31} x_i + h_{32} y_i + h_{33}} \right )^2+ \left ( y'_i- \frac{h_{21} x_i + h_{22} y_i + h_{23}}{h_{31} x_i + h_{32} y_i + h_{33}} \right )^2\)
  268. *
  269. * is minimized. If the parameter method is set to the default value 0, the function uses all the point
  270. * pairs to compute an initial homography estimate with a simple least-squares scheme.
  271. *
  272. * However, if not all of the point pairs ( \(srcPoints_i\), \(dstPoints_i\) ) fit the rigid perspective
  273. * transformation (that is, there are some outliers), this initial estimate will be poor. In this case,
  274. * you can use one of the three robust methods. The methods RANSAC, LMeDS and RHO try many different
  275. * random subsets of the corresponding point pairs (of four pairs each, collinear pairs are discarded), estimate the homography matrix
  276. * using this subset and a simple least-squares algorithm, and then compute the quality/goodness of the
  277. * computed homography (which is the number of inliers for RANSAC or the least median re-projection error for
  278. * LMeDS). The best subset is then used to produce the initial estimate of the homography matrix and
  279. * the mask of inliers/outliers.
  280. *
  281. * Regardless of the method, robust or not, the computed homography matrix is refined further (using
  282. * inliers only in case of a robust method) with the Levenberg-Marquardt method to reduce the
  283. * re-projection error even more.
  284. *
  285. * The methods RANSAC and RHO can handle practically any ratio of outliers but need a threshold to
  286. * distinguish inliers from outliers. The method LMeDS does not need any threshold but it works
  287. * correctly only when there are more than 50% of inliers. Finally, if there are no outliers and the
  288. * noise is rather small, use the default method (method=0).
  289. *
  290. * The function is used to find initial intrinsic and extrinsic matrices. Homography matrix is
  291. * determined up to a scale. Thus, it is normalized so that \(h_{33}=1\). Note that whenever an \(H\) matrix
  292. * cannot be estimated, an empty one will be returned.
  293. *
  294. * SEE:
  295. * getAffineTransform, estimateAffine2D, estimateAffinePartial2D, getPerspectiveTransform, warpPerspective,
  296. * perspectiveTransform
  297. * return automatically generated
  298. */
  299. public static Mat findHomography(MatOfPoint2f srcPoints, MatOfPoint2f dstPoints, int method, double ransacReprojThreshold, Mat mask, int maxIters, double confidence)
  300. {
  301. if (srcPoints != null) srcPoints.ThrowIfDisposed();
  302. if (dstPoints != null) dstPoints.ThrowIfDisposed();
  303. if (mask != null) mask.ThrowIfDisposed();
  304. Mat srcPoints_mat = srcPoints;
  305. Mat dstPoints_mat = dstPoints;
  306. return new Mat(DisposableObject.ThrowIfNullIntPtr(calib3d_Calib3d_findHomography_10(srcPoints_mat.nativeObj, dstPoints_mat.nativeObj, method, ransacReprojThreshold, mask.nativeObj, maxIters, confidence)));
  307. }
  308. /**
  309. * Finds a perspective transformation between two planes.
  310. *
  311. * param srcPoints Coordinates of the points in the original plane, a matrix of the type CV_32FC2
  312. * or vector&lt;Point2f&gt; .
  313. * param dstPoints Coordinates of the points in the target plane, a matrix of the type CV_32FC2 or
  314. * a vector&lt;Point2f&gt; .
  315. * param method Method used to compute a homography matrix. The following methods are possible:
  316. * <ul>
  317. * <li>
  318. * <b>0</b> - a regular method using all the points, i.e., the least squares method
  319. * </li>
  320. * <li>
  321. * REF: RANSAC - RANSAC-based robust method
  322. * </li>
  323. * <li>
  324. * REF: LMEDS - Least-Median robust method
  325. * </li>
  326. * <li>
  327. * REF: RHO - PROSAC-based robust method
  328. * </li>
  329. * </ul>
  330. * param ransacReprojThreshold Maximum allowed reprojection error to treat a point pair as an inlier
  331. * (used in the RANSAC and RHO methods only). That is, if
  332. * \(\| \texttt{dstPoints} _i - \texttt{convertPointsHomogeneous} ( \texttt{H} \cdot \texttt{srcPoints} _i) \|_2 &gt; \texttt{ransacReprojThreshold}\)
  333. * then the point \(i\) is considered as an outlier. If srcPoints and dstPoints are measured in pixels,
  334. * it usually makes sense to set this parameter somewhere in the range of 1 to 10.
  335. * param mask Optional output mask set by a robust method ( RANSAC or LMeDS ). Note that the input
  336. * mask values are ignored.
  337. * param maxIters The maximum number of RANSAC iterations.
  338. *
  339. * The function finds and returns the perspective transformation \(H\) between the source and the
  340. * destination planes:
  341. *
  342. * \(s_i \vecthree{x'_i}{y'_i}{1} \sim H \vecthree{x_i}{y_i}{1}\)
  343. *
  344. * so that the back-projection error
  345. *
  346. * \(\sum _i \left ( x'_i- \frac{h_{11} x_i + h_{12} y_i + h_{13}}{h_{31} x_i + h_{32} y_i + h_{33}} \right )^2+ \left ( y'_i- \frac{h_{21} x_i + h_{22} y_i + h_{23}}{h_{31} x_i + h_{32} y_i + h_{33}} \right )^2\)
  347. *
  348. * is minimized. If the parameter method is set to the default value 0, the function uses all the point
  349. * pairs to compute an initial homography estimate with a simple least-squares scheme.
  350. *
  351. * However, if not all of the point pairs ( \(srcPoints_i\), \(dstPoints_i\) ) fit the rigid perspective
  352. * transformation (that is, there are some outliers), this initial estimate will be poor. In this case,
  353. * you can use one of the three robust methods. The methods RANSAC, LMeDS and RHO try many different
  354. * random subsets of the corresponding point pairs (of four pairs each, collinear pairs are discarded), estimate the homography matrix
  355. * using this subset and a simple least-squares algorithm, and then compute the quality/goodness of the
  356. * computed homography (which is the number of inliers for RANSAC or the least median re-projection error for
  357. * LMeDS). The best subset is then used to produce the initial estimate of the homography matrix and
  358. * the mask of inliers/outliers.
  359. *
  360. * Regardless of the method, robust or not, the computed homography matrix is refined further (using
  361. * inliers only in case of a robust method) with the Levenberg-Marquardt method to reduce the
  362. * re-projection error even more.
  363. *
  364. * The methods RANSAC and RHO can handle practically any ratio of outliers but need a threshold to
  365. * distinguish inliers from outliers. The method LMeDS does not need any threshold but it works
  366. * correctly only when there are more than 50% of inliers. Finally, if there are no outliers and the
  367. * noise is rather small, use the default method (method=0).
  368. *
  369. * The function is used to find initial intrinsic and extrinsic matrices. Homography matrix is
  370. * determined up to a scale. Thus, it is normalized so that \(h_{33}=1\). Note that whenever an \(H\) matrix
  371. * cannot be estimated, an empty one will be returned.
  372. *
  373. * SEE:
  374. * getAffineTransform, estimateAffine2D, estimateAffinePartial2D, getPerspectiveTransform, warpPerspective,
  375. * perspectiveTransform
  376. * return automatically generated
  377. */
  378. public static Mat findHomography(MatOfPoint2f srcPoints, MatOfPoint2f dstPoints, int method, double ransacReprojThreshold, Mat mask, int maxIters)
  379. {
  380. if (srcPoints != null) srcPoints.ThrowIfDisposed();
  381. if (dstPoints != null) dstPoints.ThrowIfDisposed();
  382. if (mask != null) mask.ThrowIfDisposed();
  383. Mat srcPoints_mat = srcPoints;
  384. Mat dstPoints_mat = dstPoints;
  385. return new Mat(DisposableObject.ThrowIfNullIntPtr(calib3d_Calib3d_findHomography_11(srcPoints_mat.nativeObj, dstPoints_mat.nativeObj, method, ransacReprojThreshold, mask.nativeObj, maxIters)));
  386. }
  387. /**
  388. * Finds a perspective transformation between two planes.
  389. *
  390. * param srcPoints Coordinates of the points in the original plane, a matrix of the type CV_32FC2
  391. * or vector&lt;Point2f&gt; .
  392. * param dstPoints Coordinates of the points in the target plane, a matrix of the type CV_32FC2 or
  393. * a vector&lt;Point2f&gt; .
  394. * param method Method used to compute a homography matrix. The following methods are possible:
  395. * <ul>
  396. * <li>
  397. * <b>0</b> - a regular method using all the points, i.e., the least squares method
  398. * </li>
  399. * <li>
  400. * REF: RANSAC - RANSAC-based robust method
  401. * </li>
  402. * <li>
  403. * REF: LMEDS - Least-Median robust method
  404. * </li>
  405. * <li>
  406. * REF: RHO - PROSAC-based robust method
  407. * </li>
  408. * </ul>
  409. * param ransacReprojThreshold Maximum allowed reprojection error to treat a point pair as an inlier
  410. * (used in the RANSAC and RHO methods only). That is, if
  411. * \(\| \texttt{dstPoints} _i - \texttt{convertPointsHomogeneous} ( \texttt{H} \cdot \texttt{srcPoints} _i) \|_2 &gt; \texttt{ransacReprojThreshold}\)
  412. * then the point \(i\) is considered as an outlier. If srcPoints and dstPoints are measured in pixels,
  413. * it usually makes sense to set this parameter somewhere in the range of 1 to 10.
  414. * param mask Optional output mask set by a robust method ( RANSAC or LMeDS ). Note that the input
  415. * mask values are ignored.
  416. *
  417. * The function finds and returns the perspective transformation \(H\) between the source and the
  418. * destination planes:
  419. *
  420. * \(s_i \vecthree{x'_i}{y'_i}{1} \sim H \vecthree{x_i}{y_i}{1}\)
  421. *
  422. * so that the back-projection error
  423. *
  424. * \(\sum _i \left ( x'_i- \frac{h_{11} x_i + h_{12} y_i + h_{13}}{h_{31} x_i + h_{32} y_i + h_{33}} \right )^2+ \left ( y'_i- \frac{h_{21} x_i + h_{22} y_i + h_{23}}{h_{31} x_i + h_{32} y_i + h_{33}} \right )^2\)
  425. *
  426. * is minimized. If the parameter method is set to the default value 0, the function uses all the point
  427. * pairs to compute an initial homography estimate with a simple least-squares scheme.
  428. *
  429. * However, if not all of the point pairs ( \(srcPoints_i\), \(dstPoints_i\) ) fit the rigid perspective
  430. * transformation (that is, there are some outliers), this initial estimate will be poor. In this case,
  431. * you can use one of the three robust methods. The methods RANSAC, LMeDS and RHO try many different
  432. * random subsets of the corresponding point pairs (of four pairs each, collinear pairs are discarded), estimate the homography matrix
  433. * using this subset and a simple least-squares algorithm, and then compute the quality/goodness of the
  434. * computed homography (which is the number of inliers for RANSAC or the least median re-projection error for
  435. * LMeDS). The best subset is then used to produce the initial estimate of the homography matrix and
  436. * the mask of inliers/outliers.
  437. *
  438. * Regardless of the method, robust or not, the computed homography matrix is refined further (using
  439. * inliers only in case of a robust method) with the Levenberg-Marquardt method to reduce the
  440. * re-projection error even more.
  441. *
  442. * The methods RANSAC and RHO can handle practically any ratio of outliers but need a threshold to
  443. * distinguish inliers from outliers. The method LMeDS does not need any threshold but it works
  444. * correctly only when there are more than 50% of inliers. Finally, if there are no outliers and the
  445. * noise is rather small, use the default method (method=0).
  446. *
  447. * The function is used to find initial intrinsic and extrinsic matrices. Homography matrix is
  448. * determined up to a scale. Thus, it is normalized so that \(h_{33}=1\). Note that whenever an \(H\) matrix
  449. * cannot be estimated, an empty one will be returned.
  450. *
  451. * SEE:
  452. * getAffineTransform, estimateAffine2D, estimateAffinePartial2D, getPerspectiveTransform, warpPerspective,
  453. * perspectiveTransform
  454. * return automatically generated
  455. */
  456. public static Mat findHomography(MatOfPoint2f srcPoints, MatOfPoint2f dstPoints, int method, double ransacReprojThreshold, Mat mask)
  457. {
  458. if (srcPoints != null) srcPoints.ThrowIfDisposed();
  459. if (dstPoints != null) dstPoints.ThrowIfDisposed();
  460. if (mask != null) mask.ThrowIfDisposed();
  461. Mat srcPoints_mat = srcPoints;
  462. Mat dstPoints_mat = dstPoints;
  463. return new Mat(DisposableObject.ThrowIfNullIntPtr(calib3d_Calib3d_findHomography_12(srcPoints_mat.nativeObj, dstPoints_mat.nativeObj, method, ransacReprojThreshold, mask.nativeObj)));
  464. }
  465. /**
  466. * Finds a perspective transformation between two planes.
  467. *
  468. * param srcPoints Coordinates of the points in the original plane, a matrix of the type CV_32FC2
  469. * or vector&lt;Point2f&gt; .
  470. * param dstPoints Coordinates of the points in the target plane, a matrix of the type CV_32FC2 or
  471. * a vector&lt;Point2f&gt; .
  472. * param method Method used to compute a homography matrix. The following methods are possible:
  473. * <ul>
  474. * <li>
  475. * <b>0</b> - a regular method using all the points, i.e., the least squares method
  476. * </li>
  477. * <li>
  478. * REF: RANSAC - RANSAC-based robust method
  479. * </li>
  480. * <li>
  481. * REF: LMEDS - Least-Median robust method
  482. * </li>
  483. * <li>
  484. * REF: RHO - PROSAC-based robust method
  485. * </li>
  486. * </ul>
  487. * param ransacReprojThreshold Maximum allowed reprojection error to treat a point pair as an inlier
  488. * (used in the RANSAC and RHO methods only). That is, if
  489. * \(\| \texttt{dstPoints} _i - \texttt{convertPointsHomogeneous} ( \texttt{H} \cdot \texttt{srcPoints} _i) \|_2 &gt; \texttt{ransacReprojThreshold}\)
  490. * then the point \(i\) is considered as an outlier. If srcPoints and dstPoints are measured in pixels,
  491. * it usually makes sense to set this parameter somewhere in the range of 1 to 10.
  492. * mask values are ignored.
  493. *
  494. * The function finds and returns the perspective transformation \(H\) between the source and the
  495. * destination planes:
  496. *
  497. * \(s_i \vecthree{x'_i}{y'_i}{1} \sim H \vecthree{x_i}{y_i}{1}\)
  498. *
  499. * so that the back-projection error
  500. *
  501. * \(\sum _i \left ( x'_i- \frac{h_{11} x_i + h_{12} y_i + h_{13}}{h_{31} x_i + h_{32} y_i + h_{33}} \right )^2+ \left ( y'_i- \frac{h_{21} x_i + h_{22} y_i + h_{23}}{h_{31} x_i + h_{32} y_i + h_{33}} \right )^2\)
  502. *
  503. * is minimized. If the parameter method is set to the default value 0, the function uses all the point
  504. * pairs to compute an initial homography estimate with a simple least-squares scheme.
  505. *
  506. * However, if not all of the point pairs ( \(srcPoints_i\), \(dstPoints_i\) ) fit the rigid perspective
  507. * transformation (that is, there are some outliers), this initial estimate will be poor. In this case,
  508. * you can use one of the three robust methods. The methods RANSAC, LMeDS and RHO try many different
  509. * random subsets of the corresponding point pairs (of four pairs each, collinear pairs are discarded), estimate the homography matrix
  510. * using this subset and a simple least-squares algorithm, and then compute the quality/goodness of the
  511. * computed homography (which is the number of inliers for RANSAC or the least median re-projection error for
  512. * LMeDS). The best subset is then used to produce the initial estimate of the homography matrix and
  513. * the mask of inliers/outliers.
  514. *
  515. * Regardless of the method, robust or not, the computed homography matrix is refined further (using
  516. * inliers only in case of a robust method) with the Levenberg-Marquardt method to reduce the
  517. * re-projection error even more.
  518. *
  519. * The methods RANSAC and RHO can handle practically any ratio of outliers but need a threshold to
  520. * distinguish inliers from outliers. The method LMeDS does not need any threshold but it works
  521. * correctly only when there are more than 50% of inliers. Finally, if there are no outliers and the
  522. * noise is rather small, use the default method (method=0).
  523. *
  524. * The function is used to find initial intrinsic and extrinsic matrices. Homography matrix is
  525. * determined up to a scale. Thus, it is normalized so that \(h_{33}=1\). Note that whenever an \(H\) matrix
  526. * cannot be estimated, an empty one will be returned.
  527. *
  528. * SEE:
  529. * getAffineTransform, estimateAffine2D, estimateAffinePartial2D, getPerspectiveTransform, warpPerspective,
  530. * perspectiveTransform
  531. * return automatically generated
  532. */
  533. public static Mat findHomography(MatOfPoint2f srcPoints, MatOfPoint2f dstPoints, int method, double ransacReprojThreshold)
  534. {
  535. if (srcPoints != null) srcPoints.ThrowIfDisposed();
  536. if (dstPoints != null) dstPoints.ThrowIfDisposed();
  537. Mat srcPoints_mat = srcPoints;
  538. Mat dstPoints_mat = dstPoints;
  539. return new Mat(DisposableObject.ThrowIfNullIntPtr(calib3d_Calib3d_findHomography_13(srcPoints_mat.nativeObj, dstPoints_mat.nativeObj, method, ransacReprojThreshold)));
  540. }
  541. /**
  542. * Finds a perspective transformation between two planes.
  543. *
  544. * param srcPoints Coordinates of the points in the original plane, a matrix of the type CV_32FC2
  545. * or vector&lt;Point2f&gt; .
  546. * param dstPoints Coordinates of the points in the target plane, a matrix of the type CV_32FC2 or
  547. * a vector&lt;Point2f&gt; .
  548. * param method Method used to compute a homography matrix. The following methods are possible:
  549. * <ul>
  550. * <li>
  551. * <b>0</b> - a regular method using all the points, i.e., the least squares method
  552. * </li>
  553. * <li>
  554. * REF: RANSAC - RANSAC-based robust method
  555. * </li>
  556. * <li>
  557. * REF: LMEDS - Least-Median robust method
  558. * </li>
  559. * <li>
  560. * REF: RHO - PROSAC-based robust method
  561. * </li>
  562. * </ul>
  563. * (used in the RANSAC and RHO methods only). That is, if
  564. * \(\| \texttt{dstPoints} _i - \texttt{convertPointsHomogeneous} ( \texttt{H} \cdot \texttt{srcPoints} _i) \|_2 &gt; \texttt{ransacReprojThreshold}\)
  565. * then the point \(i\) is considered as an outlier. If srcPoints and dstPoints are measured in pixels,
  566. * it usually makes sense to set this parameter somewhere in the range of 1 to 10.
  567. * mask values are ignored.
  568. *
  569. * The function finds and returns the perspective transformation \(H\) between the source and the
  570. * destination planes:
  571. *
  572. * \(s_i \vecthree{x'_i}{y'_i}{1} \sim H \vecthree{x_i}{y_i}{1}\)
  573. *
  574. * so that the back-projection error
  575. *
  576. * \(\sum _i \left ( x'_i- \frac{h_{11} x_i + h_{12} y_i + h_{13}}{h_{31} x_i + h_{32} y_i + h_{33}} \right )^2+ \left ( y'_i- \frac{h_{21} x_i + h_{22} y_i + h_{23}}{h_{31} x_i + h_{32} y_i + h_{33}} \right )^2\)
  577. *
  578. * is minimized. If the parameter method is set to the default value 0, the function uses all the point
  579. * pairs to compute an initial homography estimate with a simple least-squares scheme.
  580. *
  581. * However, if not all of the point pairs ( \(srcPoints_i\), \(dstPoints_i\) ) fit the rigid perspective
  582. * transformation (that is, there are some outliers), this initial estimate will be poor. In this case,
  583. * you can use one of the three robust methods. The methods RANSAC, LMeDS and RHO try many different
  584. * random subsets of the corresponding point pairs (of four pairs each, collinear pairs are discarded), estimate the homography matrix
  585. * using this subset and a simple least-squares algorithm, and then compute the quality/goodness of the
  586. * computed homography (which is the number of inliers for RANSAC or the least median re-projection error for
  587. * LMeDS). The best subset is then used to produce the initial estimate of the homography matrix and
  588. * the mask of inliers/outliers.
  589. *
  590. * Regardless of the method, robust or not, the computed homography matrix is refined further (using
  591. * inliers only in case of a robust method) with the Levenberg-Marquardt method to reduce the
  592. * re-projection error even more.
  593. *
  594. * The methods RANSAC and RHO can handle practically any ratio of outliers but need a threshold to
  595. * distinguish inliers from outliers. The method LMeDS does not need any threshold but it works
  596. * correctly only when there are more than 50% of inliers. Finally, if there are no outliers and the
  597. * noise is rather small, use the default method (method=0).
  598. *
  599. * The function is used to find initial intrinsic and extrinsic matrices. Homography matrix is
  600. * determined up to a scale. Thus, it is normalized so that \(h_{33}=1\). Note that whenever an \(H\) matrix
  601. * cannot be estimated, an empty one will be returned.
  602. *
  603. * SEE:
  604. * getAffineTransform, estimateAffine2D, estimateAffinePartial2D, getPerspectiveTransform, warpPerspective,
  605. * perspectiveTransform
  606. * return automatically generated
  607. */
  608. public static Mat findHomography(MatOfPoint2f srcPoints, MatOfPoint2f dstPoints, int method)
  609. {
  610. if (srcPoints != null) srcPoints.ThrowIfDisposed();
  611. if (dstPoints != null) dstPoints.ThrowIfDisposed();
  612. Mat srcPoints_mat = srcPoints;
  613. Mat dstPoints_mat = dstPoints;
  614. return new Mat(DisposableObject.ThrowIfNullIntPtr(calib3d_Calib3d_findHomography_14(srcPoints_mat.nativeObj, dstPoints_mat.nativeObj, method)));
  615. }
  616. /**
  617. * Finds a perspective transformation between two planes.
  618. *
  619. * param srcPoints Coordinates of the points in the original plane, a matrix of the type CV_32FC2
  620. * or vector&lt;Point2f&gt; .
  621. * param dstPoints Coordinates of the points in the target plane, a matrix of the type CV_32FC2 or
  622. * a vector&lt;Point2f&gt; .
  623. * <ul>
  624. * <li>
  625. * <b>0</b> - a regular method using all the points, i.e., the least squares method
  626. * </li>
  627. * <li>
  628. * REF: RANSAC - RANSAC-based robust method
  629. * </li>
  630. * <li>
  631. * REF: LMEDS - Least-Median robust method
  632. * </li>
  633. * <li>
  634. * REF: RHO - PROSAC-based robust method
  635. * </li>
  636. * </ul>
  637. * (used in the RANSAC and RHO methods only). That is, if
  638. * \(\| \texttt{dstPoints} _i - \texttt{convertPointsHomogeneous} ( \texttt{H} \cdot \texttt{srcPoints} _i) \|_2 &gt; \texttt{ransacReprojThreshold}\)
  639. * then the point \(i\) is considered as an outlier. If srcPoints and dstPoints are measured in pixels,
  640. * it usually makes sense to set this parameter somewhere in the range of 1 to 10.
  641. * mask values are ignored.
  642. *
  643. * The function finds and returns the perspective transformation \(H\) between the source and the
  644. * destination planes:
  645. *
  646. * \(s_i \vecthree{x'_i}{y'_i}{1} \sim H \vecthree{x_i}{y_i}{1}\)
  647. *
  648. * so that the back-projection error
  649. *
  650. * \(\sum _i \left ( x'_i- \frac{h_{11} x_i + h_{12} y_i + h_{13}}{h_{31} x_i + h_{32} y_i + h_{33}} \right )^2+ \left ( y'_i- \frac{h_{21} x_i + h_{22} y_i + h_{23}}{h_{31} x_i + h_{32} y_i + h_{33}} \right )^2\)
  651. *
  652. * is minimized. If the parameter method is set to the default value 0, the function uses all the point
  653. * pairs to compute an initial homography estimate with a simple least-squares scheme.
  654. *
  655. * However, if not all of the point pairs ( \(srcPoints_i\), \(dstPoints_i\) ) fit the rigid perspective
  656. * transformation (that is, there are some outliers), this initial estimate will be poor. In this case,
  657. * you can use one of the three robust methods. The methods RANSAC, LMeDS and RHO try many different
  658. * random subsets of the corresponding point pairs (of four pairs each, collinear pairs are discarded), estimate the homography matrix
  659. * using this subset and a simple least-squares algorithm, and then compute the quality/goodness of the
  660. * computed homography (which is the number of inliers for RANSAC or the least median re-projection error for
  661. * LMeDS). The best subset is then used to produce the initial estimate of the homography matrix and
  662. * the mask of inliers/outliers.
  663. *
  664. * Regardless of the method, robust or not, the computed homography matrix is refined further (using
  665. * inliers only in case of a robust method) with the Levenberg-Marquardt method to reduce the
  666. * re-projection error even more.
  667. *
  668. * The methods RANSAC and RHO can handle practically any ratio of outliers but need a threshold to
  669. * distinguish inliers from outliers. The method LMeDS does not need any threshold but it works
  670. * correctly only when there are more than 50% of inliers. Finally, if there are no outliers and the
  671. * noise is rather small, use the default method (method=0).
  672. *
  673. * The function is used to find initial intrinsic and extrinsic matrices. Homography matrix is
  674. * determined up to a scale. Thus, it is normalized so that \(h_{33}=1\). Note that whenever an \(H\) matrix
  675. * cannot be estimated, an empty one will be returned.
  676. *
  677. * SEE:
  678. * getAffineTransform, estimateAffine2D, estimateAffinePartial2D, getPerspectiveTransform, warpPerspective,
  679. * perspectiveTransform
  680. * return automatically generated
  681. */
  682. public static Mat findHomography(MatOfPoint2f srcPoints, MatOfPoint2f dstPoints)
  683. {
  684. if (srcPoints != null) srcPoints.ThrowIfDisposed();
  685. if (dstPoints != null) dstPoints.ThrowIfDisposed();
  686. Mat srcPoints_mat = srcPoints;
  687. Mat dstPoints_mat = dstPoints;
  688. return new Mat(DisposableObject.ThrowIfNullIntPtr(calib3d_Calib3d_findHomography_15(srcPoints_mat.nativeObj, dstPoints_mat.nativeObj)));
  689. }
  690. //
  691. // C++: Mat cv::findHomography(vector_Point2f srcPoints, vector_Point2f dstPoints, Mat& mask, UsacParams _params)
  692. //
  693. public static Mat findHomography(MatOfPoint2f srcPoints, MatOfPoint2f dstPoints, Mat mask, UsacParams _params)
  694. {
  695. if (srcPoints != null) srcPoints.ThrowIfDisposed();
  696. if (dstPoints != null) dstPoints.ThrowIfDisposed();
  697. if (mask != null) mask.ThrowIfDisposed();
  698. if (_params != null) _params.ThrowIfDisposed();
  699. Mat srcPoints_mat = srcPoints;
  700. Mat dstPoints_mat = dstPoints;
  701. return new Mat(DisposableObject.ThrowIfNullIntPtr(calib3d_Calib3d_findHomography_16(srcPoints_mat.nativeObj, dstPoints_mat.nativeObj, mask.nativeObj, _params.nativeObj)));
  702. }
  703. //
  704. // C++: Vec3d cv::RQDecomp3x3(Mat src, Mat& mtxR, Mat& mtxQ, Mat& Qx = Mat(), Mat& Qy = Mat(), Mat& Qz = Mat())
  705. //
  706. /**
  707. * Computes an RQ decomposition of 3x3 matrices.
  708. *
  709. * param src 3x3 input matrix.
  710. * param mtxR Output 3x3 upper-triangular matrix.
  711. * param mtxQ Output 3x3 orthogonal matrix.
  712. * param Qx Optional output 3x3 rotation matrix around x-axis.
  713. * param Qy Optional output 3x3 rotation matrix around y-axis.
  714. * param Qz Optional output 3x3 rotation matrix around z-axis.
  715. *
  716. * The function computes a RQ decomposition using the given rotations. This function is used in
  717. * #decomposeProjectionMatrix to decompose the left 3x3 submatrix of a projection matrix into a camera
  718. * and a rotation matrix.
  719. *
  720. * It optionally returns three rotation matrices, one for each axis, and the three Euler angles in
  721. * degrees (as the return value) that could be used in OpenGL. Note, there is always more than one
  722. * sequence of rotations about the three principal axes that results in the same orientation of an
  723. * object, e.g. see CITE: Slabaugh . Returned tree rotation matrices and corresponding three Euler angles
  724. * are only one of the possible solutions.
  725. * return automatically generated
  726. */
  727. public static double[] RQDecomp3x3(Mat src, Mat mtxR, Mat mtxQ, Mat Qx, Mat Qy, Mat Qz)
  728. {
  729. if (src != null) src.ThrowIfDisposed();
  730. if (mtxR != null) mtxR.ThrowIfDisposed();
  731. if (mtxQ != null) mtxQ.ThrowIfDisposed();
  732. if (Qx != null) Qx.ThrowIfDisposed();
  733. if (Qy != null) Qy.ThrowIfDisposed();
  734. if (Qz != null) Qz.ThrowIfDisposed();
  735. double[] retVal = new double[3];
  736. calib3d_Calib3d_RQDecomp3x3_10(src.nativeObj, mtxR.nativeObj, mtxQ.nativeObj, Qx.nativeObj, Qy.nativeObj, Qz.nativeObj, retVal);
  737. return retVal;
  738. }
  739. /**
  740. * Computes an RQ decomposition of 3x3 matrices.
  741. *
  742. * param src 3x3 input matrix.
  743. * param mtxR Output 3x3 upper-triangular matrix.
  744. * param mtxQ Output 3x3 orthogonal matrix.
  745. * param Qx Optional output 3x3 rotation matrix around x-axis.
  746. * param Qy Optional output 3x3 rotation matrix around y-axis.
  747. *
  748. * The function computes a RQ decomposition using the given rotations. This function is used in
  749. * #decomposeProjectionMatrix to decompose the left 3x3 submatrix of a projection matrix into a camera
  750. * and a rotation matrix.
  751. *
  752. * It optionally returns three rotation matrices, one for each axis, and the three Euler angles in
  753. * degrees (as the return value) that could be used in OpenGL. Note, there is always more than one
  754. * sequence of rotations about the three principal axes that results in the same orientation of an
  755. * object, e.g. see CITE: Slabaugh . Returned tree rotation matrices and corresponding three Euler angles
  756. * are only one of the possible solutions.
  757. * return automatically generated
  758. */
  759. public static double[] RQDecomp3x3(Mat src, Mat mtxR, Mat mtxQ, Mat Qx, Mat Qy)
  760. {
  761. if (src != null) src.ThrowIfDisposed();
  762. if (mtxR != null) mtxR.ThrowIfDisposed();
  763. if (mtxQ != null) mtxQ.ThrowIfDisposed();
  764. if (Qx != null) Qx.ThrowIfDisposed();
  765. if (Qy != null) Qy.ThrowIfDisposed();
  766. double[] retVal = new double[3];
  767. calib3d_Calib3d_RQDecomp3x3_11(src.nativeObj, mtxR.nativeObj, mtxQ.nativeObj, Qx.nativeObj, Qy.nativeObj, retVal);
  768. return retVal;
  769. }
  770. /**
  771. * Computes an RQ decomposition of 3x3 matrices.
  772. *
  773. * param src 3x3 input matrix.
  774. * param mtxR Output 3x3 upper-triangular matrix.
  775. * param mtxQ Output 3x3 orthogonal matrix.
  776. * param Qx Optional output 3x3 rotation matrix around x-axis.
  777. *
  778. * The function computes a RQ decomposition using the given rotations. This function is used in
  779. * #decomposeProjectionMatrix to decompose the left 3x3 submatrix of a projection matrix into a camera
  780. * and a rotation matrix.
  781. *
  782. * It optionally returns three rotation matrices, one for each axis, and the three Euler angles in
  783. * degrees (as the return value) that could be used in OpenGL. Note, there is always more than one
  784. * sequence of rotations about the three principal axes that results in the same orientation of an
  785. * object, e.g. see CITE: Slabaugh . Returned tree rotation matrices and corresponding three Euler angles
  786. * are only one of the possible solutions.
  787. * return automatically generated
  788. */
  789. public static double[] RQDecomp3x3(Mat src, Mat mtxR, Mat mtxQ, Mat Qx)
  790. {
  791. if (src != null) src.ThrowIfDisposed();
  792. if (mtxR != null) mtxR.ThrowIfDisposed();
  793. if (mtxQ != null) mtxQ.ThrowIfDisposed();
  794. if (Qx != null) Qx.ThrowIfDisposed();
  795. double[] retVal = new double[3];
  796. calib3d_Calib3d_RQDecomp3x3_12(src.nativeObj, mtxR.nativeObj, mtxQ.nativeObj, Qx.nativeObj, retVal);
  797. return retVal;
  798. }
  799. /**
  800. * Computes an RQ decomposition of 3x3 matrices.
  801. *
  802. * param src 3x3 input matrix.
  803. * param mtxR Output 3x3 upper-triangular matrix.
  804. * param mtxQ Output 3x3 orthogonal matrix.
  805. *
  806. * The function computes a RQ decomposition using the given rotations. This function is used in
  807. * #decomposeProjectionMatrix to decompose the left 3x3 submatrix of a projection matrix into a camera
  808. * and a rotation matrix.
  809. *
  810. * It optionally returns three rotation matrices, one for each axis, and the three Euler angles in
  811. * degrees (as the return value) that could be used in OpenGL. Note, there is always more than one
  812. * sequence of rotations about the three principal axes that results in the same orientation of an
  813. * object, e.g. see CITE: Slabaugh . Returned tree rotation matrices and corresponding three Euler angles
  814. * are only one of the possible solutions.
  815. * return automatically generated
  816. */
  817. public static double[] RQDecomp3x3(Mat src, Mat mtxR, Mat mtxQ)
  818. {
  819. if (src != null) src.ThrowIfDisposed();
  820. if (mtxR != null) mtxR.ThrowIfDisposed();
  821. if (mtxQ != null) mtxQ.ThrowIfDisposed();
  822. double[] retVal = new double[3];
  823. calib3d_Calib3d_RQDecomp3x3_13(src.nativeObj, mtxR.nativeObj, mtxQ.nativeObj, retVal);
  824. return retVal;
  825. }
  826. //
  827. // C++: void cv::decomposeProjectionMatrix(Mat projMatrix, Mat& cameraMatrix, Mat& rotMatrix, Mat& transVect, Mat& rotMatrixX = Mat(), Mat& rotMatrixY = Mat(), Mat& rotMatrixZ = Mat(), Mat& eulerAngles = Mat())
  828. //
  829. /**
  830. * Decomposes a projection matrix into a rotation matrix and a camera intrinsic matrix.
  831. *
  832. * param projMatrix 3x4 input projection matrix P.
  833. * param cameraMatrix Output 3x3 camera intrinsic matrix \(\cameramatrix{A}\).
  834. * param rotMatrix Output 3x3 external rotation matrix R.
  835. * param transVect Output 4x1 translation vector T.
  836. * param rotMatrixX Optional 3x3 rotation matrix around x-axis.
  837. * param rotMatrixY Optional 3x3 rotation matrix around y-axis.
  838. * param rotMatrixZ Optional 3x3 rotation matrix around z-axis.
  839. * param eulerAngles Optional three-element vector containing three Euler angles of rotation in
  840. * degrees.
  841. *
  842. * The function computes a decomposition of a projection matrix into a calibration and a rotation
  843. * matrix and the position of a camera.
  844. *
  845. * It optionally returns three rotation matrices, one for each axis, and three Euler angles that could
  846. * be used in OpenGL. Note, there is always more than one sequence of rotations about the three
  847. * principal axes that results in the same orientation of an object, e.g. see CITE: Slabaugh . Returned
  848. * tree rotation matrices and corresponding three Euler angles are only one of the possible solutions.
  849. *
  850. * The function is based on #RQDecomp3x3 .
  851. */
  852. public static void decomposeProjectionMatrix(Mat projMatrix, Mat cameraMatrix, Mat rotMatrix, Mat transVect, Mat rotMatrixX, Mat rotMatrixY, Mat rotMatrixZ, Mat eulerAngles)
  853. {
  854. if (projMatrix != null) projMatrix.ThrowIfDisposed();
  855. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  856. if (rotMatrix != null) rotMatrix.ThrowIfDisposed();
  857. if (transVect != null) transVect.ThrowIfDisposed();
  858. if (rotMatrixX != null) rotMatrixX.ThrowIfDisposed();
  859. if (rotMatrixY != null) rotMatrixY.ThrowIfDisposed();
  860. if (rotMatrixZ != null) rotMatrixZ.ThrowIfDisposed();
  861. if (eulerAngles != null) eulerAngles.ThrowIfDisposed();
  862. calib3d_Calib3d_decomposeProjectionMatrix_10(projMatrix.nativeObj, cameraMatrix.nativeObj, rotMatrix.nativeObj, transVect.nativeObj, rotMatrixX.nativeObj, rotMatrixY.nativeObj, rotMatrixZ.nativeObj, eulerAngles.nativeObj);
  863. }
  864. /**
  865. * Decomposes a projection matrix into a rotation matrix and a camera intrinsic matrix.
  866. *
  867. * param projMatrix 3x4 input projection matrix P.
  868. * param cameraMatrix Output 3x3 camera intrinsic matrix \(\cameramatrix{A}\).
  869. * param rotMatrix Output 3x3 external rotation matrix R.
  870. * param transVect Output 4x1 translation vector T.
  871. * param rotMatrixX Optional 3x3 rotation matrix around x-axis.
  872. * param rotMatrixY Optional 3x3 rotation matrix around y-axis.
  873. * param rotMatrixZ Optional 3x3 rotation matrix around z-axis.
  874. * degrees.
  875. *
  876. * The function computes a decomposition of a projection matrix into a calibration and a rotation
  877. * matrix and the position of a camera.
  878. *
  879. * It optionally returns three rotation matrices, one for each axis, and three Euler angles that could
  880. * be used in OpenGL. Note, there is always more than one sequence of rotations about the three
  881. * principal axes that results in the same orientation of an object, e.g. see CITE: Slabaugh . Returned
  882. * tree rotation matrices and corresponding three Euler angles are only one of the possible solutions.
  883. *
  884. * The function is based on #RQDecomp3x3 .
  885. */
  886. public static void decomposeProjectionMatrix(Mat projMatrix, Mat cameraMatrix, Mat rotMatrix, Mat transVect, Mat rotMatrixX, Mat rotMatrixY, Mat rotMatrixZ)
  887. {
  888. if (projMatrix != null) projMatrix.ThrowIfDisposed();
  889. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  890. if (rotMatrix != null) rotMatrix.ThrowIfDisposed();
  891. if (transVect != null) transVect.ThrowIfDisposed();
  892. if (rotMatrixX != null) rotMatrixX.ThrowIfDisposed();
  893. if (rotMatrixY != null) rotMatrixY.ThrowIfDisposed();
  894. if (rotMatrixZ != null) rotMatrixZ.ThrowIfDisposed();
  895. calib3d_Calib3d_decomposeProjectionMatrix_11(projMatrix.nativeObj, cameraMatrix.nativeObj, rotMatrix.nativeObj, transVect.nativeObj, rotMatrixX.nativeObj, rotMatrixY.nativeObj, rotMatrixZ.nativeObj);
  896. }
  897. /**
  898. * Decomposes a projection matrix into a rotation matrix and a camera intrinsic matrix.
  899. *
  900. * param projMatrix 3x4 input projection matrix P.
  901. * param cameraMatrix Output 3x3 camera intrinsic matrix \(\cameramatrix{A}\).
  902. * param rotMatrix Output 3x3 external rotation matrix R.
  903. * param transVect Output 4x1 translation vector T.
  904. * param rotMatrixX Optional 3x3 rotation matrix around x-axis.
  905. * param rotMatrixY Optional 3x3 rotation matrix around y-axis.
  906. * degrees.
  907. *
  908. * The function computes a decomposition of a projection matrix into a calibration and a rotation
  909. * matrix and the position of a camera.
  910. *
  911. * It optionally returns three rotation matrices, one for each axis, and three Euler angles that could
  912. * be used in OpenGL. Note, there is always more than one sequence of rotations about the three
  913. * principal axes that results in the same orientation of an object, e.g. see CITE: Slabaugh . Returned
  914. * tree rotation matrices and corresponding three Euler angles are only one of the possible solutions.
  915. *
  916. * The function is based on #RQDecomp3x3 .
  917. */
  918. public static void decomposeProjectionMatrix(Mat projMatrix, Mat cameraMatrix, Mat rotMatrix, Mat transVect, Mat rotMatrixX, Mat rotMatrixY)
  919. {
  920. if (projMatrix != null) projMatrix.ThrowIfDisposed();
  921. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  922. if (rotMatrix != null) rotMatrix.ThrowIfDisposed();
  923. if (transVect != null) transVect.ThrowIfDisposed();
  924. if (rotMatrixX != null) rotMatrixX.ThrowIfDisposed();
  925. if (rotMatrixY != null) rotMatrixY.ThrowIfDisposed();
  926. calib3d_Calib3d_decomposeProjectionMatrix_12(projMatrix.nativeObj, cameraMatrix.nativeObj, rotMatrix.nativeObj, transVect.nativeObj, rotMatrixX.nativeObj, rotMatrixY.nativeObj);
  927. }
  928. /**
  929. * Decomposes a projection matrix into a rotation matrix and a camera intrinsic matrix.
  930. *
  931. * param projMatrix 3x4 input projection matrix P.
  932. * param cameraMatrix Output 3x3 camera intrinsic matrix \(\cameramatrix{A}\).
  933. * param rotMatrix Output 3x3 external rotation matrix R.
  934. * param transVect Output 4x1 translation vector T.
  935. * param rotMatrixX Optional 3x3 rotation matrix around x-axis.
  936. * degrees.
  937. *
  938. * The function computes a decomposition of a projection matrix into a calibration and a rotation
  939. * matrix and the position of a camera.
  940. *
  941. * It optionally returns three rotation matrices, one for each axis, and three Euler angles that could
  942. * be used in OpenGL. Note, there is always more than one sequence of rotations about the three
  943. * principal axes that results in the same orientation of an object, e.g. see CITE: Slabaugh . Returned
  944. * tree rotation matrices and corresponding three Euler angles are only one of the possible solutions.
  945. *
  946. * The function is based on #RQDecomp3x3 .
  947. */
  948. public static void decomposeProjectionMatrix(Mat projMatrix, Mat cameraMatrix, Mat rotMatrix, Mat transVect, Mat rotMatrixX)
  949. {
  950. if (projMatrix != null) projMatrix.ThrowIfDisposed();
  951. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  952. if (rotMatrix != null) rotMatrix.ThrowIfDisposed();
  953. if (transVect != null) transVect.ThrowIfDisposed();
  954. if (rotMatrixX != null) rotMatrixX.ThrowIfDisposed();
  955. calib3d_Calib3d_decomposeProjectionMatrix_13(projMatrix.nativeObj, cameraMatrix.nativeObj, rotMatrix.nativeObj, transVect.nativeObj, rotMatrixX.nativeObj);
  956. }
  957. /**
  958. * Decomposes a projection matrix into a rotation matrix and a camera intrinsic matrix.
  959. *
  960. * param projMatrix 3x4 input projection matrix P.
  961. * param cameraMatrix Output 3x3 camera intrinsic matrix \(\cameramatrix{A}\).
  962. * param rotMatrix Output 3x3 external rotation matrix R.
  963. * param transVect Output 4x1 translation vector T.
  964. * degrees.
  965. *
  966. * The function computes a decomposition of a projection matrix into a calibration and a rotation
  967. * matrix and the position of a camera.
  968. *
  969. * It optionally returns three rotation matrices, one for each axis, and three Euler angles that could
  970. * be used in OpenGL. Note, there is always more than one sequence of rotations about the three
  971. * principal axes that results in the same orientation of an object, e.g. see CITE: Slabaugh . Returned
  972. * tree rotation matrices and corresponding three Euler angles are only one of the possible solutions.
  973. *
  974. * The function is based on #RQDecomp3x3 .
  975. */
  976. public static void decomposeProjectionMatrix(Mat projMatrix, Mat cameraMatrix, Mat rotMatrix, Mat transVect)
  977. {
  978. if (projMatrix != null) projMatrix.ThrowIfDisposed();
  979. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  980. if (rotMatrix != null) rotMatrix.ThrowIfDisposed();
  981. if (transVect != null) transVect.ThrowIfDisposed();
  982. calib3d_Calib3d_decomposeProjectionMatrix_14(projMatrix.nativeObj, cameraMatrix.nativeObj, rotMatrix.nativeObj, transVect.nativeObj);
  983. }
  984. //
  985. // C++: void cv::matMulDeriv(Mat A, Mat B, Mat& dABdA, Mat& dABdB)
  986. //
  987. /**
  988. * Computes partial derivatives of the matrix product for each multiplied matrix.
  989. *
  990. * param A First multiplied matrix.
  991. * param B Second multiplied matrix.
  992. * param dABdA First output derivative matrix d(A\*B)/dA of size
  993. * \(\texttt{A.rows*B.cols} \times {A.rows*A.cols}\) .
  994. * param dABdB Second output derivative matrix d(A\*B)/dB of size
  995. * \(\texttt{A.rows*B.cols} \times {B.rows*B.cols}\) .
  996. *
  997. * The function computes partial derivatives of the elements of the matrix product \(A*B\) with regard to
  998. * the elements of each of the two input matrices. The function is used to compute the Jacobian
  999. * matrices in #stereoCalibrate but can also be used in any other similar optimization function.
  1000. */
  1001. public static void matMulDeriv(Mat A, Mat B, Mat dABdA, Mat dABdB)
  1002. {
  1003. if (A != null) A.ThrowIfDisposed();
  1004. if (B != null) B.ThrowIfDisposed();
  1005. if (dABdA != null) dABdA.ThrowIfDisposed();
  1006. if (dABdB != null) dABdB.ThrowIfDisposed();
  1007. calib3d_Calib3d_matMulDeriv_10(A.nativeObj, B.nativeObj, dABdA.nativeObj, dABdB.nativeObj);
  1008. }
  1009. //
  1010. // C++: void cv::composeRT(Mat rvec1, Mat tvec1, Mat rvec2, Mat tvec2, Mat& rvec3, Mat& tvec3, Mat& dr3dr1 = Mat(), Mat& dr3dt1 = Mat(), Mat& dr3dr2 = Mat(), Mat& dr3dt2 = Mat(), Mat& dt3dr1 = Mat(), Mat& dt3dt1 = Mat(), Mat& dt3dr2 = Mat(), Mat& dt3dt2 = Mat())
  1011. //
  1012. /**
  1013. * Combines two rotation-and-shift transformations.
  1014. *
  1015. * param rvec1 First rotation vector.
  1016. * param tvec1 First translation vector.
  1017. * param rvec2 Second rotation vector.
  1018. * param tvec2 Second translation vector.
  1019. * param rvec3 Output rotation vector of the superposition.
  1020. * param tvec3 Output translation vector of the superposition.
  1021. * param dr3dr1 Optional output derivative of rvec3 with regard to rvec1
  1022. * param dr3dt1 Optional output derivative of rvec3 with regard to tvec1
  1023. * param dr3dr2 Optional output derivative of rvec3 with regard to rvec2
  1024. * param dr3dt2 Optional output derivative of rvec3 with regard to tvec2
  1025. * param dt3dr1 Optional output derivative of tvec3 with regard to rvec1
  1026. * param dt3dt1 Optional output derivative of tvec3 with regard to tvec1
  1027. * param dt3dr2 Optional output derivative of tvec3 with regard to rvec2
  1028. * param dt3dt2 Optional output derivative of tvec3 with regard to tvec2
  1029. *
  1030. * The functions compute:
  1031. *
  1032. * \(\begin{array}{l} \texttt{rvec3} = \mathrm{rodrigues} ^{-1} \left ( \mathrm{rodrigues} ( \texttt{rvec2} ) \cdot \mathrm{rodrigues} ( \texttt{rvec1} ) \right ) \\ \texttt{tvec3} = \mathrm{rodrigues} ( \texttt{rvec2} ) \cdot \texttt{tvec1} + \texttt{tvec2} \end{array} ,\)
  1033. *
  1034. * where \(\mathrm{rodrigues}\) denotes a rotation vector to a rotation matrix transformation, and
  1035. * \(\mathrm{rodrigues}^{-1}\) denotes the inverse transformation. See #Rodrigues for details.
  1036. *
  1037. * Also, the functions can compute the derivatives of the output vectors with regards to the input
  1038. * vectors (see #matMulDeriv ). The functions are used inside #stereoCalibrate but can also be used in
  1039. * your own code where Levenberg-Marquardt or another gradient-based solver is used to optimize a
  1040. * function that contains a matrix multiplication.
  1041. */
  1042. public static void composeRT(Mat rvec1, Mat tvec1, Mat rvec2, Mat tvec2, Mat rvec3, Mat tvec3, Mat dr3dr1, Mat dr3dt1, Mat dr3dr2, Mat dr3dt2, Mat dt3dr1, Mat dt3dt1, Mat dt3dr2, Mat dt3dt2)
  1043. {
  1044. if (rvec1 != null) rvec1.ThrowIfDisposed();
  1045. if (tvec1 != null) tvec1.ThrowIfDisposed();
  1046. if (rvec2 != null) rvec2.ThrowIfDisposed();
  1047. if (tvec2 != null) tvec2.ThrowIfDisposed();
  1048. if (rvec3 != null) rvec3.ThrowIfDisposed();
  1049. if (tvec3 != null) tvec3.ThrowIfDisposed();
  1050. if (dr3dr1 != null) dr3dr1.ThrowIfDisposed();
  1051. if (dr3dt1 != null) dr3dt1.ThrowIfDisposed();
  1052. if (dr3dr2 != null) dr3dr2.ThrowIfDisposed();
  1053. if (dr3dt2 != null) dr3dt2.ThrowIfDisposed();
  1054. if (dt3dr1 != null) dt3dr1.ThrowIfDisposed();
  1055. if (dt3dt1 != null) dt3dt1.ThrowIfDisposed();
  1056. if (dt3dr2 != null) dt3dr2.ThrowIfDisposed();
  1057. if (dt3dt2 != null) dt3dt2.ThrowIfDisposed();
  1058. calib3d_Calib3d_composeRT_10(rvec1.nativeObj, tvec1.nativeObj, rvec2.nativeObj, tvec2.nativeObj, rvec3.nativeObj, tvec3.nativeObj, dr3dr1.nativeObj, dr3dt1.nativeObj, dr3dr2.nativeObj, dr3dt2.nativeObj, dt3dr1.nativeObj, dt3dt1.nativeObj, dt3dr2.nativeObj, dt3dt2.nativeObj);
  1059. }
  1060. /**
  1061. * Combines two rotation-and-shift transformations.
  1062. *
  1063. * param rvec1 First rotation vector.
  1064. * param tvec1 First translation vector.
  1065. * param rvec2 Second rotation vector.
  1066. * param tvec2 Second translation vector.
  1067. * param rvec3 Output rotation vector of the superposition.
  1068. * param tvec3 Output translation vector of the superposition.
  1069. * param dr3dr1 Optional output derivative of rvec3 with regard to rvec1
  1070. * param dr3dt1 Optional output derivative of rvec3 with regard to tvec1
  1071. * param dr3dr2 Optional output derivative of rvec3 with regard to rvec2
  1072. * param dr3dt2 Optional output derivative of rvec3 with regard to tvec2
  1073. * param dt3dr1 Optional output derivative of tvec3 with regard to rvec1
  1074. * param dt3dt1 Optional output derivative of tvec3 with regard to tvec1
  1075. * param dt3dr2 Optional output derivative of tvec3 with regard to rvec2
  1076. *
  1077. * The functions compute:
  1078. *
  1079. * \(\begin{array}{l} \texttt{rvec3} = \mathrm{rodrigues} ^{-1} \left ( \mathrm{rodrigues} ( \texttt{rvec2} ) \cdot \mathrm{rodrigues} ( \texttt{rvec1} ) \right ) \\ \texttt{tvec3} = \mathrm{rodrigues} ( \texttt{rvec2} ) \cdot \texttt{tvec1} + \texttt{tvec2} \end{array} ,\)
  1080. *
  1081. * where \(\mathrm{rodrigues}\) denotes a rotation vector to a rotation matrix transformation, and
  1082. * \(\mathrm{rodrigues}^{-1}\) denotes the inverse transformation. See #Rodrigues for details.
  1083. *
  1084. * Also, the functions can compute the derivatives of the output vectors with regards to the input
  1085. * vectors (see #matMulDeriv ). The functions are used inside #stereoCalibrate but can also be used in
  1086. * your own code where Levenberg-Marquardt or another gradient-based solver is used to optimize a
  1087. * function that contains a matrix multiplication.
  1088. */
  1089. public static void composeRT(Mat rvec1, Mat tvec1, Mat rvec2, Mat tvec2, Mat rvec3, Mat tvec3, Mat dr3dr1, Mat dr3dt1, Mat dr3dr2, Mat dr3dt2, Mat dt3dr1, Mat dt3dt1, Mat dt3dr2)
  1090. {
  1091. if (rvec1 != null) rvec1.ThrowIfDisposed();
  1092. if (tvec1 != null) tvec1.ThrowIfDisposed();
  1093. if (rvec2 != null) rvec2.ThrowIfDisposed();
  1094. if (tvec2 != null) tvec2.ThrowIfDisposed();
  1095. if (rvec3 != null) rvec3.ThrowIfDisposed();
  1096. if (tvec3 != null) tvec3.ThrowIfDisposed();
  1097. if (dr3dr1 != null) dr3dr1.ThrowIfDisposed();
  1098. if (dr3dt1 != null) dr3dt1.ThrowIfDisposed();
  1099. if (dr3dr2 != null) dr3dr2.ThrowIfDisposed();
  1100. if (dr3dt2 != null) dr3dt2.ThrowIfDisposed();
  1101. if (dt3dr1 != null) dt3dr1.ThrowIfDisposed();
  1102. if (dt3dt1 != null) dt3dt1.ThrowIfDisposed();
  1103. if (dt3dr2 != null) dt3dr2.ThrowIfDisposed();
  1104. calib3d_Calib3d_composeRT_11(rvec1.nativeObj, tvec1.nativeObj, rvec2.nativeObj, tvec2.nativeObj, rvec3.nativeObj, tvec3.nativeObj, dr3dr1.nativeObj, dr3dt1.nativeObj, dr3dr2.nativeObj, dr3dt2.nativeObj, dt3dr1.nativeObj, dt3dt1.nativeObj, dt3dr2.nativeObj);
  1105. }
  1106. /**
  1107. * Combines two rotation-and-shift transformations.
  1108. *
  1109. * param rvec1 First rotation vector.
  1110. * param tvec1 First translation vector.
  1111. * param rvec2 Second rotation vector.
  1112. * param tvec2 Second translation vector.
  1113. * param rvec3 Output rotation vector of the superposition.
  1114. * param tvec3 Output translation vector of the superposition.
  1115. * param dr3dr1 Optional output derivative of rvec3 with regard to rvec1
  1116. * param dr3dt1 Optional output derivative of rvec3 with regard to tvec1
  1117. * param dr3dr2 Optional output derivative of rvec3 with regard to rvec2
  1118. * param dr3dt2 Optional output derivative of rvec3 with regard to tvec2
  1119. * param dt3dr1 Optional output derivative of tvec3 with regard to rvec1
  1120. * param dt3dt1 Optional output derivative of tvec3 with regard to tvec1
  1121. *
  1122. * The functions compute:
  1123. *
  1124. * \(\begin{array}{l} \texttt{rvec3} = \mathrm{rodrigues} ^{-1} \left ( \mathrm{rodrigues} ( \texttt{rvec2} ) \cdot \mathrm{rodrigues} ( \texttt{rvec1} ) \right ) \\ \texttt{tvec3} = \mathrm{rodrigues} ( \texttt{rvec2} ) \cdot \texttt{tvec1} + \texttt{tvec2} \end{array} ,\)
  1125. *
  1126. * where \(\mathrm{rodrigues}\) denotes a rotation vector to a rotation matrix transformation, and
  1127. * \(\mathrm{rodrigues}^{-1}\) denotes the inverse transformation. See #Rodrigues for details.
  1128. *
  1129. * Also, the functions can compute the derivatives of the output vectors with regards to the input
  1130. * vectors (see #matMulDeriv ). The functions are used inside #stereoCalibrate but can also be used in
  1131. * your own code where Levenberg-Marquardt or another gradient-based solver is used to optimize a
  1132. * function that contains a matrix multiplication.
  1133. */
  1134. public static void composeRT(Mat rvec1, Mat tvec1, Mat rvec2, Mat tvec2, Mat rvec3, Mat tvec3, Mat dr3dr1, Mat dr3dt1, Mat dr3dr2, Mat dr3dt2, Mat dt3dr1, Mat dt3dt1)
  1135. {
  1136. if (rvec1 != null) rvec1.ThrowIfDisposed();
  1137. if (tvec1 != null) tvec1.ThrowIfDisposed();
  1138. if (rvec2 != null) rvec2.ThrowIfDisposed();
  1139. if (tvec2 != null) tvec2.ThrowIfDisposed();
  1140. if (rvec3 != null) rvec3.ThrowIfDisposed();
  1141. if (tvec3 != null) tvec3.ThrowIfDisposed();
  1142. if (dr3dr1 != null) dr3dr1.ThrowIfDisposed();
  1143. if (dr3dt1 != null) dr3dt1.ThrowIfDisposed();
  1144. if (dr3dr2 != null) dr3dr2.ThrowIfDisposed();
  1145. if (dr3dt2 != null) dr3dt2.ThrowIfDisposed();
  1146. if (dt3dr1 != null) dt3dr1.ThrowIfDisposed();
  1147. if (dt3dt1 != null) dt3dt1.ThrowIfDisposed();
  1148. calib3d_Calib3d_composeRT_12(rvec1.nativeObj, tvec1.nativeObj, rvec2.nativeObj, tvec2.nativeObj, rvec3.nativeObj, tvec3.nativeObj, dr3dr1.nativeObj, dr3dt1.nativeObj, dr3dr2.nativeObj, dr3dt2.nativeObj, dt3dr1.nativeObj, dt3dt1.nativeObj);
  1149. }
  1150. /**
  1151. * Combines two rotation-and-shift transformations.
  1152. *
  1153. * param rvec1 First rotation vector.
  1154. * param tvec1 First translation vector.
  1155. * param rvec2 Second rotation vector.
  1156. * param tvec2 Second translation vector.
  1157. * param rvec3 Output rotation vector of the superposition.
  1158. * param tvec3 Output translation vector of the superposition.
  1159. * param dr3dr1 Optional output derivative of rvec3 with regard to rvec1
  1160. * param dr3dt1 Optional output derivative of rvec3 with regard to tvec1
  1161. * param dr3dr2 Optional output derivative of rvec3 with regard to rvec2
  1162. * param dr3dt2 Optional output derivative of rvec3 with regard to tvec2
  1163. * param dt3dr1 Optional output derivative of tvec3 with regard to rvec1
  1164. *
  1165. * The functions compute:
  1166. *
  1167. * \(\begin{array}{l} \texttt{rvec3} = \mathrm{rodrigues} ^{-1} \left ( \mathrm{rodrigues} ( \texttt{rvec2} ) \cdot \mathrm{rodrigues} ( \texttt{rvec1} ) \right ) \\ \texttt{tvec3} = \mathrm{rodrigues} ( \texttt{rvec2} ) \cdot \texttt{tvec1} + \texttt{tvec2} \end{array} ,\)
  1168. *
  1169. * where \(\mathrm{rodrigues}\) denotes a rotation vector to a rotation matrix transformation, and
  1170. * \(\mathrm{rodrigues}^{-1}\) denotes the inverse transformation. See #Rodrigues for details.
  1171. *
  1172. * Also, the functions can compute the derivatives of the output vectors with regards to the input
  1173. * vectors (see #matMulDeriv ). The functions are used inside #stereoCalibrate but can also be used in
  1174. * your own code where Levenberg-Marquardt or another gradient-based solver is used to optimize a
  1175. * function that contains a matrix multiplication.
  1176. */
  1177. public static void composeRT(Mat rvec1, Mat tvec1, Mat rvec2, Mat tvec2, Mat rvec3, Mat tvec3, Mat dr3dr1, Mat dr3dt1, Mat dr3dr2, Mat dr3dt2, Mat dt3dr1)
  1178. {
  1179. if (rvec1 != null) rvec1.ThrowIfDisposed();
  1180. if (tvec1 != null) tvec1.ThrowIfDisposed();
  1181. if (rvec2 != null) rvec2.ThrowIfDisposed();
  1182. if (tvec2 != null) tvec2.ThrowIfDisposed();
  1183. if (rvec3 != null) rvec3.ThrowIfDisposed();
  1184. if (tvec3 != null) tvec3.ThrowIfDisposed();
  1185. if (dr3dr1 != null) dr3dr1.ThrowIfDisposed();
  1186. if (dr3dt1 != null) dr3dt1.ThrowIfDisposed();
  1187. if (dr3dr2 != null) dr3dr2.ThrowIfDisposed();
  1188. if (dr3dt2 != null) dr3dt2.ThrowIfDisposed();
  1189. if (dt3dr1 != null) dt3dr1.ThrowIfDisposed();
  1190. calib3d_Calib3d_composeRT_13(rvec1.nativeObj, tvec1.nativeObj, rvec2.nativeObj, tvec2.nativeObj, rvec3.nativeObj, tvec3.nativeObj, dr3dr1.nativeObj, dr3dt1.nativeObj, dr3dr2.nativeObj, dr3dt2.nativeObj, dt3dr1.nativeObj);
  1191. }
  1192. /**
  1193. * Combines two rotation-and-shift transformations.
  1194. *
  1195. * param rvec1 First rotation vector.
  1196. * param tvec1 First translation vector.
  1197. * param rvec2 Second rotation vector.
  1198. * param tvec2 Second translation vector.
  1199. * param rvec3 Output rotation vector of the superposition.
  1200. * param tvec3 Output translation vector of the superposition.
  1201. * param dr3dr1 Optional output derivative of rvec3 with regard to rvec1
  1202. * param dr3dt1 Optional output derivative of rvec3 with regard to tvec1
  1203. * param dr3dr2 Optional output derivative of rvec3 with regard to rvec2
  1204. * param dr3dt2 Optional output derivative of rvec3 with regard to tvec2
  1205. *
  1206. * The functions compute:
  1207. *
  1208. * \(\begin{array}{l} \texttt{rvec3} = \mathrm{rodrigues} ^{-1} \left ( \mathrm{rodrigues} ( \texttt{rvec2} ) \cdot \mathrm{rodrigues} ( \texttt{rvec1} ) \right ) \\ \texttt{tvec3} = \mathrm{rodrigues} ( \texttt{rvec2} ) \cdot \texttt{tvec1} + \texttt{tvec2} \end{array} ,\)
  1209. *
  1210. * where \(\mathrm{rodrigues}\) denotes a rotation vector to a rotation matrix transformation, and
  1211. * \(\mathrm{rodrigues}^{-1}\) denotes the inverse transformation. See #Rodrigues for details.
  1212. *
  1213. * Also, the functions can compute the derivatives of the output vectors with regards to the input
  1214. * vectors (see #matMulDeriv ). The functions are used inside #stereoCalibrate but can also be used in
  1215. * your own code where Levenberg-Marquardt or another gradient-based solver is used to optimize a
  1216. * function that contains a matrix multiplication.
  1217. */
  1218. public static void composeRT(Mat rvec1, Mat tvec1, Mat rvec2, Mat tvec2, Mat rvec3, Mat tvec3, Mat dr3dr1, Mat dr3dt1, Mat dr3dr2, Mat dr3dt2)
  1219. {
  1220. if (rvec1 != null) rvec1.ThrowIfDisposed();
  1221. if (tvec1 != null) tvec1.ThrowIfDisposed();
  1222. if (rvec2 != null) rvec2.ThrowIfDisposed();
  1223. if (tvec2 != null) tvec2.ThrowIfDisposed();
  1224. if (rvec3 != null) rvec3.ThrowIfDisposed();
  1225. if (tvec3 != null) tvec3.ThrowIfDisposed();
  1226. if (dr3dr1 != null) dr3dr1.ThrowIfDisposed();
  1227. if (dr3dt1 != null) dr3dt1.ThrowIfDisposed();
  1228. if (dr3dr2 != null) dr3dr2.ThrowIfDisposed();
  1229. if (dr3dt2 != null) dr3dt2.ThrowIfDisposed();
  1230. calib3d_Calib3d_composeRT_14(rvec1.nativeObj, tvec1.nativeObj, rvec2.nativeObj, tvec2.nativeObj, rvec3.nativeObj, tvec3.nativeObj, dr3dr1.nativeObj, dr3dt1.nativeObj, dr3dr2.nativeObj, dr3dt2.nativeObj);
  1231. }
  1232. /**
  1233. * Combines two rotation-and-shift transformations.
  1234. *
  1235. * param rvec1 First rotation vector.
  1236. * param tvec1 First translation vector.
  1237. * param rvec2 Second rotation vector.
  1238. * param tvec2 Second translation vector.
  1239. * param rvec3 Output rotation vector of the superposition.
  1240. * param tvec3 Output translation vector of the superposition.
  1241. * param dr3dr1 Optional output derivative of rvec3 with regard to rvec1
  1242. * param dr3dt1 Optional output derivative of rvec3 with regard to tvec1
  1243. * param dr3dr2 Optional output derivative of rvec3 with regard to rvec2
  1244. *
  1245. * The functions compute:
  1246. *
  1247. * \(\begin{array}{l} \texttt{rvec3} = \mathrm{rodrigues} ^{-1} \left ( \mathrm{rodrigues} ( \texttt{rvec2} ) \cdot \mathrm{rodrigues} ( \texttt{rvec1} ) \right ) \\ \texttt{tvec3} = \mathrm{rodrigues} ( \texttt{rvec2} ) \cdot \texttt{tvec1} + \texttt{tvec2} \end{array} ,\)
  1248. *
  1249. * where \(\mathrm{rodrigues}\) denotes a rotation vector to a rotation matrix transformation, and
  1250. * \(\mathrm{rodrigues}^{-1}\) denotes the inverse transformation. See #Rodrigues for details.
  1251. *
  1252. * Also, the functions can compute the derivatives of the output vectors with regards to the input
  1253. * vectors (see #matMulDeriv ). The functions are used inside #stereoCalibrate but can also be used in
  1254. * your own code where Levenberg-Marquardt or another gradient-based solver is used to optimize a
  1255. * function that contains a matrix multiplication.
  1256. */
  1257. public static void composeRT(Mat rvec1, Mat tvec1, Mat rvec2, Mat tvec2, Mat rvec3, Mat tvec3, Mat dr3dr1, Mat dr3dt1, Mat dr3dr2)
  1258. {
  1259. if (rvec1 != null) rvec1.ThrowIfDisposed();
  1260. if (tvec1 != null) tvec1.ThrowIfDisposed();
  1261. if (rvec2 != null) rvec2.ThrowIfDisposed();
  1262. if (tvec2 != null) tvec2.ThrowIfDisposed();
  1263. if (rvec3 != null) rvec3.ThrowIfDisposed();
  1264. if (tvec3 != null) tvec3.ThrowIfDisposed();
  1265. if (dr3dr1 != null) dr3dr1.ThrowIfDisposed();
  1266. if (dr3dt1 != null) dr3dt1.ThrowIfDisposed();
  1267. if (dr3dr2 != null) dr3dr2.ThrowIfDisposed();
  1268. calib3d_Calib3d_composeRT_15(rvec1.nativeObj, tvec1.nativeObj, rvec2.nativeObj, tvec2.nativeObj, rvec3.nativeObj, tvec3.nativeObj, dr3dr1.nativeObj, dr3dt1.nativeObj, dr3dr2.nativeObj);
  1269. }
  1270. /**
  1271. * Combines two rotation-and-shift transformations.
  1272. *
  1273. * param rvec1 First rotation vector.
  1274. * param tvec1 First translation vector.
  1275. * param rvec2 Second rotation vector.
  1276. * param tvec2 Second translation vector.
  1277. * param rvec3 Output rotation vector of the superposition.
  1278. * param tvec3 Output translation vector of the superposition.
  1279. * param dr3dr1 Optional output derivative of rvec3 with regard to rvec1
  1280. * param dr3dt1 Optional output derivative of rvec3 with regard to tvec1
  1281. *
  1282. * The functions compute:
  1283. *
  1284. * \(\begin{array}{l} \texttt{rvec3} = \mathrm{rodrigues} ^{-1} \left ( \mathrm{rodrigues} ( \texttt{rvec2} ) \cdot \mathrm{rodrigues} ( \texttt{rvec1} ) \right ) \\ \texttt{tvec3} = \mathrm{rodrigues} ( \texttt{rvec2} ) \cdot \texttt{tvec1} + \texttt{tvec2} \end{array} ,\)
  1285. *
  1286. * where \(\mathrm{rodrigues}\) denotes a rotation vector to a rotation matrix transformation, and
  1287. * \(\mathrm{rodrigues}^{-1}\) denotes the inverse transformation. See #Rodrigues for details.
  1288. *
  1289. * Also, the functions can compute the derivatives of the output vectors with regards to the input
  1290. * vectors (see #matMulDeriv ). The functions are used inside #stereoCalibrate but can also be used in
  1291. * your own code where Levenberg-Marquardt or another gradient-based solver is used to optimize a
  1292. * function that contains a matrix multiplication.
  1293. */
  1294. public static void composeRT(Mat rvec1, Mat tvec1, Mat rvec2, Mat tvec2, Mat rvec3, Mat tvec3, Mat dr3dr1, Mat dr3dt1)
  1295. {
  1296. if (rvec1 != null) rvec1.ThrowIfDisposed();
  1297. if (tvec1 != null) tvec1.ThrowIfDisposed();
  1298. if (rvec2 != null) rvec2.ThrowIfDisposed();
  1299. if (tvec2 != null) tvec2.ThrowIfDisposed();
  1300. if (rvec3 != null) rvec3.ThrowIfDisposed();
  1301. if (tvec3 != null) tvec3.ThrowIfDisposed();
  1302. if (dr3dr1 != null) dr3dr1.ThrowIfDisposed();
  1303. if (dr3dt1 != null) dr3dt1.ThrowIfDisposed();
  1304. calib3d_Calib3d_composeRT_16(rvec1.nativeObj, tvec1.nativeObj, rvec2.nativeObj, tvec2.nativeObj, rvec3.nativeObj, tvec3.nativeObj, dr3dr1.nativeObj, dr3dt1.nativeObj);
  1305. }
  1306. /**
  1307. * Combines two rotation-and-shift transformations.
  1308. *
  1309. * param rvec1 First rotation vector.
  1310. * param tvec1 First translation vector.
  1311. * param rvec2 Second rotation vector.
  1312. * param tvec2 Second translation vector.
  1313. * param rvec3 Output rotation vector of the superposition.
  1314. * param tvec3 Output translation vector of the superposition.
  1315. * param dr3dr1 Optional output derivative of rvec3 with regard to rvec1
  1316. *
  1317. * The functions compute:
  1318. *
  1319. * \(\begin{array}{l} \texttt{rvec3} = \mathrm{rodrigues} ^{-1} \left ( \mathrm{rodrigues} ( \texttt{rvec2} ) \cdot \mathrm{rodrigues} ( \texttt{rvec1} ) \right ) \\ \texttt{tvec3} = \mathrm{rodrigues} ( \texttt{rvec2} ) \cdot \texttt{tvec1} + \texttt{tvec2} \end{array} ,\)
  1320. *
  1321. * where \(\mathrm{rodrigues}\) denotes a rotation vector to a rotation matrix transformation, and
  1322. * \(\mathrm{rodrigues}^{-1}\) denotes the inverse transformation. See #Rodrigues for details.
  1323. *
  1324. * Also, the functions can compute the derivatives of the output vectors with regards to the input
  1325. * vectors (see #matMulDeriv ). The functions are used inside #stereoCalibrate but can also be used in
  1326. * your own code where Levenberg-Marquardt or another gradient-based solver is used to optimize a
  1327. * function that contains a matrix multiplication.
  1328. */
  1329. public static void composeRT(Mat rvec1, Mat tvec1, Mat rvec2, Mat tvec2, Mat rvec3, Mat tvec3, Mat dr3dr1)
  1330. {
  1331. if (rvec1 != null) rvec1.ThrowIfDisposed();
  1332. if (tvec1 != null) tvec1.ThrowIfDisposed();
  1333. if (rvec2 != null) rvec2.ThrowIfDisposed();
  1334. if (tvec2 != null) tvec2.ThrowIfDisposed();
  1335. if (rvec3 != null) rvec3.ThrowIfDisposed();
  1336. if (tvec3 != null) tvec3.ThrowIfDisposed();
  1337. if (dr3dr1 != null) dr3dr1.ThrowIfDisposed();
  1338. calib3d_Calib3d_composeRT_17(rvec1.nativeObj, tvec1.nativeObj, rvec2.nativeObj, tvec2.nativeObj, rvec3.nativeObj, tvec3.nativeObj, dr3dr1.nativeObj);
  1339. }
  1340. /**
  1341. * Combines two rotation-and-shift transformations.
  1342. *
  1343. * param rvec1 First rotation vector.
  1344. * param tvec1 First translation vector.
  1345. * param rvec2 Second rotation vector.
  1346. * param tvec2 Second translation vector.
  1347. * param rvec3 Output rotation vector of the superposition.
  1348. * param tvec3 Output translation vector of the superposition.
  1349. *
  1350. * The functions compute:
  1351. *
  1352. * \(\begin{array}{l} \texttt{rvec3} = \mathrm{rodrigues} ^{-1} \left ( \mathrm{rodrigues} ( \texttt{rvec2} ) \cdot \mathrm{rodrigues} ( \texttt{rvec1} ) \right ) \\ \texttt{tvec3} = \mathrm{rodrigues} ( \texttt{rvec2} ) \cdot \texttt{tvec1} + \texttt{tvec2} \end{array} ,\)
  1353. *
  1354. * where \(\mathrm{rodrigues}\) denotes a rotation vector to a rotation matrix transformation, and
  1355. * \(\mathrm{rodrigues}^{-1}\) denotes the inverse transformation. See #Rodrigues for details.
  1356. *
  1357. * Also, the functions can compute the derivatives of the output vectors with regards to the input
  1358. * vectors (see #matMulDeriv ). The functions are used inside #stereoCalibrate but can also be used in
  1359. * your own code where Levenberg-Marquardt or another gradient-based solver is used to optimize a
  1360. * function that contains a matrix multiplication.
  1361. */
  1362. public static void composeRT(Mat rvec1, Mat tvec1, Mat rvec2, Mat tvec2, Mat rvec3, Mat tvec3)
  1363. {
  1364. if (rvec1 != null) rvec1.ThrowIfDisposed();
  1365. if (tvec1 != null) tvec1.ThrowIfDisposed();
  1366. if (rvec2 != null) rvec2.ThrowIfDisposed();
  1367. if (tvec2 != null) tvec2.ThrowIfDisposed();
  1368. if (rvec3 != null) rvec3.ThrowIfDisposed();
  1369. if (tvec3 != null) tvec3.ThrowIfDisposed();
  1370. calib3d_Calib3d_composeRT_18(rvec1.nativeObj, tvec1.nativeObj, rvec2.nativeObj, tvec2.nativeObj, rvec3.nativeObj, tvec3.nativeObj);
  1371. }
  1372. //
  1373. // C++: void cv::projectPoints(vector_Point3f objectPoints, Mat rvec, Mat tvec, Mat cameraMatrix, vector_double distCoeffs, vector_Point2f& imagePoints, Mat& jacobian = Mat(), double aspectRatio = 0)
  1374. //
  1375. /**
  1376. * Projects 3D points to an image plane.
  1377. *
  1378. * param objectPoints Array of object points expressed wrt. the world coordinate frame. A 3xN/Nx3
  1379. * 1-channel or 1xN/Nx1 3-channel (or vector&lt;Point3f&gt; ), where N is the number of points in the view.
  1380. * param rvec The rotation vector (REF: Rodrigues) that, together with tvec, performs a change of
  1381. * basis from world to camera coordinate system, see REF: calibrateCamera for details.
  1382. * param tvec The translation vector, see parameter description above.
  1383. * param cameraMatrix Camera intrinsic matrix \(\cameramatrix{A}\) .
  1384. * param distCoeffs Input vector of distortion coefficients
  1385. * \(\distcoeffs\) . If the vector is empty, the zero distortion coefficients are assumed.
  1386. * param imagePoints Output array of image points, 1xN/Nx1 2-channel, or
  1387. * vector&lt;Point2f&gt; .
  1388. * param jacobian Optional output 2Nx(10+&lt;numDistCoeffs&gt;) jacobian matrix of derivatives of image
  1389. * points with respect to components of the rotation vector, translation vector, focal lengths,
  1390. * coordinates of the principal point and the distortion coefficients. In the old interface different
  1391. * components of the jacobian are returned via different output parameters.
  1392. * param aspectRatio Optional "fixed aspect ratio" parameter. If the parameter is not 0, the
  1393. * function assumes that the aspect ratio (\(f_x / f_y\)) is fixed and correspondingly adjusts the
  1394. * jacobian matrix.
  1395. *
  1396. * The function computes the 2D projections of 3D points to the image plane, given intrinsic and
  1397. * extrinsic camera parameters. Optionally, the function computes Jacobians -matrices of partial
  1398. * derivatives of image points coordinates (as functions of all the input parameters) with respect to
  1399. * the particular parameters, intrinsic and/or extrinsic. The Jacobians are used during the global
  1400. * optimization in REF: calibrateCamera, REF: solvePnP, and REF: stereoCalibrate. The function itself
  1401. * can also be used to compute a re-projection error, given the current intrinsic and extrinsic
  1402. * parameters.
  1403. *
  1404. * <b>Note:</b> By setting rvec = tvec = \([0, 0, 0]\), or by setting cameraMatrix to a 3x3 identity matrix,
  1405. * or by passing zero distortion coefficients, one can get various useful partial cases of the
  1406. * function. This means, one can compute the distorted coordinates for a sparse set of points or apply
  1407. * a perspective transformation (and also compute the derivatives) in the ideal zero-distortion setup.
  1408. */
  1409. public static void projectPoints(MatOfPoint3f objectPoints, Mat rvec, Mat tvec, Mat cameraMatrix, MatOfDouble distCoeffs, MatOfPoint2f imagePoints, Mat jacobian, double aspectRatio)
  1410. {
  1411. if (objectPoints != null) objectPoints.ThrowIfDisposed();
  1412. if (rvec != null) rvec.ThrowIfDisposed();
  1413. if (tvec != null) tvec.ThrowIfDisposed();
  1414. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  1415. if (distCoeffs != null) distCoeffs.ThrowIfDisposed();
  1416. if (imagePoints != null) imagePoints.ThrowIfDisposed();
  1417. if (jacobian != null) jacobian.ThrowIfDisposed();
  1418. Mat objectPoints_mat = objectPoints;
  1419. Mat distCoeffs_mat = distCoeffs;
  1420. Mat imagePoints_mat = imagePoints;
  1421. calib3d_Calib3d_projectPoints_10(objectPoints_mat.nativeObj, rvec.nativeObj, tvec.nativeObj, cameraMatrix.nativeObj, distCoeffs_mat.nativeObj, imagePoints_mat.nativeObj, jacobian.nativeObj, aspectRatio);
  1422. }
  1423. /**
  1424. * Projects 3D points to an image plane.
  1425. *
  1426. * param objectPoints Array of object points expressed wrt. the world coordinate frame. A 3xN/Nx3
  1427. * 1-channel or 1xN/Nx1 3-channel (or vector&lt;Point3f&gt; ), where N is the number of points in the view.
  1428. * param rvec The rotation vector (REF: Rodrigues) that, together with tvec, performs a change of
  1429. * basis from world to camera coordinate system, see REF: calibrateCamera for details.
  1430. * param tvec The translation vector, see parameter description above.
  1431. * param cameraMatrix Camera intrinsic matrix \(\cameramatrix{A}\) .
  1432. * param distCoeffs Input vector of distortion coefficients
  1433. * \(\distcoeffs\) . If the vector is empty, the zero distortion coefficients are assumed.
  1434. * param imagePoints Output array of image points, 1xN/Nx1 2-channel, or
  1435. * vector&lt;Point2f&gt; .
  1436. * param jacobian Optional output 2Nx(10+&lt;numDistCoeffs&gt;) jacobian matrix of derivatives of image
  1437. * points with respect to components of the rotation vector, translation vector, focal lengths,
  1438. * coordinates of the principal point and the distortion coefficients. In the old interface different
  1439. * components of the jacobian are returned via different output parameters.
  1440. * function assumes that the aspect ratio (\(f_x / f_y\)) is fixed and correspondingly adjusts the
  1441. * jacobian matrix.
  1442. *
  1443. * The function computes the 2D projections of 3D points to the image plane, given intrinsic and
  1444. * extrinsic camera parameters. Optionally, the function computes Jacobians -matrices of partial
  1445. * derivatives of image points coordinates (as functions of all the input parameters) with respect to
  1446. * the particular parameters, intrinsic and/or extrinsic. The Jacobians are used during the global
  1447. * optimization in REF: calibrateCamera, REF: solvePnP, and REF: stereoCalibrate. The function itself
  1448. * can also be used to compute a re-projection error, given the current intrinsic and extrinsic
  1449. * parameters.
  1450. *
  1451. * <b>Note:</b> By setting rvec = tvec = \([0, 0, 0]\), or by setting cameraMatrix to a 3x3 identity matrix,
  1452. * or by passing zero distortion coefficients, one can get various useful partial cases of the
  1453. * function. This means, one can compute the distorted coordinates for a sparse set of points or apply
  1454. * a perspective transformation (and also compute the derivatives) in the ideal zero-distortion setup.
  1455. */
  1456. public static void projectPoints(MatOfPoint3f objectPoints, Mat rvec, Mat tvec, Mat cameraMatrix, MatOfDouble distCoeffs, MatOfPoint2f imagePoints, Mat jacobian)
  1457. {
  1458. if (objectPoints != null) objectPoints.ThrowIfDisposed();
  1459. if (rvec != null) rvec.ThrowIfDisposed();
  1460. if (tvec != null) tvec.ThrowIfDisposed();
  1461. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  1462. if (distCoeffs != null) distCoeffs.ThrowIfDisposed();
  1463. if (imagePoints != null) imagePoints.ThrowIfDisposed();
  1464. if (jacobian != null) jacobian.ThrowIfDisposed();
  1465. Mat objectPoints_mat = objectPoints;
  1466. Mat distCoeffs_mat = distCoeffs;
  1467. Mat imagePoints_mat = imagePoints;
  1468. calib3d_Calib3d_projectPoints_11(objectPoints_mat.nativeObj, rvec.nativeObj, tvec.nativeObj, cameraMatrix.nativeObj, distCoeffs_mat.nativeObj, imagePoints_mat.nativeObj, jacobian.nativeObj);
  1469. }
  1470. /**
  1471. * Projects 3D points to an image plane.
  1472. *
  1473. * param objectPoints Array of object points expressed wrt. the world coordinate frame. A 3xN/Nx3
  1474. * 1-channel or 1xN/Nx1 3-channel (or vector&lt;Point3f&gt; ), where N is the number of points in the view.
  1475. * param rvec The rotation vector (REF: Rodrigues) that, together with tvec, performs a change of
  1476. * basis from world to camera coordinate system, see REF: calibrateCamera for details.
  1477. * param tvec The translation vector, see parameter description above.
  1478. * param cameraMatrix Camera intrinsic matrix \(\cameramatrix{A}\) .
  1479. * param distCoeffs Input vector of distortion coefficients
  1480. * \(\distcoeffs\) . If the vector is empty, the zero distortion coefficients are assumed.
  1481. * param imagePoints Output array of image points, 1xN/Nx1 2-channel, or
  1482. * vector&lt;Point2f&gt; .
  1483. * points with respect to components of the rotation vector, translation vector, focal lengths,
  1484. * coordinates of the principal point and the distortion coefficients. In the old interface different
  1485. * components of the jacobian are returned via different output parameters.
  1486. * function assumes that the aspect ratio (\(f_x / f_y\)) is fixed and correspondingly adjusts the
  1487. * jacobian matrix.
  1488. *
  1489. * The function computes the 2D projections of 3D points to the image plane, given intrinsic and
  1490. * extrinsic camera parameters. Optionally, the function computes Jacobians -matrices of partial
  1491. * derivatives of image points coordinates (as functions of all the input parameters) with respect to
  1492. * the particular parameters, intrinsic and/or extrinsic. The Jacobians are used during the global
  1493. * optimization in REF: calibrateCamera, REF: solvePnP, and REF: stereoCalibrate. The function itself
  1494. * can also be used to compute a re-projection error, given the current intrinsic and extrinsic
  1495. * parameters.
  1496. *
  1497. * <b>Note:</b> By setting rvec = tvec = \([0, 0, 0]\), or by setting cameraMatrix to a 3x3 identity matrix,
  1498. * or by passing zero distortion coefficients, one can get various useful partial cases of the
  1499. * function. This means, one can compute the distorted coordinates for a sparse set of points or apply
  1500. * a perspective transformation (and also compute the derivatives) in the ideal zero-distortion setup.
  1501. */
  1502. public static void projectPoints(MatOfPoint3f objectPoints, Mat rvec, Mat tvec, Mat cameraMatrix, MatOfDouble distCoeffs, MatOfPoint2f imagePoints)
  1503. {
  1504. if (objectPoints != null) objectPoints.ThrowIfDisposed();
  1505. if (rvec != null) rvec.ThrowIfDisposed();
  1506. if (tvec != null) tvec.ThrowIfDisposed();
  1507. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  1508. if (distCoeffs != null) distCoeffs.ThrowIfDisposed();
  1509. if (imagePoints != null) imagePoints.ThrowIfDisposed();
  1510. Mat objectPoints_mat = objectPoints;
  1511. Mat distCoeffs_mat = distCoeffs;
  1512. Mat imagePoints_mat = imagePoints;
  1513. calib3d_Calib3d_projectPoints_12(objectPoints_mat.nativeObj, rvec.nativeObj, tvec.nativeObj, cameraMatrix.nativeObj, distCoeffs_mat.nativeObj, imagePoints_mat.nativeObj);
  1514. }
  1515. //
  1516. // C++: bool cv::solvePnP(vector_Point3f objectPoints, vector_Point2f imagePoints, Mat cameraMatrix, vector_double distCoeffs, Mat& rvec, Mat& tvec, bool useExtrinsicGuess = false, int flags = SOLVEPNP_ITERATIVE)
  1517. //
  1518. /**
  1519. * Finds an object pose from 3D-2D point correspondences.
  1520. *
  1521. * SEE: REF: calib3d_solvePnP
  1522. *
  1523. * This function returns the rotation and the translation vectors that transform a 3D point expressed in the object
  1524. * coordinate frame to the camera coordinate frame, using different methods:
  1525. * <ul>
  1526. * <li>
  1527. * P3P methods (REF: SOLVEPNP_P3P, REF: SOLVEPNP_AP3P): need 4 input points to return a unique solution.
  1528. * </li>
  1529. * <li>
  1530. * REF: SOLVEPNP_IPPE Input points must be &gt;= 4 and object points must be coplanar.
  1531. * </li>
  1532. * <li>
  1533. * REF: SOLVEPNP_IPPE_SQUARE Special case suitable for marker pose estimation.
  1534. * Number of input points must be 4. Object points must be defined in the following order:
  1535. * <ul>
  1536. * <li>
  1537. * point 0: [-squareLength / 2, squareLength / 2, 0]
  1538. * </li>
  1539. * <li>
  1540. * point 1: [ squareLength / 2, squareLength / 2, 0]
  1541. * </li>
  1542. * <li>
  1543. * point 2: [ squareLength / 2, -squareLength / 2, 0]
  1544. * </li>
  1545. * <li>
  1546. * point 3: [-squareLength / 2, -squareLength / 2, 0]
  1547. * </li>
  1548. * </ul>
  1549. * <li>
  1550. * for all the other flags, number of input points must be &gt;= 4 and object points can be in any configuration.
  1551. * </li>
  1552. * </ul>
  1553. *
  1554. * param objectPoints Array of object points in the object coordinate space, Nx3 1-channel or
  1555. * 1xN/Nx1 3-channel, where N is the number of points. vector&lt;Point3d&gt; can be also passed here.
  1556. * param imagePoints Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
  1557. * where N is the number of points. vector&lt;Point2d&gt; can be also passed here.
  1558. * param cameraMatrix Input camera intrinsic matrix \(\cameramatrix{A}\) .
  1559. * param distCoeffs Input vector of distortion coefficients
  1560. * \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
  1561. * assumed.
  1562. * param rvec Output rotation vector (see REF: Rodrigues ) that, together with tvec, brings points from
  1563. * the model coordinate system to the camera coordinate system.
  1564. * param tvec Output translation vector.
  1565. * param useExtrinsicGuess Parameter used for #SOLVEPNP_ITERATIVE. If true (1), the function uses
  1566. * the provided rvec and tvec values as initial approximations of the rotation and translation
  1567. * vectors, respectively, and further optimizes them.
  1568. * param flags Method for solving a PnP problem: see REF: calib3d_solvePnP_flags
  1569. *
  1570. * More information about Perspective-n-Points is described in REF: calib3d_solvePnP
  1571. *
  1572. * <b>Note:</b>
  1573. * <ul>
  1574. * <li>
  1575. * An example of how to use solvePnP for planar augmented reality can be found at
  1576. * opencv_source_code/samples/python/plane_ar.py
  1577. * </li>
  1578. * <li>
  1579. * If you are using Python:
  1580. * <ul>
  1581. * <li>
  1582. * Numpy array slices won't work as input because solvePnP requires contiguous
  1583. * arrays (enforced by the assertion using cv::Mat::checkVector() around line 55 of
  1584. * modules/calib3d/src/solvepnp.cpp version 2.4.9)
  1585. * </li>
  1586. * <li>
  1587. * The P3P algorithm requires image points to be in an array of shape (N,1,2) due
  1588. * to its calling of #undistortPoints (around line 75 of modules/calib3d/src/solvepnp.cpp version 2.4.9)
  1589. * which requires 2-channel information.
  1590. * </li>
  1591. * <li>
  1592. * Thus, given some data D = np.array(...) where D.shape = (N,M), in order to use a subset of
  1593. * it as, e.g., imagePoints, one must effectively copy it into a new array: imagePoints =
  1594. * np.ascontiguousarray(D[:,:2]).reshape((N,1,2))
  1595. * </li>
  1596. * </ul>
  1597. * <li>
  1598. * The methods REF: SOLVEPNP_DLS and REF: SOLVEPNP_UPNP cannot be used as the current implementations are
  1599. * unstable and sometimes give completely wrong results. If you pass one of these two
  1600. * flags, REF: SOLVEPNP_EPNP method will be used instead.
  1601. * </li>
  1602. * <li>
  1603. * The minimum number of points is 4 in the general case. In the case of REF: SOLVEPNP_P3P and REF: SOLVEPNP_AP3P
  1604. * methods, it is required to use exactly 4 points (the first 3 points are used to estimate all the solutions
  1605. * of the P3P problem, the last one is used to retain the best solution that minimizes the reprojection error).
  1606. * </li>
  1607. * <li>
  1608. * With REF: SOLVEPNP_ITERATIVE method and {code useExtrinsicGuess=true}, the minimum number of points is 3 (3 points
  1609. * are sufficient to compute a pose but there are up to 4 solutions). The initial solution should be close to the
  1610. * global solution to converge.
  1611. * </li>
  1612. * <li>
  1613. * With REF: SOLVEPNP_IPPE input points must be &gt;= 4 and object points must be coplanar.
  1614. * </li>
  1615. * <li>
  1616. * With REF: SOLVEPNP_IPPE_SQUARE this is a special case suitable for marker pose estimation.
  1617. * Number of input points must be 4. Object points must be defined in the following order:
  1618. * <ul>
  1619. * <li>
  1620. * point 0: [-squareLength / 2, squareLength / 2, 0]
  1621. * </li>
  1622. * <li>
  1623. * point 1: [ squareLength / 2, squareLength / 2, 0]
  1624. * </li>
  1625. * <li>
  1626. * point 2: [ squareLength / 2, -squareLength / 2, 0]
  1627. * </li>
  1628. * <li>
  1629. * point 3: [-squareLength / 2, -squareLength / 2, 0]
  1630. * </li>
  1631. * </ul>
  1632. * <ul>
  1633. * <li>
  1634. * With REF: SOLVEPNP_SQPNP input points must be &gt;= 3
  1635. * </li>
  1636. * </ul>
  1637. * </li>
  1638. * </ul>
  1639. * return automatically generated
  1640. */
  1641. public static bool solvePnP(MatOfPoint3f objectPoints, MatOfPoint2f imagePoints, Mat cameraMatrix, MatOfDouble distCoeffs, Mat rvec, Mat tvec, bool useExtrinsicGuess, int flags)
  1642. {
  1643. if (objectPoints != null) objectPoints.ThrowIfDisposed();
  1644. if (imagePoints != null) imagePoints.ThrowIfDisposed();
  1645. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  1646. if (distCoeffs != null) distCoeffs.ThrowIfDisposed();
  1647. if (rvec != null) rvec.ThrowIfDisposed();
  1648. if (tvec != null) tvec.ThrowIfDisposed();
  1649. Mat objectPoints_mat = objectPoints;
  1650. Mat imagePoints_mat = imagePoints;
  1651. Mat distCoeffs_mat = distCoeffs;
  1652. return calib3d_Calib3d_solvePnP_10(objectPoints_mat.nativeObj, imagePoints_mat.nativeObj, cameraMatrix.nativeObj, distCoeffs_mat.nativeObj, rvec.nativeObj, tvec.nativeObj, useExtrinsicGuess, flags);
  1653. }
  1654. /**
  1655. * Finds an object pose from 3D-2D point correspondences.
  1656. *
  1657. * SEE: REF: calib3d_solvePnP
  1658. *
  1659. * This function returns the rotation and the translation vectors that transform a 3D point expressed in the object
  1660. * coordinate frame to the camera coordinate frame, using different methods:
  1661. * <ul>
  1662. * <li>
  1663. * P3P methods (REF: SOLVEPNP_P3P, REF: SOLVEPNP_AP3P): need 4 input points to return a unique solution.
  1664. * </li>
  1665. * <li>
  1666. * REF: SOLVEPNP_IPPE Input points must be &gt;= 4 and object points must be coplanar.
  1667. * </li>
  1668. * <li>
  1669. * REF: SOLVEPNP_IPPE_SQUARE Special case suitable for marker pose estimation.
  1670. * Number of input points must be 4. Object points must be defined in the following order:
  1671. * <ul>
  1672. * <li>
  1673. * point 0: [-squareLength / 2, squareLength / 2, 0]
  1674. * </li>
  1675. * <li>
  1676. * point 1: [ squareLength / 2, squareLength / 2, 0]
  1677. * </li>
  1678. * <li>
  1679. * point 2: [ squareLength / 2, -squareLength / 2, 0]
  1680. * </li>
  1681. * <li>
  1682. * point 3: [-squareLength / 2, -squareLength / 2, 0]
  1683. * </li>
  1684. * </ul>
  1685. * <li>
  1686. * for all the other flags, number of input points must be &gt;= 4 and object points can be in any configuration.
  1687. * </li>
  1688. * </ul>
  1689. *
  1690. * param objectPoints Array of object points in the object coordinate space, Nx3 1-channel or
  1691. * 1xN/Nx1 3-channel, where N is the number of points. vector&lt;Point3d&gt; can be also passed here.
  1692. * param imagePoints Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
  1693. * where N is the number of points. vector&lt;Point2d&gt; can be also passed here.
  1694. * param cameraMatrix Input camera intrinsic matrix \(\cameramatrix{A}\) .
  1695. * param distCoeffs Input vector of distortion coefficients
  1696. * \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
  1697. * assumed.
  1698. * param rvec Output rotation vector (see REF: Rodrigues ) that, together with tvec, brings points from
  1699. * the model coordinate system to the camera coordinate system.
  1700. * param tvec Output translation vector.
  1701. * param useExtrinsicGuess Parameter used for #SOLVEPNP_ITERATIVE. If true (1), the function uses
  1702. * the provided rvec and tvec values as initial approximations of the rotation and translation
  1703. * vectors, respectively, and further optimizes them.
  1704. *
  1705. * More information about Perspective-n-Points is described in REF: calib3d_solvePnP
  1706. *
  1707. * <b>Note:</b>
  1708. * <ul>
  1709. * <li>
  1710. * An example of how to use solvePnP for planar augmented reality can be found at
  1711. * opencv_source_code/samples/python/plane_ar.py
  1712. * </li>
  1713. * <li>
  1714. * If you are using Python:
  1715. * <ul>
  1716. * <li>
  1717. * Numpy array slices won't work as input because solvePnP requires contiguous
  1718. * arrays (enforced by the assertion using cv::Mat::checkVector() around line 55 of
  1719. * modules/calib3d/src/solvepnp.cpp version 2.4.9)
  1720. * </li>
  1721. * <li>
  1722. * The P3P algorithm requires image points to be in an array of shape (N,1,2) due
  1723. * to its calling of #undistortPoints (around line 75 of modules/calib3d/src/solvepnp.cpp version 2.4.9)
  1724. * which requires 2-channel information.
  1725. * </li>
  1726. * <li>
  1727. * Thus, given some data D = np.array(...) where D.shape = (N,M), in order to use a subset of
  1728. * it as, e.g., imagePoints, one must effectively copy it into a new array: imagePoints =
  1729. * np.ascontiguousarray(D[:,:2]).reshape((N,1,2))
  1730. * </li>
  1731. * </ul>
  1732. * <li>
  1733. * The methods REF: SOLVEPNP_DLS and REF: SOLVEPNP_UPNP cannot be used as the current implementations are
  1734. * unstable and sometimes give completely wrong results. If you pass one of these two
  1735. * flags, REF: SOLVEPNP_EPNP method will be used instead.
  1736. * </li>
  1737. * <li>
  1738. * The minimum number of points is 4 in the general case. In the case of REF: SOLVEPNP_P3P and REF: SOLVEPNP_AP3P
  1739. * methods, it is required to use exactly 4 points (the first 3 points are used to estimate all the solutions
  1740. * of the P3P problem, the last one is used to retain the best solution that minimizes the reprojection error).
  1741. * </li>
  1742. * <li>
  1743. * With REF: SOLVEPNP_ITERATIVE method and {code useExtrinsicGuess=true}, the minimum number of points is 3 (3 points
  1744. * are sufficient to compute a pose but there are up to 4 solutions). The initial solution should be close to the
  1745. * global solution to converge.
  1746. * </li>
  1747. * <li>
  1748. * With REF: SOLVEPNP_IPPE input points must be &gt;= 4 and object points must be coplanar.
  1749. * </li>
  1750. * <li>
  1751. * With REF: SOLVEPNP_IPPE_SQUARE this is a special case suitable for marker pose estimation.
  1752. * Number of input points must be 4. Object points must be defined in the following order:
  1753. * <ul>
  1754. * <li>
  1755. * point 0: [-squareLength / 2, squareLength / 2, 0]
  1756. * </li>
  1757. * <li>
  1758. * point 1: [ squareLength / 2, squareLength / 2, 0]
  1759. * </li>
  1760. * <li>
  1761. * point 2: [ squareLength / 2, -squareLength / 2, 0]
  1762. * </li>
  1763. * <li>
  1764. * point 3: [-squareLength / 2, -squareLength / 2, 0]
  1765. * </li>
  1766. * </ul>
  1767. * <ul>
  1768. * <li>
  1769. * With REF: SOLVEPNP_SQPNP input points must be &gt;= 3
  1770. * </li>
  1771. * </ul>
  1772. * </li>
  1773. * </ul>
  1774. * return automatically generated
  1775. */
  1776. public static bool solvePnP(MatOfPoint3f objectPoints, MatOfPoint2f imagePoints, Mat cameraMatrix, MatOfDouble distCoeffs, Mat rvec, Mat tvec, bool useExtrinsicGuess)
  1777. {
  1778. if (objectPoints != null) objectPoints.ThrowIfDisposed();
  1779. if (imagePoints != null) imagePoints.ThrowIfDisposed();
  1780. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  1781. if (distCoeffs != null) distCoeffs.ThrowIfDisposed();
  1782. if (rvec != null) rvec.ThrowIfDisposed();
  1783. if (tvec != null) tvec.ThrowIfDisposed();
  1784. Mat objectPoints_mat = objectPoints;
  1785. Mat imagePoints_mat = imagePoints;
  1786. Mat distCoeffs_mat = distCoeffs;
  1787. return calib3d_Calib3d_solvePnP_11(objectPoints_mat.nativeObj, imagePoints_mat.nativeObj, cameraMatrix.nativeObj, distCoeffs_mat.nativeObj, rvec.nativeObj, tvec.nativeObj, useExtrinsicGuess);
  1788. }
  1789. /**
  1790. * Finds an object pose from 3D-2D point correspondences.
  1791. *
  1792. * SEE: REF: calib3d_solvePnP
  1793. *
  1794. * This function returns the rotation and the translation vectors that transform a 3D point expressed in the object
  1795. * coordinate frame to the camera coordinate frame, using different methods:
  1796. * <ul>
  1797. * <li>
  1798. * P3P methods (REF: SOLVEPNP_P3P, REF: SOLVEPNP_AP3P): need 4 input points to return a unique solution.
  1799. * </li>
  1800. * <li>
  1801. * REF: SOLVEPNP_IPPE Input points must be &gt;= 4 and object points must be coplanar.
  1802. * </li>
  1803. * <li>
  1804. * REF: SOLVEPNP_IPPE_SQUARE Special case suitable for marker pose estimation.
  1805. * Number of input points must be 4. Object points must be defined in the following order:
  1806. * <ul>
  1807. * <li>
  1808. * point 0: [-squareLength / 2, squareLength / 2, 0]
  1809. * </li>
  1810. * <li>
  1811. * point 1: [ squareLength / 2, squareLength / 2, 0]
  1812. * </li>
  1813. * <li>
  1814. * point 2: [ squareLength / 2, -squareLength / 2, 0]
  1815. * </li>
  1816. * <li>
  1817. * point 3: [-squareLength / 2, -squareLength / 2, 0]
  1818. * </li>
  1819. * </ul>
  1820. * <li>
  1821. * for all the other flags, number of input points must be &gt;= 4 and object points can be in any configuration.
  1822. * </li>
  1823. * </ul>
  1824. *
  1825. * param objectPoints Array of object points in the object coordinate space, Nx3 1-channel or
  1826. * 1xN/Nx1 3-channel, where N is the number of points. vector&lt;Point3d&gt; can be also passed here.
  1827. * param imagePoints Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
  1828. * where N is the number of points. vector&lt;Point2d&gt; can be also passed here.
  1829. * param cameraMatrix Input camera intrinsic matrix \(\cameramatrix{A}\) .
  1830. * param distCoeffs Input vector of distortion coefficients
  1831. * \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
  1832. * assumed.
  1833. * param rvec Output rotation vector (see REF: Rodrigues ) that, together with tvec, brings points from
  1834. * the model coordinate system to the camera coordinate system.
  1835. * param tvec Output translation vector.
  1836. * the provided rvec and tvec values as initial approximations of the rotation and translation
  1837. * vectors, respectively, and further optimizes them.
  1838. *
  1839. * More information about Perspective-n-Points is described in REF: calib3d_solvePnP
  1840. *
  1841. * <b>Note:</b>
  1842. * <ul>
  1843. * <li>
  1844. * An example of how to use solvePnP for planar augmented reality can be found at
  1845. * opencv_source_code/samples/python/plane_ar.py
  1846. * </li>
  1847. * <li>
  1848. * If you are using Python:
  1849. * <ul>
  1850. * <li>
  1851. * Numpy array slices won't work as input because solvePnP requires contiguous
  1852. * arrays (enforced by the assertion using cv::Mat::checkVector() around line 55 of
  1853. * modules/calib3d/src/solvepnp.cpp version 2.4.9)
  1854. * </li>
  1855. * <li>
  1856. * The P3P algorithm requires image points to be in an array of shape (N,1,2) due
  1857. * to its calling of #undistortPoints (around line 75 of modules/calib3d/src/solvepnp.cpp version 2.4.9)
  1858. * which requires 2-channel information.
  1859. * </li>
  1860. * <li>
  1861. * Thus, given some data D = np.array(...) where D.shape = (N,M), in order to use a subset of
  1862. * it as, e.g., imagePoints, one must effectively copy it into a new array: imagePoints =
  1863. * np.ascontiguousarray(D[:,:2]).reshape((N,1,2))
  1864. * </li>
  1865. * </ul>
  1866. * <li>
  1867. * The methods REF: SOLVEPNP_DLS and REF: SOLVEPNP_UPNP cannot be used as the current implementations are
  1868. * unstable and sometimes give completely wrong results. If you pass one of these two
  1869. * flags, REF: SOLVEPNP_EPNP method will be used instead.
  1870. * </li>
  1871. * <li>
  1872. * The minimum number of points is 4 in the general case. In the case of REF: SOLVEPNP_P3P and REF: SOLVEPNP_AP3P
  1873. * methods, it is required to use exactly 4 points (the first 3 points are used to estimate all the solutions
  1874. * of the P3P problem, the last one is used to retain the best solution that minimizes the reprojection error).
  1875. * </li>
  1876. * <li>
  1877. * With REF: SOLVEPNP_ITERATIVE method and {code useExtrinsicGuess=true}, the minimum number of points is 3 (3 points
  1878. * are sufficient to compute a pose but there are up to 4 solutions). The initial solution should be close to the
  1879. * global solution to converge.
  1880. * </li>
  1881. * <li>
  1882. * With REF: SOLVEPNP_IPPE input points must be &gt;= 4 and object points must be coplanar.
  1883. * </li>
  1884. * <li>
  1885. * With REF: SOLVEPNP_IPPE_SQUARE this is a special case suitable for marker pose estimation.
  1886. * Number of input points must be 4. Object points must be defined in the following order:
  1887. * <ul>
  1888. * <li>
  1889. * point 0: [-squareLength / 2, squareLength / 2, 0]
  1890. * </li>
  1891. * <li>
  1892. * point 1: [ squareLength / 2, squareLength / 2, 0]
  1893. * </li>
  1894. * <li>
  1895. * point 2: [ squareLength / 2, -squareLength / 2, 0]
  1896. * </li>
  1897. * <li>
  1898. * point 3: [-squareLength / 2, -squareLength / 2, 0]
  1899. * </li>
  1900. * </ul>
  1901. * <ul>
  1902. * <li>
  1903. * With REF: SOLVEPNP_SQPNP input points must be &gt;= 3
  1904. * </li>
  1905. * </ul>
  1906. * </li>
  1907. * </ul>
  1908. * return automatically generated
  1909. */
  1910. public static bool solvePnP(MatOfPoint3f objectPoints, MatOfPoint2f imagePoints, Mat cameraMatrix, MatOfDouble distCoeffs, Mat rvec, Mat tvec)
  1911. {
  1912. if (objectPoints != null) objectPoints.ThrowIfDisposed();
  1913. if (imagePoints != null) imagePoints.ThrowIfDisposed();
  1914. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  1915. if (distCoeffs != null) distCoeffs.ThrowIfDisposed();
  1916. if (rvec != null) rvec.ThrowIfDisposed();
  1917. if (tvec != null) tvec.ThrowIfDisposed();
  1918. Mat objectPoints_mat = objectPoints;
  1919. Mat imagePoints_mat = imagePoints;
  1920. Mat distCoeffs_mat = distCoeffs;
  1921. return calib3d_Calib3d_solvePnP_12(objectPoints_mat.nativeObj, imagePoints_mat.nativeObj, cameraMatrix.nativeObj, distCoeffs_mat.nativeObj, rvec.nativeObj, tvec.nativeObj);
  1922. }
  1923. //
  1924. // C++: bool cv::solvePnPRansac(vector_Point3f objectPoints, vector_Point2f imagePoints, Mat cameraMatrix, vector_double distCoeffs, Mat& rvec, Mat& tvec, bool useExtrinsicGuess = false, int iterationsCount = 100, float reprojectionError = 8.0, double confidence = 0.99, Mat& inliers = Mat(), int flags = SOLVEPNP_ITERATIVE)
  1925. //
  1926. /**
  1927. * Finds an object pose from 3D-2D point correspondences using the RANSAC scheme.
  1928. *
  1929. * SEE: REF: calib3d_solvePnP
  1930. *
  1931. * param objectPoints Array of object points in the object coordinate space, Nx3 1-channel or
  1932. * 1xN/Nx1 3-channel, where N is the number of points. vector&lt;Point3d&gt; can be also passed here.
  1933. * param imagePoints Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
  1934. * where N is the number of points. vector&lt;Point2d&gt; can be also passed here.
  1935. * param cameraMatrix Input camera intrinsic matrix \(\cameramatrix{A}\) .
  1936. * param distCoeffs Input vector of distortion coefficients
  1937. * \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
  1938. * assumed.
  1939. * param rvec Output rotation vector (see REF: Rodrigues ) that, together with tvec, brings points from
  1940. * the model coordinate system to the camera coordinate system.
  1941. * param tvec Output translation vector.
  1942. * param useExtrinsicGuess Parameter used for REF: SOLVEPNP_ITERATIVE. If true (1), the function uses
  1943. * the provided rvec and tvec values as initial approximations of the rotation and translation
  1944. * vectors, respectively, and further optimizes them.
  1945. * param iterationsCount Number of iterations.
  1946. * param reprojectionError Inlier threshold value used by the RANSAC procedure. The parameter value
  1947. * is the maximum allowed distance between the observed and computed point projections to consider it
  1948. * an inlier.
  1949. * param confidence The probability that the algorithm produces a useful result.
  1950. * param inliers Output vector that contains indices of inliers in objectPoints and imagePoints .
  1951. * param flags Method for solving a PnP problem (see REF: solvePnP ).
  1952. *
  1953. * The function estimates an object pose given a set of object points, their corresponding image
  1954. * projections, as well as the camera intrinsic matrix and the distortion coefficients. This function finds such
  1955. * a pose that minimizes reprojection error, that is, the sum of squared distances between the observed
  1956. * projections imagePoints and the projected (using REF: projectPoints ) objectPoints. The use of RANSAC
  1957. * makes the function resistant to outliers.
  1958. *
  1959. * <b>Note:</b>
  1960. * <ul>
  1961. * <li>
  1962. * An example of how to use solvePNPRansac for object detection can be found at
  1963. * opencv_source_code/samples/cpp/tutorial_code/calib3d/real_time_pose_estimation/
  1964. * </li>
  1965. * <li>
  1966. * The default method used to estimate the camera pose for the Minimal Sample Sets step
  1967. * is #SOLVEPNP_EPNP. Exceptions are:
  1968. * <ul>
  1969. * <li>
  1970. * if you choose #SOLVEPNP_P3P or #SOLVEPNP_AP3P, these methods will be used.
  1971. * </li>
  1972. * <li>
  1973. * if the number of input points is equal to 4, #SOLVEPNP_P3P is used.
  1974. * </li>
  1975. * </ul>
  1976. * <li>
  1977. * The method used to estimate the camera pose using all the inliers is defined by the
  1978. * flags parameters unless it is equal to #SOLVEPNP_P3P or #SOLVEPNP_AP3P. In this case,
  1979. * the method #SOLVEPNP_EPNP will be used instead.
  1980. * </li>
  1981. * </ul>
  1982. * return automatically generated
  1983. */
  1984. public static bool solvePnPRansac(MatOfPoint3f objectPoints, MatOfPoint2f imagePoints, Mat cameraMatrix, MatOfDouble distCoeffs, Mat rvec, Mat tvec, bool useExtrinsicGuess, int iterationsCount, float reprojectionError, double confidence, Mat inliers, int flags)
  1985. {
  1986. if (objectPoints != null) objectPoints.ThrowIfDisposed();
  1987. if (imagePoints != null) imagePoints.ThrowIfDisposed();
  1988. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  1989. if (distCoeffs != null) distCoeffs.ThrowIfDisposed();
  1990. if (rvec != null) rvec.ThrowIfDisposed();
  1991. if (tvec != null) tvec.ThrowIfDisposed();
  1992. if (inliers != null) inliers.ThrowIfDisposed();
  1993. Mat objectPoints_mat = objectPoints;
  1994. Mat imagePoints_mat = imagePoints;
  1995. Mat distCoeffs_mat = distCoeffs;
  1996. return calib3d_Calib3d_solvePnPRansac_10(objectPoints_mat.nativeObj, imagePoints_mat.nativeObj, cameraMatrix.nativeObj, distCoeffs_mat.nativeObj, rvec.nativeObj, tvec.nativeObj, useExtrinsicGuess, iterationsCount, reprojectionError, confidence, inliers.nativeObj, flags);
  1997. }
  1998. /**
  1999. * Finds an object pose from 3D-2D point correspondences using the RANSAC scheme.
  2000. *
  2001. * SEE: REF: calib3d_solvePnP
  2002. *
  2003. * param objectPoints Array of object points in the object coordinate space, Nx3 1-channel or
  2004. * 1xN/Nx1 3-channel, where N is the number of points. vector&lt;Point3d&gt; can be also passed here.
  2005. * param imagePoints Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
  2006. * where N is the number of points. vector&lt;Point2d&gt; can be also passed here.
  2007. * param cameraMatrix Input camera intrinsic matrix \(\cameramatrix{A}\) .
  2008. * param distCoeffs Input vector of distortion coefficients
  2009. * \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
  2010. * assumed.
  2011. * param rvec Output rotation vector (see REF: Rodrigues ) that, together with tvec, brings points from
  2012. * the model coordinate system to the camera coordinate system.
  2013. * param tvec Output translation vector.
  2014. * param useExtrinsicGuess Parameter used for REF: SOLVEPNP_ITERATIVE. If true (1), the function uses
  2015. * the provided rvec and tvec values as initial approximations of the rotation and translation
  2016. * vectors, respectively, and further optimizes them.
  2017. * param iterationsCount Number of iterations.
  2018. * param reprojectionError Inlier threshold value used by the RANSAC procedure. The parameter value
  2019. * is the maximum allowed distance between the observed and computed point projections to consider it
  2020. * an inlier.
  2021. * param confidence The probability that the algorithm produces a useful result.
  2022. * param inliers Output vector that contains indices of inliers in objectPoints and imagePoints .
  2023. *
  2024. * The function estimates an object pose given a set of object points, their corresponding image
  2025. * projections, as well as the camera intrinsic matrix and the distortion coefficients. This function finds such
  2026. * a pose that minimizes reprojection error, that is, the sum of squared distances between the observed
  2027. * projections imagePoints and the projected (using REF: projectPoints ) objectPoints. The use of RANSAC
  2028. * makes the function resistant to outliers.
  2029. *
  2030. * <b>Note:</b>
  2031. * <ul>
  2032. * <li>
  2033. * An example of how to use solvePNPRansac for object detection can be found at
  2034. * opencv_source_code/samples/cpp/tutorial_code/calib3d/real_time_pose_estimation/
  2035. * </li>
  2036. * <li>
  2037. * The default method used to estimate the camera pose for the Minimal Sample Sets step
  2038. * is #SOLVEPNP_EPNP. Exceptions are:
  2039. * <ul>
  2040. * <li>
  2041. * if you choose #SOLVEPNP_P3P or #SOLVEPNP_AP3P, these methods will be used.
  2042. * </li>
  2043. * <li>
  2044. * if the number of input points is equal to 4, #SOLVEPNP_P3P is used.
  2045. * </li>
  2046. * </ul>
  2047. * <li>
  2048. * The method used to estimate the camera pose using all the inliers is defined by the
  2049. * flags parameters unless it is equal to #SOLVEPNP_P3P or #SOLVEPNP_AP3P. In this case,
  2050. * the method #SOLVEPNP_EPNP will be used instead.
  2051. * </li>
  2052. * </ul>
  2053. * return automatically generated
  2054. */
  2055. public static bool solvePnPRansac(MatOfPoint3f objectPoints, MatOfPoint2f imagePoints, Mat cameraMatrix, MatOfDouble distCoeffs, Mat rvec, Mat tvec, bool useExtrinsicGuess, int iterationsCount, float reprojectionError, double confidence, Mat inliers)
  2056. {
  2057. if (objectPoints != null) objectPoints.ThrowIfDisposed();
  2058. if (imagePoints != null) imagePoints.ThrowIfDisposed();
  2059. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  2060. if (distCoeffs != null) distCoeffs.ThrowIfDisposed();
  2061. if (rvec != null) rvec.ThrowIfDisposed();
  2062. if (tvec != null) tvec.ThrowIfDisposed();
  2063. if (inliers != null) inliers.ThrowIfDisposed();
  2064. Mat objectPoints_mat = objectPoints;
  2065. Mat imagePoints_mat = imagePoints;
  2066. Mat distCoeffs_mat = distCoeffs;
  2067. return calib3d_Calib3d_solvePnPRansac_11(objectPoints_mat.nativeObj, imagePoints_mat.nativeObj, cameraMatrix.nativeObj, distCoeffs_mat.nativeObj, rvec.nativeObj, tvec.nativeObj, useExtrinsicGuess, iterationsCount, reprojectionError, confidence, inliers.nativeObj);
  2068. }
  2069. /**
  2070. * Finds an object pose from 3D-2D point correspondences using the RANSAC scheme.
  2071. *
  2072. * SEE: REF: calib3d_solvePnP
  2073. *
  2074. * param objectPoints Array of object points in the object coordinate space, Nx3 1-channel or
  2075. * 1xN/Nx1 3-channel, where N is the number of points. vector&lt;Point3d&gt; can be also passed here.
  2076. * param imagePoints Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
  2077. * where N is the number of points. vector&lt;Point2d&gt; can be also passed here.
  2078. * param cameraMatrix Input camera intrinsic matrix \(\cameramatrix{A}\) .
  2079. * param distCoeffs Input vector of distortion coefficients
  2080. * \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
  2081. * assumed.
  2082. * param rvec Output rotation vector (see REF: Rodrigues ) that, together with tvec, brings points from
  2083. * the model coordinate system to the camera coordinate system.
  2084. * param tvec Output translation vector.
  2085. * param useExtrinsicGuess Parameter used for REF: SOLVEPNP_ITERATIVE. If true (1), the function uses
  2086. * the provided rvec and tvec values as initial approximations of the rotation and translation
  2087. * vectors, respectively, and further optimizes them.
  2088. * param iterationsCount Number of iterations.
  2089. * param reprojectionError Inlier threshold value used by the RANSAC procedure. The parameter value
  2090. * is the maximum allowed distance between the observed and computed point projections to consider it
  2091. * an inlier.
  2092. * param confidence The probability that the algorithm produces a useful result.
  2093. *
  2094. * The function estimates an object pose given a set of object points, their corresponding image
  2095. * projections, as well as the camera intrinsic matrix and the distortion coefficients. This function finds such
  2096. * a pose that minimizes reprojection error, that is, the sum of squared distances between the observed
  2097. * projections imagePoints and the projected (using REF: projectPoints ) objectPoints. The use of RANSAC
  2098. * makes the function resistant to outliers.
  2099. *
  2100. * <b>Note:</b>
  2101. * <ul>
  2102. * <li>
  2103. * An example of how to use solvePNPRansac for object detection can be found at
  2104. * opencv_source_code/samples/cpp/tutorial_code/calib3d/real_time_pose_estimation/
  2105. * </li>
  2106. * <li>
  2107. * The default method used to estimate the camera pose for the Minimal Sample Sets step
  2108. * is #SOLVEPNP_EPNP. Exceptions are:
  2109. * <ul>
  2110. * <li>
  2111. * if you choose #SOLVEPNP_P3P or #SOLVEPNP_AP3P, these methods will be used.
  2112. * </li>
  2113. * <li>
  2114. * if the number of input points is equal to 4, #SOLVEPNP_P3P is used.
  2115. * </li>
  2116. * </ul>
  2117. * <li>
  2118. * The method used to estimate the camera pose using all the inliers is defined by the
  2119. * flags parameters unless it is equal to #SOLVEPNP_P3P or #SOLVEPNP_AP3P. In this case,
  2120. * the method #SOLVEPNP_EPNP will be used instead.
  2121. * </li>
  2122. * </ul>
  2123. * return automatically generated
  2124. */
  2125. public static bool solvePnPRansac(MatOfPoint3f objectPoints, MatOfPoint2f imagePoints, Mat cameraMatrix, MatOfDouble distCoeffs, Mat rvec, Mat tvec, bool useExtrinsicGuess, int iterationsCount, float reprojectionError, double confidence)
  2126. {
  2127. if (objectPoints != null) objectPoints.ThrowIfDisposed();
  2128. if (imagePoints != null) imagePoints.ThrowIfDisposed();
  2129. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  2130. if (distCoeffs != null) distCoeffs.ThrowIfDisposed();
  2131. if (rvec != null) rvec.ThrowIfDisposed();
  2132. if (tvec != null) tvec.ThrowIfDisposed();
  2133. Mat objectPoints_mat = objectPoints;
  2134. Mat imagePoints_mat = imagePoints;
  2135. Mat distCoeffs_mat = distCoeffs;
  2136. return calib3d_Calib3d_solvePnPRansac_12(objectPoints_mat.nativeObj, imagePoints_mat.nativeObj, cameraMatrix.nativeObj, distCoeffs_mat.nativeObj, rvec.nativeObj, tvec.nativeObj, useExtrinsicGuess, iterationsCount, reprojectionError, confidence);
  2137. }
  2138. /**
  2139. * Finds an object pose from 3D-2D point correspondences using the RANSAC scheme.
  2140. *
  2141. * SEE: REF: calib3d_solvePnP
  2142. *
  2143. * param objectPoints Array of object points in the object coordinate space, Nx3 1-channel or
  2144. * 1xN/Nx1 3-channel, where N is the number of points. vector&lt;Point3d&gt; can be also passed here.
  2145. * param imagePoints Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
  2146. * where N is the number of points. vector&lt;Point2d&gt; can be also passed here.
  2147. * param cameraMatrix Input camera intrinsic matrix \(\cameramatrix{A}\) .
  2148. * param distCoeffs Input vector of distortion coefficients
  2149. * \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
  2150. * assumed.
  2151. * param rvec Output rotation vector (see REF: Rodrigues ) that, together with tvec, brings points from
  2152. * the model coordinate system to the camera coordinate system.
  2153. * param tvec Output translation vector.
  2154. * param useExtrinsicGuess Parameter used for REF: SOLVEPNP_ITERATIVE. If true (1), the function uses
  2155. * the provided rvec and tvec values as initial approximations of the rotation and translation
  2156. * vectors, respectively, and further optimizes them.
  2157. * param iterationsCount Number of iterations.
  2158. * param reprojectionError Inlier threshold value used by the RANSAC procedure. The parameter value
  2159. * is the maximum allowed distance between the observed and computed point projections to consider it
  2160. * an inlier.
  2161. *
  2162. * The function estimates an object pose given a set of object points, their corresponding image
  2163. * projections, as well as the camera intrinsic matrix and the distortion coefficients. This function finds such
  2164. * a pose that minimizes reprojection error, that is, the sum of squared distances between the observed
  2165. * projections imagePoints and the projected (using REF: projectPoints ) objectPoints. The use of RANSAC
  2166. * makes the function resistant to outliers.
  2167. *
  2168. * <b>Note:</b>
  2169. * <ul>
  2170. * <li>
  2171. * An example of how to use solvePNPRansac for object detection can be found at
  2172. * opencv_source_code/samples/cpp/tutorial_code/calib3d/real_time_pose_estimation/
  2173. * </li>
  2174. * <li>
  2175. * The default method used to estimate the camera pose for the Minimal Sample Sets step
  2176. * is #SOLVEPNP_EPNP. Exceptions are:
  2177. * <ul>
  2178. * <li>
  2179. * if you choose #SOLVEPNP_P3P or #SOLVEPNP_AP3P, these methods will be used.
  2180. * </li>
  2181. * <li>
  2182. * if the number of input points is equal to 4, #SOLVEPNP_P3P is used.
  2183. * </li>
  2184. * </ul>
  2185. * <li>
  2186. * The method used to estimate the camera pose using all the inliers is defined by the
  2187. * flags parameters unless it is equal to #SOLVEPNP_P3P or #SOLVEPNP_AP3P. In this case,
  2188. * the method #SOLVEPNP_EPNP will be used instead.
  2189. * </li>
  2190. * </ul>
  2191. * return automatically generated
  2192. */
  2193. public static bool solvePnPRansac(MatOfPoint3f objectPoints, MatOfPoint2f imagePoints, Mat cameraMatrix, MatOfDouble distCoeffs, Mat rvec, Mat tvec, bool useExtrinsicGuess, int iterationsCount, float reprojectionError)
  2194. {
  2195. if (objectPoints != null) objectPoints.ThrowIfDisposed();
  2196. if (imagePoints != null) imagePoints.ThrowIfDisposed();
  2197. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  2198. if (distCoeffs != null) distCoeffs.ThrowIfDisposed();
  2199. if (rvec != null) rvec.ThrowIfDisposed();
  2200. if (tvec != null) tvec.ThrowIfDisposed();
  2201. Mat objectPoints_mat = objectPoints;
  2202. Mat imagePoints_mat = imagePoints;
  2203. Mat distCoeffs_mat = distCoeffs;
  2204. return calib3d_Calib3d_solvePnPRansac_13(objectPoints_mat.nativeObj, imagePoints_mat.nativeObj, cameraMatrix.nativeObj, distCoeffs_mat.nativeObj, rvec.nativeObj, tvec.nativeObj, useExtrinsicGuess, iterationsCount, reprojectionError);
  2205. }
  2206. /**
  2207. * Finds an object pose from 3D-2D point correspondences using the RANSAC scheme.
  2208. *
  2209. * SEE: REF: calib3d_solvePnP
  2210. *
  2211. * param objectPoints Array of object points in the object coordinate space, Nx3 1-channel or
  2212. * 1xN/Nx1 3-channel, where N is the number of points. vector&lt;Point3d&gt; can be also passed here.
  2213. * param imagePoints Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
  2214. * where N is the number of points. vector&lt;Point2d&gt; can be also passed here.
  2215. * param cameraMatrix Input camera intrinsic matrix \(\cameramatrix{A}\) .
  2216. * param distCoeffs Input vector of distortion coefficients
  2217. * \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
  2218. * assumed.
  2219. * param rvec Output rotation vector (see REF: Rodrigues ) that, together with tvec, brings points from
  2220. * the model coordinate system to the camera coordinate system.
  2221. * param tvec Output translation vector.
  2222. * param useExtrinsicGuess Parameter used for REF: SOLVEPNP_ITERATIVE. If true (1), the function uses
  2223. * the provided rvec and tvec values as initial approximations of the rotation and translation
  2224. * vectors, respectively, and further optimizes them.
  2225. * param iterationsCount Number of iterations.
  2226. * is the maximum allowed distance between the observed and computed point projections to consider it
  2227. * an inlier.
  2228. *
  2229. * The function estimates an object pose given a set of object points, their corresponding image
  2230. * projections, as well as the camera intrinsic matrix and the distortion coefficients. This function finds such
  2231. * a pose that minimizes reprojection error, that is, the sum of squared distances between the observed
  2232. * projections imagePoints and the projected (using REF: projectPoints ) objectPoints. The use of RANSAC
  2233. * makes the function resistant to outliers.
  2234. *
  2235. * <b>Note:</b>
  2236. * <ul>
  2237. * <li>
  2238. * An example of how to use solvePNPRansac for object detection can be found at
  2239. * opencv_source_code/samples/cpp/tutorial_code/calib3d/real_time_pose_estimation/
  2240. * </li>
  2241. * <li>
  2242. * The default method used to estimate the camera pose for the Minimal Sample Sets step
  2243. * is #SOLVEPNP_EPNP. Exceptions are:
  2244. * <ul>
  2245. * <li>
  2246. * if you choose #SOLVEPNP_P3P or #SOLVEPNP_AP3P, these methods will be used.
  2247. * </li>
  2248. * <li>
  2249. * if the number of input points is equal to 4, #SOLVEPNP_P3P is used.
  2250. * </li>
  2251. * </ul>
  2252. * <li>
  2253. * The method used to estimate the camera pose using all the inliers is defined by the
  2254. * flags parameters unless it is equal to #SOLVEPNP_P3P or #SOLVEPNP_AP3P. In this case,
  2255. * the method #SOLVEPNP_EPNP will be used instead.
  2256. * </li>
  2257. * </ul>
  2258. * return automatically generated
  2259. */
  2260. public static bool solvePnPRansac(MatOfPoint3f objectPoints, MatOfPoint2f imagePoints, Mat cameraMatrix, MatOfDouble distCoeffs, Mat rvec, Mat tvec, bool useExtrinsicGuess, int iterationsCount)
  2261. {
  2262. if (objectPoints != null) objectPoints.ThrowIfDisposed();
  2263. if (imagePoints != null) imagePoints.ThrowIfDisposed();
  2264. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  2265. if (distCoeffs != null) distCoeffs.ThrowIfDisposed();
  2266. if (rvec != null) rvec.ThrowIfDisposed();
  2267. if (tvec != null) tvec.ThrowIfDisposed();
  2268. Mat objectPoints_mat = objectPoints;
  2269. Mat imagePoints_mat = imagePoints;
  2270. Mat distCoeffs_mat = distCoeffs;
  2271. return calib3d_Calib3d_solvePnPRansac_14(objectPoints_mat.nativeObj, imagePoints_mat.nativeObj, cameraMatrix.nativeObj, distCoeffs_mat.nativeObj, rvec.nativeObj, tvec.nativeObj, useExtrinsicGuess, iterationsCount);
  2272. }
  2273. /**
  2274. * Finds an object pose from 3D-2D point correspondences using the RANSAC scheme.
  2275. *
  2276. * SEE: REF: calib3d_solvePnP
  2277. *
  2278. * param objectPoints Array of object points in the object coordinate space, Nx3 1-channel or
  2279. * 1xN/Nx1 3-channel, where N is the number of points. vector&lt;Point3d&gt; can be also passed here.
  2280. * param imagePoints Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
  2281. * where N is the number of points. vector&lt;Point2d&gt; can be also passed here.
  2282. * param cameraMatrix Input camera intrinsic matrix \(\cameramatrix{A}\) .
  2283. * param distCoeffs Input vector of distortion coefficients
  2284. * \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
  2285. * assumed.
  2286. * param rvec Output rotation vector (see REF: Rodrigues ) that, together with tvec, brings points from
  2287. * the model coordinate system to the camera coordinate system.
  2288. * param tvec Output translation vector.
  2289. * param useExtrinsicGuess Parameter used for REF: SOLVEPNP_ITERATIVE. If true (1), the function uses
  2290. * the provided rvec and tvec values as initial approximations of the rotation and translation
  2291. * vectors, respectively, and further optimizes them.
  2292. * is the maximum allowed distance between the observed and computed point projections to consider it
  2293. * an inlier.
  2294. *
  2295. * The function estimates an object pose given a set of object points, their corresponding image
  2296. * projections, as well as the camera intrinsic matrix and the distortion coefficients. This function finds such
  2297. * a pose that minimizes reprojection error, that is, the sum of squared distances between the observed
  2298. * projections imagePoints and the projected (using REF: projectPoints ) objectPoints. The use of RANSAC
  2299. * makes the function resistant to outliers.
  2300. *
  2301. * <b>Note:</b>
  2302. * <ul>
  2303. * <li>
  2304. * An example of how to use solvePNPRansac for object detection can be found at
  2305. * opencv_source_code/samples/cpp/tutorial_code/calib3d/real_time_pose_estimation/
  2306. * </li>
  2307. * <li>
  2308. * The default method used to estimate the camera pose for the Minimal Sample Sets step
  2309. * is #SOLVEPNP_EPNP. Exceptions are:
  2310. * <ul>
  2311. * <li>
  2312. * if you choose #SOLVEPNP_P3P or #SOLVEPNP_AP3P, these methods will be used.
  2313. * </li>
  2314. * <li>
  2315. * if the number of input points is equal to 4, #SOLVEPNP_P3P is used.
  2316. * </li>
  2317. * </ul>
  2318. * <li>
  2319. * The method used to estimate the camera pose using all the inliers is defined by the
  2320. * flags parameters unless it is equal to #SOLVEPNP_P3P or #SOLVEPNP_AP3P. In this case,
  2321. * the method #SOLVEPNP_EPNP will be used instead.
  2322. * </li>
  2323. * </ul>
  2324. * return automatically generated
  2325. */
  2326. public static bool solvePnPRansac(MatOfPoint3f objectPoints, MatOfPoint2f imagePoints, Mat cameraMatrix, MatOfDouble distCoeffs, Mat rvec, Mat tvec, bool useExtrinsicGuess)
  2327. {
  2328. if (objectPoints != null) objectPoints.ThrowIfDisposed();
  2329. if (imagePoints != null) imagePoints.ThrowIfDisposed();
  2330. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  2331. if (distCoeffs != null) distCoeffs.ThrowIfDisposed();
  2332. if (rvec != null) rvec.ThrowIfDisposed();
  2333. if (tvec != null) tvec.ThrowIfDisposed();
  2334. Mat objectPoints_mat = objectPoints;
  2335. Mat imagePoints_mat = imagePoints;
  2336. Mat distCoeffs_mat = distCoeffs;
  2337. return calib3d_Calib3d_solvePnPRansac_15(objectPoints_mat.nativeObj, imagePoints_mat.nativeObj, cameraMatrix.nativeObj, distCoeffs_mat.nativeObj, rvec.nativeObj, tvec.nativeObj, useExtrinsicGuess);
  2338. }
  2339. /**
  2340. * Finds an object pose from 3D-2D point correspondences using the RANSAC scheme.
  2341. *
  2342. * SEE: REF: calib3d_solvePnP
  2343. *
  2344. * param objectPoints Array of object points in the object coordinate space, Nx3 1-channel or
  2345. * 1xN/Nx1 3-channel, where N is the number of points. vector&lt;Point3d&gt; can be also passed here.
  2346. * param imagePoints Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
  2347. * where N is the number of points. vector&lt;Point2d&gt; can be also passed here.
  2348. * param cameraMatrix Input camera intrinsic matrix \(\cameramatrix{A}\) .
  2349. * param distCoeffs Input vector of distortion coefficients
  2350. * \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
  2351. * assumed.
  2352. * param rvec Output rotation vector (see REF: Rodrigues ) that, together with tvec, brings points from
  2353. * the model coordinate system to the camera coordinate system.
  2354. * param tvec Output translation vector.
  2355. * the provided rvec and tvec values as initial approximations of the rotation and translation
  2356. * vectors, respectively, and further optimizes them.
  2357. * is the maximum allowed distance between the observed and computed point projections to consider it
  2358. * an inlier.
  2359. *
  2360. * The function estimates an object pose given a set of object points, their corresponding image
  2361. * projections, as well as the camera intrinsic matrix and the distortion coefficients. This function finds such
  2362. * a pose that minimizes reprojection error, that is, the sum of squared distances between the observed
  2363. * projections imagePoints and the projected (using REF: projectPoints ) objectPoints. The use of RANSAC
  2364. * makes the function resistant to outliers.
  2365. *
  2366. * <b>Note:</b>
  2367. * <ul>
  2368. * <li>
  2369. * An example of how to use solvePNPRansac for object detection can be found at
  2370. * opencv_source_code/samples/cpp/tutorial_code/calib3d/real_time_pose_estimation/
  2371. * </li>
  2372. * <li>
  2373. * The default method used to estimate the camera pose for the Minimal Sample Sets step
  2374. * is #SOLVEPNP_EPNP. Exceptions are:
  2375. * <ul>
  2376. * <li>
  2377. * if you choose #SOLVEPNP_P3P or #SOLVEPNP_AP3P, these methods will be used.
  2378. * </li>
  2379. * <li>
  2380. * if the number of input points is equal to 4, #SOLVEPNP_P3P is used.
  2381. * </li>
  2382. * </ul>
  2383. * <li>
  2384. * The method used to estimate the camera pose using all the inliers is defined by the
  2385. * flags parameters unless it is equal to #SOLVEPNP_P3P or #SOLVEPNP_AP3P. In this case,
  2386. * the method #SOLVEPNP_EPNP will be used instead.
  2387. * </li>
  2388. * </ul>
  2389. * return automatically generated
  2390. */
  2391. public static bool solvePnPRansac(MatOfPoint3f objectPoints, MatOfPoint2f imagePoints, Mat cameraMatrix, MatOfDouble distCoeffs, Mat rvec, Mat tvec)
  2392. {
  2393. if (objectPoints != null) objectPoints.ThrowIfDisposed();
  2394. if (imagePoints != null) imagePoints.ThrowIfDisposed();
  2395. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  2396. if (distCoeffs != null) distCoeffs.ThrowIfDisposed();
  2397. if (rvec != null) rvec.ThrowIfDisposed();
  2398. if (tvec != null) tvec.ThrowIfDisposed();
  2399. Mat objectPoints_mat = objectPoints;
  2400. Mat imagePoints_mat = imagePoints;
  2401. Mat distCoeffs_mat = distCoeffs;
  2402. return calib3d_Calib3d_solvePnPRansac_16(objectPoints_mat.nativeObj, imagePoints_mat.nativeObj, cameraMatrix.nativeObj, distCoeffs_mat.nativeObj, rvec.nativeObj, tvec.nativeObj);
  2403. }
  2404. //
  2405. // C++: bool cv::solvePnPRansac(vector_Point3f objectPoints, vector_Point2f imagePoints, Mat& cameraMatrix, vector_double distCoeffs, Mat& rvec, Mat& tvec, Mat& inliers, UsacParams _params = UsacParams())
  2406. //
  2407. public static bool solvePnPRansac(MatOfPoint3f objectPoints, MatOfPoint2f imagePoints, Mat cameraMatrix, MatOfDouble distCoeffs, Mat rvec, Mat tvec, Mat inliers, UsacParams _params)
  2408. {
  2409. if (objectPoints != null) objectPoints.ThrowIfDisposed();
  2410. if (imagePoints != null) imagePoints.ThrowIfDisposed();
  2411. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  2412. if (distCoeffs != null) distCoeffs.ThrowIfDisposed();
  2413. if (rvec != null) rvec.ThrowIfDisposed();
  2414. if (tvec != null) tvec.ThrowIfDisposed();
  2415. if (inliers != null) inliers.ThrowIfDisposed();
  2416. if (_params != null) _params.ThrowIfDisposed();
  2417. Mat objectPoints_mat = objectPoints;
  2418. Mat imagePoints_mat = imagePoints;
  2419. Mat distCoeffs_mat = distCoeffs;
  2420. return calib3d_Calib3d_solvePnPRansac_17(objectPoints_mat.nativeObj, imagePoints_mat.nativeObj, cameraMatrix.nativeObj, distCoeffs_mat.nativeObj, rvec.nativeObj, tvec.nativeObj, inliers.nativeObj, _params.nativeObj);
  2421. }
  2422. public static bool solvePnPRansac(MatOfPoint3f objectPoints, MatOfPoint2f imagePoints, Mat cameraMatrix, MatOfDouble distCoeffs, Mat rvec, Mat tvec, Mat inliers)
  2423. {
  2424. if (objectPoints != null) objectPoints.ThrowIfDisposed();
  2425. if (imagePoints != null) imagePoints.ThrowIfDisposed();
  2426. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  2427. if (distCoeffs != null) distCoeffs.ThrowIfDisposed();
  2428. if (rvec != null) rvec.ThrowIfDisposed();
  2429. if (tvec != null) tvec.ThrowIfDisposed();
  2430. if (inliers != null) inliers.ThrowIfDisposed();
  2431. Mat objectPoints_mat = objectPoints;
  2432. Mat imagePoints_mat = imagePoints;
  2433. Mat distCoeffs_mat = distCoeffs;
  2434. return calib3d_Calib3d_solvePnPRansac_18(objectPoints_mat.nativeObj, imagePoints_mat.nativeObj, cameraMatrix.nativeObj, distCoeffs_mat.nativeObj, rvec.nativeObj, tvec.nativeObj, inliers.nativeObj);
  2435. }
  2436. //
  2437. // C++: int cv::solveP3P(Mat objectPoints, Mat imagePoints, Mat cameraMatrix, Mat distCoeffs, vector_Mat& rvecs, vector_Mat& tvecs, int flags)
  2438. //
  2439. /**
  2440. * Finds an object pose from 3 3D-2D point correspondences.
  2441. *
  2442. * SEE: REF: calib3d_solvePnP
  2443. *
  2444. * param objectPoints Array of object points in the object coordinate space, 3x3 1-channel or
  2445. * 1x3/3x1 3-channel. vector&lt;Point3f&gt; can be also passed here.
  2446. * param imagePoints Array of corresponding image points, 3x2 1-channel or 1x3/3x1 2-channel.
  2447. * vector&lt;Point2f&gt; can be also passed here.
  2448. * param cameraMatrix Input camera intrinsic matrix \(\cameramatrix{A}\) .
  2449. * param distCoeffs Input vector of distortion coefficients
  2450. * \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
  2451. * assumed.
  2452. * param rvecs Output rotation vectors (see REF: Rodrigues ) that, together with tvecs, brings points from
  2453. * the model coordinate system to the camera coordinate system. A P3P problem has up to 4 solutions.
  2454. * param tvecs Output translation vectors.
  2455. * param flags Method for solving a P3P problem:
  2456. * <ul>
  2457. * <li>
  2458. * REF: SOLVEPNP_P3P Method is based on the paper of X.S. Gao, X.-R. Hou, J. Tang, H.-F. Chang
  2459. * "Complete Solution Classification for the Perspective-Three-Point Problem" (CITE: gao2003complete).
  2460. * </li>
  2461. * <li>
  2462. * REF: SOLVEPNP_AP3P Method is based on the paper of T. Ke and S. Roumeliotis.
  2463. * "An Efficient Algebraic Solution to the Perspective-Three-Point Problem" (CITE: Ke17).
  2464. * </li>
  2465. * </ul>
  2466. *
  2467. * The function estimates the object pose given 3 object points, their corresponding image
  2468. * projections, as well as the camera intrinsic matrix and the distortion coefficients.
  2469. *
  2470. * <b>Note:</b>
  2471. * The solutions are sorted by reprojection errors (lowest to highest).
  2472. * return automatically generated
  2473. */
  2474. public static int solveP3P(Mat objectPoints, Mat imagePoints, Mat cameraMatrix, Mat distCoeffs, List<Mat> rvecs, List<Mat> tvecs, int flags)
  2475. {
  2476. if (objectPoints != null) objectPoints.ThrowIfDisposed();
  2477. if (imagePoints != null) imagePoints.ThrowIfDisposed();
  2478. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  2479. if (distCoeffs != null) distCoeffs.ThrowIfDisposed();
  2480. Mat rvecs_mat = new Mat();
  2481. Mat tvecs_mat = new Mat();
  2482. int retVal = calib3d_Calib3d_solveP3P_10(objectPoints.nativeObj, imagePoints.nativeObj, cameraMatrix.nativeObj, distCoeffs.nativeObj, rvecs_mat.nativeObj, tvecs_mat.nativeObj, flags);
  2483. Converters.Mat_to_vector_Mat(rvecs_mat, rvecs);
  2484. rvecs_mat.release();
  2485. Converters.Mat_to_vector_Mat(tvecs_mat, tvecs);
  2486. tvecs_mat.release();
  2487. return retVal;
  2488. }
  2489. //
  2490. // C++: void cv::solvePnPRefineLM(Mat objectPoints, Mat imagePoints, Mat cameraMatrix, Mat distCoeffs, Mat& rvec, Mat& tvec, TermCriteria criteria = TermCriteria(TermCriteria::EPS + TermCriteria::COUNT, 20, FLT_EPSILON))
  2491. //
  2492. /**
  2493. * Refine a pose (the translation and the rotation that transform a 3D point expressed in the object coordinate frame
  2494. * to the camera coordinate frame) from a 3D-2D point correspondences and starting from an initial solution.
  2495. *
  2496. * SEE: REF: calib3d_solvePnP
  2497. *
  2498. * param objectPoints Array of object points in the object coordinate space, Nx3 1-channel or 1xN/Nx1 3-channel,
  2499. * where N is the number of points. vector&lt;Point3d&gt; can also be passed here.
  2500. * param imagePoints Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
  2501. * where N is the number of points. vector&lt;Point2d&gt; can also be passed here.
  2502. * param cameraMatrix Input camera intrinsic matrix \(\cameramatrix{A}\) .
  2503. * param distCoeffs Input vector of distortion coefficients
  2504. * \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
  2505. * assumed.
  2506. * param rvec Input/Output rotation vector (see REF: Rodrigues ) that, together with tvec, brings points from
  2507. * the model coordinate system to the camera coordinate system. Input values are used as an initial solution.
  2508. * param tvec Input/Output translation vector. Input values are used as an initial solution.
  2509. * param criteria Criteria when to stop the Levenberg-Marquard iterative algorithm.
  2510. *
  2511. * The function refines the object pose given at least 3 object points, their corresponding image
  2512. * projections, an initial solution for the rotation and translation vector,
  2513. * as well as the camera intrinsic matrix and the distortion coefficients.
  2514. * The function minimizes the projection error with respect to the rotation and the translation vectors, according
  2515. * to a Levenberg-Marquardt iterative minimization CITE: Madsen04 CITE: Eade13 process.
  2516. */
  2517. public static void solvePnPRefineLM(Mat objectPoints, Mat imagePoints, Mat cameraMatrix, Mat distCoeffs, Mat rvec, Mat tvec, TermCriteria criteria)
  2518. {
  2519. if (objectPoints != null) objectPoints.ThrowIfDisposed();
  2520. if (imagePoints != null) imagePoints.ThrowIfDisposed();
  2521. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  2522. if (distCoeffs != null) distCoeffs.ThrowIfDisposed();
  2523. if (rvec != null) rvec.ThrowIfDisposed();
  2524. if (tvec != null) tvec.ThrowIfDisposed();
  2525. calib3d_Calib3d_solvePnPRefineLM_10(objectPoints.nativeObj, imagePoints.nativeObj, cameraMatrix.nativeObj, distCoeffs.nativeObj, rvec.nativeObj, tvec.nativeObj, criteria.type, criteria.maxCount, criteria.epsilon);
  2526. }
  2527. /**
  2528. * Refine a pose (the translation and the rotation that transform a 3D point expressed in the object coordinate frame
  2529. * to the camera coordinate frame) from a 3D-2D point correspondences and starting from an initial solution.
  2530. *
  2531. * SEE: REF: calib3d_solvePnP
  2532. *
  2533. * param objectPoints Array of object points in the object coordinate space, Nx3 1-channel or 1xN/Nx1 3-channel,
  2534. * where N is the number of points. vector&lt;Point3d&gt; can also be passed here.
  2535. * param imagePoints Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
  2536. * where N is the number of points. vector&lt;Point2d&gt; can also be passed here.
  2537. * param cameraMatrix Input camera intrinsic matrix \(\cameramatrix{A}\) .
  2538. * param distCoeffs Input vector of distortion coefficients
  2539. * \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
  2540. * assumed.
  2541. * param rvec Input/Output rotation vector (see REF: Rodrigues ) that, together with tvec, brings points from
  2542. * the model coordinate system to the camera coordinate system. Input values are used as an initial solution.
  2543. * param tvec Input/Output translation vector. Input values are used as an initial solution.
  2544. *
  2545. * The function refines the object pose given at least 3 object points, their corresponding image
  2546. * projections, an initial solution for the rotation and translation vector,
  2547. * as well as the camera intrinsic matrix and the distortion coefficients.
  2548. * The function minimizes the projection error with respect to the rotation and the translation vectors, according
  2549. * to a Levenberg-Marquardt iterative minimization CITE: Madsen04 CITE: Eade13 process.
  2550. */
  2551. public static void solvePnPRefineLM(Mat objectPoints, Mat imagePoints, Mat cameraMatrix, Mat distCoeffs, Mat rvec, Mat tvec)
  2552. {
  2553. if (objectPoints != null) objectPoints.ThrowIfDisposed();
  2554. if (imagePoints != null) imagePoints.ThrowIfDisposed();
  2555. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  2556. if (distCoeffs != null) distCoeffs.ThrowIfDisposed();
  2557. if (rvec != null) rvec.ThrowIfDisposed();
  2558. if (tvec != null) tvec.ThrowIfDisposed();
  2559. calib3d_Calib3d_solvePnPRefineLM_11(objectPoints.nativeObj, imagePoints.nativeObj, cameraMatrix.nativeObj, distCoeffs.nativeObj, rvec.nativeObj, tvec.nativeObj);
  2560. }
  2561. //
  2562. // C++: void cv::solvePnPRefineVVS(Mat objectPoints, Mat imagePoints, Mat cameraMatrix, Mat distCoeffs, Mat& rvec, Mat& tvec, TermCriteria criteria = TermCriteria(TermCriteria::EPS + TermCriteria::COUNT, 20, FLT_EPSILON), double VVSlambda = 1)
  2563. //
  2564. /**
  2565. * Refine a pose (the translation and the rotation that transform a 3D point expressed in the object coordinate frame
  2566. * to the camera coordinate frame) from a 3D-2D point correspondences and starting from an initial solution.
  2567. *
  2568. * SEE: REF: calib3d_solvePnP
  2569. *
  2570. * param objectPoints Array of object points in the object coordinate space, Nx3 1-channel or 1xN/Nx1 3-channel,
  2571. * where N is the number of points. vector&lt;Point3d&gt; can also be passed here.
  2572. * param imagePoints Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
  2573. * where N is the number of points. vector&lt;Point2d&gt; can also be passed here.
  2574. * param cameraMatrix Input camera intrinsic matrix \(\cameramatrix{A}\) .
  2575. * param distCoeffs Input vector of distortion coefficients
  2576. * \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
  2577. * assumed.
  2578. * param rvec Input/Output rotation vector (see REF: Rodrigues ) that, together with tvec, brings points from
  2579. * the model coordinate system to the camera coordinate system. Input values are used as an initial solution.
  2580. * param tvec Input/Output translation vector. Input values are used as an initial solution.
  2581. * param criteria Criteria when to stop the Levenberg-Marquard iterative algorithm.
  2582. * param VVSlambda Gain for the virtual visual servoing control law, equivalent to the \(\alpha\)
  2583. * gain in the Damped Gauss-Newton formulation.
  2584. *
  2585. * The function refines the object pose given at least 3 object points, their corresponding image
  2586. * projections, an initial solution for the rotation and translation vector,
  2587. * as well as the camera intrinsic matrix and the distortion coefficients.
  2588. * The function minimizes the projection error with respect to the rotation and the translation vectors, using a
  2589. * virtual visual servoing (VVS) CITE: Chaumette06 CITE: Marchand16 scheme.
  2590. */
  2591. public static void solvePnPRefineVVS(Mat objectPoints, Mat imagePoints, Mat cameraMatrix, Mat distCoeffs, Mat rvec, Mat tvec, TermCriteria criteria, double VVSlambda)
  2592. {
  2593. if (objectPoints != null) objectPoints.ThrowIfDisposed();
  2594. if (imagePoints != null) imagePoints.ThrowIfDisposed();
  2595. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  2596. if (distCoeffs != null) distCoeffs.ThrowIfDisposed();
  2597. if (rvec != null) rvec.ThrowIfDisposed();
  2598. if (tvec != null) tvec.ThrowIfDisposed();
  2599. calib3d_Calib3d_solvePnPRefineVVS_10(objectPoints.nativeObj, imagePoints.nativeObj, cameraMatrix.nativeObj, distCoeffs.nativeObj, rvec.nativeObj, tvec.nativeObj, criteria.type, criteria.maxCount, criteria.epsilon, VVSlambda);
  2600. }
  2601. /**
  2602. * Refine a pose (the translation and the rotation that transform a 3D point expressed in the object coordinate frame
  2603. * to the camera coordinate frame) from a 3D-2D point correspondences and starting from an initial solution.
  2604. *
  2605. * SEE: REF: calib3d_solvePnP
  2606. *
  2607. * param objectPoints Array of object points in the object coordinate space, Nx3 1-channel or 1xN/Nx1 3-channel,
  2608. * where N is the number of points. vector&lt;Point3d&gt; can also be passed here.
  2609. * param imagePoints Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
  2610. * where N is the number of points. vector&lt;Point2d&gt; can also be passed here.
  2611. * param cameraMatrix Input camera intrinsic matrix \(\cameramatrix{A}\) .
  2612. * param distCoeffs Input vector of distortion coefficients
  2613. * \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
  2614. * assumed.
  2615. * param rvec Input/Output rotation vector (see REF: Rodrigues ) that, together with tvec, brings points from
  2616. * the model coordinate system to the camera coordinate system. Input values are used as an initial solution.
  2617. * param tvec Input/Output translation vector. Input values are used as an initial solution.
  2618. * param criteria Criteria when to stop the Levenberg-Marquard iterative algorithm.
  2619. * gain in the Damped Gauss-Newton formulation.
  2620. *
  2621. * The function refines the object pose given at least 3 object points, their corresponding image
  2622. * projections, an initial solution for the rotation and translation vector,
  2623. * as well as the camera intrinsic matrix and the distortion coefficients.
  2624. * The function minimizes the projection error with respect to the rotation and the translation vectors, using a
  2625. * virtual visual servoing (VVS) CITE: Chaumette06 CITE: Marchand16 scheme.
  2626. */
  2627. public static void solvePnPRefineVVS(Mat objectPoints, Mat imagePoints, Mat cameraMatrix, Mat distCoeffs, Mat rvec, Mat tvec, TermCriteria criteria)
  2628. {
  2629. if (objectPoints != null) objectPoints.ThrowIfDisposed();
  2630. if (imagePoints != null) imagePoints.ThrowIfDisposed();
  2631. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  2632. if (distCoeffs != null) distCoeffs.ThrowIfDisposed();
  2633. if (rvec != null) rvec.ThrowIfDisposed();
  2634. if (tvec != null) tvec.ThrowIfDisposed();
  2635. calib3d_Calib3d_solvePnPRefineVVS_11(objectPoints.nativeObj, imagePoints.nativeObj, cameraMatrix.nativeObj, distCoeffs.nativeObj, rvec.nativeObj, tvec.nativeObj, criteria.type, criteria.maxCount, criteria.epsilon);
  2636. }
  2637. /**
  2638. * Refine a pose (the translation and the rotation that transform a 3D point expressed in the object coordinate frame
  2639. * to the camera coordinate frame) from a 3D-2D point correspondences and starting from an initial solution.
  2640. *
  2641. * SEE: REF: calib3d_solvePnP
  2642. *
  2643. * param objectPoints Array of object points in the object coordinate space, Nx3 1-channel or 1xN/Nx1 3-channel,
  2644. * where N is the number of points. vector&lt;Point3d&gt; can also be passed here.
  2645. * param imagePoints Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
  2646. * where N is the number of points. vector&lt;Point2d&gt; can also be passed here.
  2647. * param cameraMatrix Input camera intrinsic matrix \(\cameramatrix{A}\) .
  2648. * param distCoeffs Input vector of distortion coefficients
  2649. * \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
  2650. * assumed.
  2651. * param rvec Input/Output rotation vector (see REF: Rodrigues ) that, together with tvec, brings points from
  2652. * the model coordinate system to the camera coordinate system. Input values are used as an initial solution.
  2653. * param tvec Input/Output translation vector. Input values are used as an initial solution.
  2654. * gain in the Damped Gauss-Newton formulation.
  2655. *
  2656. * The function refines the object pose given at least 3 object points, their corresponding image
  2657. * projections, an initial solution for the rotation and translation vector,
  2658. * as well as the camera intrinsic matrix and the distortion coefficients.
  2659. * The function minimizes the projection error with respect to the rotation and the translation vectors, using a
  2660. * virtual visual servoing (VVS) CITE: Chaumette06 CITE: Marchand16 scheme.
  2661. */
  2662. public static void solvePnPRefineVVS(Mat objectPoints, Mat imagePoints, Mat cameraMatrix, Mat distCoeffs, Mat rvec, Mat tvec)
  2663. {
  2664. if (objectPoints != null) objectPoints.ThrowIfDisposed();
  2665. if (imagePoints != null) imagePoints.ThrowIfDisposed();
  2666. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  2667. if (distCoeffs != null) distCoeffs.ThrowIfDisposed();
  2668. if (rvec != null) rvec.ThrowIfDisposed();
  2669. if (tvec != null) tvec.ThrowIfDisposed();
  2670. calib3d_Calib3d_solvePnPRefineVVS_12(objectPoints.nativeObj, imagePoints.nativeObj, cameraMatrix.nativeObj, distCoeffs.nativeObj, rvec.nativeObj, tvec.nativeObj);
  2671. }
  2672. //
  2673. // C++: int cv::solvePnPGeneric(Mat objectPoints, Mat imagePoints, Mat cameraMatrix, Mat distCoeffs, vector_Mat& rvecs, vector_Mat& tvecs, bool useExtrinsicGuess = false, SolvePnPMethod flags = SOLVEPNP_ITERATIVE, Mat rvec = Mat(), Mat tvec = Mat(), Mat& reprojectionError = Mat())
  2674. //
  2675. /**
  2676. * Finds an object pose from 3D-2D point correspondences.
  2677. *
  2678. * SEE: REF: calib3d_solvePnP
  2679. *
  2680. * This function returns a list of all the possible solutions (a solution is a &lt;rotation vector, translation vector&gt;
  2681. * couple), depending on the number of input points and the chosen method:
  2682. * <ul>
  2683. * <li>
  2684. * P3P methods (REF: SOLVEPNP_P3P, REF: SOLVEPNP_AP3P): 3 or 4 input points. Number of returned solutions can be between 0 and 4 with 3 input points.
  2685. * </li>
  2686. * <li>
  2687. * REF: SOLVEPNP_IPPE Input points must be &gt;= 4 and object points must be coplanar. Returns 2 solutions.
  2688. * </li>
  2689. * <li>
  2690. * REF: SOLVEPNP_IPPE_SQUARE Special case suitable for marker pose estimation.
  2691. * Number of input points must be 4 and 2 solutions are returned. Object points must be defined in the following order:
  2692. * <ul>
  2693. * <li>
  2694. * point 0: [-squareLength / 2, squareLength / 2, 0]
  2695. * </li>
  2696. * <li>
  2697. * point 1: [ squareLength / 2, squareLength / 2, 0]
  2698. * </li>
  2699. * <li>
  2700. * point 2: [ squareLength / 2, -squareLength / 2, 0]
  2701. * </li>
  2702. * <li>
  2703. * point 3: [-squareLength / 2, -squareLength / 2, 0]
  2704. * </li>
  2705. * </ul>
  2706. * <li>
  2707. * for all the other flags, number of input points must be &gt;= 4 and object points can be in any configuration.
  2708. * Only 1 solution is returned.
  2709. * </li>
  2710. * </ul>
  2711. *
  2712. * param objectPoints Array of object points in the object coordinate space, Nx3 1-channel or
  2713. * 1xN/Nx1 3-channel, where N is the number of points. vector&lt;Point3d&gt; can be also passed here.
  2714. * param imagePoints Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
  2715. * where N is the number of points. vector&lt;Point2d&gt; can be also passed here.
  2716. * param cameraMatrix Input camera intrinsic matrix \(\cameramatrix{A}\) .
  2717. * param distCoeffs Input vector of distortion coefficients
  2718. * \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
  2719. * assumed.
  2720. * param rvecs Vector of output rotation vectors (see REF: Rodrigues ) that, together with tvecs, brings points from
  2721. * the model coordinate system to the camera coordinate system.
  2722. * param tvecs Vector of output translation vectors.
  2723. * param useExtrinsicGuess Parameter used for #SOLVEPNP_ITERATIVE. If true (1), the function uses
  2724. * the provided rvec and tvec values as initial approximations of the rotation and translation
  2725. * vectors, respectively, and further optimizes them.
  2726. * param flags Method for solving a PnP problem: see REF: calib3d_solvePnP_flags
  2727. * param rvec Rotation vector used to initialize an iterative PnP refinement algorithm, when flag is REF: SOLVEPNP_ITERATIVE
  2728. * and useExtrinsicGuess is set to true.
  2729. * param tvec Translation vector used to initialize an iterative PnP refinement algorithm, when flag is REF: SOLVEPNP_ITERATIVE
  2730. * and useExtrinsicGuess is set to true.
  2731. * param reprojectionError Optional vector of reprojection error, that is the RMS error
  2732. * (\( \text{RMSE} = \sqrt{\frac{\sum_{i}^{N} \left ( \hat{y_i} - y_i \right )^2}{N}} \)) between the input image points
  2733. * and the 3D object points projected with the estimated pose.
  2734. *
  2735. * More information is described in REF: calib3d_solvePnP
  2736. *
  2737. * <b>Note:</b>
  2738. * <ul>
  2739. * <li>
  2740. * An example of how to use solvePnP for planar augmented reality can be found at
  2741. * opencv_source_code/samples/python/plane_ar.py
  2742. * </li>
  2743. * <li>
  2744. * If you are using Python:
  2745. * <ul>
  2746. * <li>
  2747. * Numpy array slices won't work as input because solvePnP requires contiguous
  2748. * arrays (enforced by the assertion using cv::Mat::checkVector() around line 55 of
  2749. * modules/calib3d/src/solvepnp.cpp version 2.4.9)
  2750. * </li>
  2751. * <li>
  2752. * The P3P algorithm requires image points to be in an array of shape (N,1,2) due
  2753. * to its calling of #undistortPoints (around line 75 of modules/calib3d/src/solvepnp.cpp version 2.4.9)
  2754. * which requires 2-channel information.
  2755. * </li>
  2756. * <li>
  2757. * Thus, given some data D = np.array(...) where D.shape = (N,M), in order to use a subset of
  2758. * it as, e.g., imagePoints, one must effectively copy it into a new array: imagePoints =
  2759. * np.ascontiguousarray(D[:,:2]).reshape((N,1,2))
  2760. * </li>
  2761. * </ul>
  2762. * <li>
  2763. * The methods REF: SOLVEPNP_DLS and REF: SOLVEPNP_UPNP cannot be used as the current implementations are
  2764. * unstable and sometimes give completely wrong results. If you pass one of these two
  2765. * flags, REF: SOLVEPNP_EPNP method will be used instead.
  2766. * </li>
  2767. * <li>
  2768. * The minimum number of points is 4 in the general case. In the case of REF: SOLVEPNP_P3P and REF: SOLVEPNP_AP3P
  2769. * methods, it is required to use exactly 4 points (the first 3 points are used to estimate all the solutions
  2770. * of the P3P problem, the last one is used to retain the best solution that minimizes the reprojection error).
  2771. * </li>
  2772. * <li>
  2773. * With REF: SOLVEPNP_ITERATIVE method and {code useExtrinsicGuess=true}, the minimum number of points is 3 (3 points
  2774. * are sufficient to compute a pose but there are up to 4 solutions). The initial solution should be close to the
  2775. * global solution to converge.
  2776. * </li>
  2777. * <li>
  2778. * With REF: SOLVEPNP_IPPE input points must be &gt;= 4 and object points must be coplanar.
  2779. * </li>
  2780. * <li>
  2781. * With REF: SOLVEPNP_IPPE_SQUARE this is a special case suitable for marker pose estimation.
  2782. * Number of input points must be 4. Object points must be defined in the following order:
  2783. * <ul>
  2784. * <li>
  2785. * point 0: [-squareLength / 2, squareLength / 2, 0]
  2786. * </li>
  2787. * <li>
  2788. * point 1: [ squareLength / 2, squareLength / 2, 0]
  2789. * </li>
  2790. * <li>
  2791. * point 2: [ squareLength / 2, -squareLength / 2, 0]
  2792. * </li>
  2793. * <li>
  2794. * point 3: [-squareLength / 2, -squareLength / 2, 0]
  2795. * </li>
  2796. * </ul>
  2797. * </li>
  2798. * </ul>
  2799. * return automatically generated
  2800. */
  2801. public static int solvePnPGeneric(Mat objectPoints, Mat imagePoints, Mat cameraMatrix, Mat distCoeffs, List<Mat> rvecs, List<Mat> tvecs, bool useExtrinsicGuess, int flags, Mat rvec, Mat tvec, Mat reprojectionError)
  2802. {
  2803. if (objectPoints != null) objectPoints.ThrowIfDisposed();
  2804. if (imagePoints != null) imagePoints.ThrowIfDisposed();
  2805. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  2806. if (distCoeffs != null) distCoeffs.ThrowIfDisposed();
  2807. if (rvec != null) rvec.ThrowIfDisposed();
  2808. if (tvec != null) tvec.ThrowIfDisposed();
  2809. if (reprojectionError != null) reprojectionError.ThrowIfDisposed();
  2810. Mat rvecs_mat = new Mat();
  2811. Mat tvecs_mat = new Mat();
  2812. int retVal = calib3d_Calib3d_solvePnPGeneric_10(objectPoints.nativeObj, imagePoints.nativeObj, cameraMatrix.nativeObj, distCoeffs.nativeObj, rvecs_mat.nativeObj, tvecs_mat.nativeObj, useExtrinsicGuess, flags, rvec.nativeObj, tvec.nativeObj, reprojectionError.nativeObj);
  2813. Converters.Mat_to_vector_Mat(rvecs_mat, rvecs);
  2814. rvecs_mat.release();
  2815. Converters.Mat_to_vector_Mat(tvecs_mat, tvecs);
  2816. tvecs_mat.release();
  2817. return retVal;
  2818. }
  2819. /**
  2820. * Finds an object pose from 3D-2D point correspondences.
  2821. *
  2822. * SEE: REF: calib3d_solvePnP
  2823. *
  2824. * This function returns a list of all the possible solutions (a solution is a &lt;rotation vector, translation vector&gt;
  2825. * couple), depending on the number of input points and the chosen method:
  2826. * <ul>
  2827. * <li>
  2828. * P3P methods (REF: SOLVEPNP_P3P, REF: SOLVEPNP_AP3P): 3 or 4 input points. Number of returned solutions can be between 0 and 4 with 3 input points.
  2829. * </li>
  2830. * <li>
  2831. * REF: SOLVEPNP_IPPE Input points must be &gt;= 4 and object points must be coplanar. Returns 2 solutions.
  2832. * </li>
  2833. * <li>
  2834. * REF: SOLVEPNP_IPPE_SQUARE Special case suitable for marker pose estimation.
  2835. * Number of input points must be 4 and 2 solutions are returned. Object points must be defined in the following order:
  2836. * <ul>
  2837. * <li>
  2838. * point 0: [-squareLength / 2, squareLength / 2, 0]
  2839. * </li>
  2840. * <li>
  2841. * point 1: [ squareLength / 2, squareLength / 2, 0]
  2842. * </li>
  2843. * <li>
  2844. * point 2: [ squareLength / 2, -squareLength / 2, 0]
  2845. * </li>
  2846. * <li>
  2847. * point 3: [-squareLength / 2, -squareLength / 2, 0]
  2848. * </li>
  2849. * </ul>
  2850. * <li>
  2851. * for all the other flags, number of input points must be &gt;= 4 and object points can be in any configuration.
  2852. * Only 1 solution is returned.
  2853. * </li>
  2854. * </ul>
  2855. *
  2856. * param objectPoints Array of object points in the object coordinate space, Nx3 1-channel or
  2857. * 1xN/Nx1 3-channel, where N is the number of points. vector&lt;Point3d&gt; can be also passed here.
  2858. * param imagePoints Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
  2859. * where N is the number of points. vector&lt;Point2d&gt; can be also passed here.
  2860. * param cameraMatrix Input camera intrinsic matrix \(\cameramatrix{A}\) .
  2861. * param distCoeffs Input vector of distortion coefficients
  2862. * \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
  2863. * assumed.
  2864. * param rvecs Vector of output rotation vectors (see REF: Rodrigues ) that, together with tvecs, brings points from
  2865. * the model coordinate system to the camera coordinate system.
  2866. * param tvecs Vector of output translation vectors.
  2867. * param useExtrinsicGuess Parameter used for #SOLVEPNP_ITERATIVE. If true (1), the function uses
  2868. * the provided rvec and tvec values as initial approximations of the rotation and translation
  2869. * vectors, respectively, and further optimizes them.
  2870. * param flags Method for solving a PnP problem: see REF: calib3d_solvePnP_flags
  2871. * param rvec Rotation vector used to initialize an iterative PnP refinement algorithm, when flag is REF: SOLVEPNP_ITERATIVE
  2872. * and useExtrinsicGuess is set to true.
  2873. * param tvec Translation vector used to initialize an iterative PnP refinement algorithm, when flag is REF: SOLVEPNP_ITERATIVE
  2874. * and useExtrinsicGuess is set to true.
  2875. * (\( \text{RMSE} = \sqrt{\frac{\sum_{i}^{N} \left ( \hat{y_i} - y_i \right )^2}{N}} \)) between the input image points
  2876. * and the 3D object points projected with the estimated pose.
  2877. *
  2878. * More information is described in REF: calib3d_solvePnP
  2879. *
  2880. * <b>Note:</b>
  2881. * <ul>
  2882. * <li>
  2883. * An example of how to use solvePnP for planar augmented reality can be found at
  2884. * opencv_source_code/samples/python/plane_ar.py
  2885. * </li>
  2886. * <li>
  2887. * If you are using Python:
  2888. * <ul>
  2889. * <li>
  2890. * Numpy array slices won't work as input because solvePnP requires contiguous
  2891. * arrays (enforced by the assertion using cv::Mat::checkVector() around line 55 of
  2892. * modules/calib3d/src/solvepnp.cpp version 2.4.9)
  2893. * </li>
  2894. * <li>
  2895. * The P3P algorithm requires image points to be in an array of shape (N,1,2) due
  2896. * to its calling of #undistortPoints (around line 75 of modules/calib3d/src/solvepnp.cpp version 2.4.9)
  2897. * which requires 2-channel information.
  2898. * </li>
  2899. * <li>
  2900. * Thus, given some data D = np.array(...) where D.shape = (N,M), in order to use a subset of
  2901. * it as, e.g., imagePoints, one must effectively copy it into a new array: imagePoints =
  2902. * np.ascontiguousarray(D[:,:2]).reshape((N,1,2))
  2903. * </li>
  2904. * </ul>
  2905. * <li>
  2906. * The methods REF: SOLVEPNP_DLS and REF: SOLVEPNP_UPNP cannot be used as the current implementations are
  2907. * unstable and sometimes give completely wrong results. If you pass one of these two
  2908. * flags, REF: SOLVEPNP_EPNP method will be used instead.
  2909. * </li>
  2910. * <li>
  2911. * The minimum number of points is 4 in the general case. In the case of REF: SOLVEPNP_P3P and REF: SOLVEPNP_AP3P
  2912. * methods, it is required to use exactly 4 points (the first 3 points are used to estimate all the solutions
  2913. * of the P3P problem, the last one is used to retain the best solution that minimizes the reprojection error).
  2914. * </li>
  2915. * <li>
  2916. * With REF: SOLVEPNP_ITERATIVE method and {code useExtrinsicGuess=true}, the minimum number of points is 3 (3 points
  2917. * are sufficient to compute a pose but there are up to 4 solutions). The initial solution should be close to the
  2918. * global solution to converge.
  2919. * </li>
  2920. * <li>
  2921. * With REF: SOLVEPNP_IPPE input points must be &gt;= 4 and object points must be coplanar.
  2922. * </li>
  2923. * <li>
  2924. * With REF: SOLVEPNP_IPPE_SQUARE this is a special case suitable for marker pose estimation.
  2925. * Number of input points must be 4. Object points must be defined in the following order:
  2926. * <ul>
  2927. * <li>
  2928. * point 0: [-squareLength / 2, squareLength / 2, 0]
  2929. * </li>
  2930. * <li>
  2931. * point 1: [ squareLength / 2, squareLength / 2, 0]
  2932. * </li>
  2933. * <li>
  2934. * point 2: [ squareLength / 2, -squareLength / 2, 0]
  2935. * </li>
  2936. * <li>
  2937. * point 3: [-squareLength / 2, -squareLength / 2, 0]
  2938. * </li>
  2939. * </ul>
  2940. * </li>
  2941. * </ul>
  2942. * return automatically generated
  2943. */
  2944. public static int solvePnPGeneric(Mat objectPoints, Mat imagePoints, Mat cameraMatrix, Mat distCoeffs, List<Mat> rvecs, List<Mat> tvecs, bool useExtrinsicGuess, int flags, Mat rvec, Mat tvec)
  2945. {
  2946. if (objectPoints != null) objectPoints.ThrowIfDisposed();
  2947. if (imagePoints != null) imagePoints.ThrowIfDisposed();
  2948. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  2949. if (distCoeffs != null) distCoeffs.ThrowIfDisposed();
  2950. if (rvec != null) rvec.ThrowIfDisposed();
  2951. if (tvec != null) tvec.ThrowIfDisposed();
  2952. Mat rvecs_mat = new Mat();
  2953. Mat tvecs_mat = new Mat();
  2954. int retVal = calib3d_Calib3d_solvePnPGeneric_11(objectPoints.nativeObj, imagePoints.nativeObj, cameraMatrix.nativeObj, distCoeffs.nativeObj, rvecs_mat.nativeObj, tvecs_mat.nativeObj, useExtrinsicGuess, flags, rvec.nativeObj, tvec.nativeObj);
  2955. Converters.Mat_to_vector_Mat(rvecs_mat, rvecs);
  2956. rvecs_mat.release();
  2957. Converters.Mat_to_vector_Mat(tvecs_mat, tvecs);
  2958. tvecs_mat.release();
  2959. return retVal;
  2960. }
  2961. /**
  2962. * Finds an object pose from 3D-2D point correspondences.
  2963. *
  2964. * SEE: REF: calib3d_solvePnP
  2965. *
  2966. * This function returns a list of all the possible solutions (a solution is a &lt;rotation vector, translation vector&gt;
  2967. * couple), depending on the number of input points and the chosen method:
  2968. * <ul>
  2969. * <li>
  2970. * P3P methods (REF: SOLVEPNP_P3P, REF: SOLVEPNP_AP3P): 3 or 4 input points. Number of returned solutions can be between 0 and 4 with 3 input points.
  2971. * </li>
  2972. * <li>
  2973. * REF: SOLVEPNP_IPPE Input points must be &gt;= 4 and object points must be coplanar. Returns 2 solutions.
  2974. * </li>
  2975. * <li>
  2976. * REF: SOLVEPNP_IPPE_SQUARE Special case suitable for marker pose estimation.
  2977. * Number of input points must be 4 and 2 solutions are returned. Object points must be defined in the following order:
  2978. * <ul>
  2979. * <li>
  2980. * point 0: [-squareLength / 2, squareLength / 2, 0]
  2981. * </li>
  2982. * <li>
  2983. * point 1: [ squareLength / 2, squareLength / 2, 0]
  2984. * </li>
  2985. * <li>
  2986. * point 2: [ squareLength / 2, -squareLength / 2, 0]
  2987. * </li>
  2988. * <li>
  2989. * point 3: [-squareLength / 2, -squareLength / 2, 0]
  2990. * </li>
  2991. * </ul>
  2992. * <li>
  2993. * for all the other flags, number of input points must be &gt;= 4 and object points can be in any configuration.
  2994. * Only 1 solution is returned.
  2995. * </li>
  2996. * </ul>
  2997. *
  2998. * param objectPoints Array of object points in the object coordinate space, Nx3 1-channel or
  2999. * 1xN/Nx1 3-channel, where N is the number of points. vector&lt;Point3d&gt; can be also passed here.
  3000. * param imagePoints Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
  3001. * where N is the number of points. vector&lt;Point2d&gt; can be also passed here.
  3002. * param cameraMatrix Input camera intrinsic matrix \(\cameramatrix{A}\) .
  3003. * param distCoeffs Input vector of distortion coefficients
  3004. * \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
  3005. * assumed.
  3006. * param rvecs Vector of output rotation vectors (see REF: Rodrigues ) that, together with tvecs, brings points from
  3007. * the model coordinate system to the camera coordinate system.
  3008. * param tvecs Vector of output translation vectors.
  3009. * param useExtrinsicGuess Parameter used for #SOLVEPNP_ITERATIVE. If true (1), the function uses
  3010. * the provided rvec and tvec values as initial approximations of the rotation and translation
  3011. * vectors, respectively, and further optimizes them.
  3012. * param flags Method for solving a PnP problem: see REF: calib3d_solvePnP_flags
  3013. * param rvec Rotation vector used to initialize an iterative PnP refinement algorithm, when flag is REF: SOLVEPNP_ITERATIVE
  3014. * and useExtrinsicGuess is set to true.
  3015. * and useExtrinsicGuess is set to true.
  3016. * (\( \text{RMSE} = \sqrt{\frac{\sum_{i}^{N} \left ( \hat{y_i} - y_i \right )^2}{N}} \)) between the input image points
  3017. * and the 3D object points projected with the estimated pose.
  3018. *
  3019. * More information is described in REF: calib3d_solvePnP
  3020. *
  3021. * <b>Note:</b>
  3022. * <ul>
  3023. * <li>
  3024. * An example of how to use solvePnP for planar augmented reality can be found at
  3025. * opencv_source_code/samples/python/plane_ar.py
  3026. * </li>
  3027. * <li>
  3028. * If you are using Python:
  3029. * <ul>
  3030. * <li>
  3031. * Numpy array slices won't work as input because solvePnP requires contiguous
  3032. * arrays (enforced by the assertion using cv::Mat::checkVector() around line 55 of
  3033. * modules/calib3d/src/solvepnp.cpp version 2.4.9)
  3034. * </li>
  3035. * <li>
  3036. * The P3P algorithm requires image points to be in an array of shape (N,1,2) due
  3037. * to its calling of #undistortPoints (around line 75 of modules/calib3d/src/solvepnp.cpp version 2.4.9)
  3038. * which requires 2-channel information.
  3039. * </li>
  3040. * <li>
  3041. * Thus, given some data D = np.array(...) where D.shape = (N,M), in order to use a subset of
  3042. * it as, e.g., imagePoints, one must effectively copy it into a new array: imagePoints =
  3043. * np.ascontiguousarray(D[:,:2]).reshape((N,1,2))
  3044. * </li>
  3045. * </ul>
  3046. * <li>
  3047. * The methods REF: SOLVEPNP_DLS and REF: SOLVEPNP_UPNP cannot be used as the current implementations are
  3048. * unstable and sometimes give completely wrong results. If you pass one of these two
  3049. * flags, REF: SOLVEPNP_EPNP method will be used instead.
  3050. * </li>
  3051. * <li>
  3052. * The minimum number of points is 4 in the general case. In the case of REF: SOLVEPNP_P3P and REF: SOLVEPNP_AP3P
  3053. * methods, it is required to use exactly 4 points (the first 3 points are used to estimate all the solutions
  3054. * of the P3P problem, the last one is used to retain the best solution that minimizes the reprojection error).
  3055. * </li>
  3056. * <li>
  3057. * With REF: SOLVEPNP_ITERATIVE method and {code useExtrinsicGuess=true}, the minimum number of points is 3 (3 points
  3058. * are sufficient to compute a pose but there are up to 4 solutions). The initial solution should be close to the
  3059. * global solution to converge.
  3060. * </li>
  3061. * <li>
  3062. * With REF: SOLVEPNP_IPPE input points must be &gt;= 4 and object points must be coplanar.
  3063. * </li>
  3064. * <li>
  3065. * With REF: SOLVEPNP_IPPE_SQUARE this is a special case suitable for marker pose estimation.
  3066. * Number of input points must be 4. Object points must be defined in the following order:
  3067. * <ul>
  3068. * <li>
  3069. * point 0: [-squareLength / 2, squareLength / 2, 0]
  3070. * </li>
  3071. * <li>
  3072. * point 1: [ squareLength / 2, squareLength / 2, 0]
  3073. * </li>
  3074. * <li>
  3075. * point 2: [ squareLength / 2, -squareLength / 2, 0]
  3076. * </li>
  3077. * <li>
  3078. * point 3: [-squareLength / 2, -squareLength / 2, 0]
  3079. * </li>
  3080. * </ul>
  3081. * </li>
  3082. * </ul>
  3083. * return automatically generated
  3084. */
  3085. public static int solvePnPGeneric(Mat objectPoints, Mat imagePoints, Mat cameraMatrix, Mat distCoeffs, List<Mat> rvecs, List<Mat> tvecs, bool useExtrinsicGuess, int flags, Mat rvec)
  3086. {
  3087. if (objectPoints != null) objectPoints.ThrowIfDisposed();
  3088. if (imagePoints != null) imagePoints.ThrowIfDisposed();
  3089. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  3090. if (distCoeffs != null) distCoeffs.ThrowIfDisposed();
  3091. if (rvec != null) rvec.ThrowIfDisposed();
  3092. Mat rvecs_mat = new Mat();
  3093. Mat tvecs_mat = new Mat();
  3094. int retVal = calib3d_Calib3d_solvePnPGeneric_12(objectPoints.nativeObj, imagePoints.nativeObj, cameraMatrix.nativeObj, distCoeffs.nativeObj, rvecs_mat.nativeObj, tvecs_mat.nativeObj, useExtrinsicGuess, flags, rvec.nativeObj);
  3095. Converters.Mat_to_vector_Mat(rvecs_mat, rvecs);
  3096. rvecs_mat.release();
  3097. Converters.Mat_to_vector_Mat(tvecs_mat, tvecs);
  3098. tvecs_mat.release();
  3099. return retVal;
  3100. }
  3101. /**
  3102. * Finds an object pose from 3D-2D point correspondences.
  3103. *
  3104. * SEE: REF: calib3d_solvePnP
  3105. *
  3106. * This function returns a list of all the possible solutions (a solution is a &lt;rotation vector, translation vector&gt;
  3107. * couple), depending on the number of input points and the chosen method:
  3108. * <ul>
  3109. * <li>
  3110. * P3P methods (REF: SOLVEPNP_P3P, REF: SOLVEPNP_AP3P): 3 or 4 input points. Number of returned solutions can be between 0 and 4 with 3 input points.
  3111. * </li>
  3112. * <li>
  3113. * REF: SOLVEPNP_IPPE Input points must be &gt;= 4 and object points must be coplanar. Returns 2 solutions.
  3114. * </li>
  3115. * <li>
  3116. * REF: SOLVEPNP_IPPE_SQUARE Special case suitable for marker pose estimation.
  3117. * Number of input points must be 4 and 2 solutions are returned. Object points must be defined in the following order:
  3118. * <ul>
  3119. * <li>
  3120. * point 0: [-squareLength / 2, squareLength / 2, 0]
  3121. * </li>
  3122. * <li>
  3123. * point 1: [ squareLength / 2, squareLength / 2, 0]
  3124. * </li>
  3125. * <li>
  3126. * point 2: [ squareLength / 2, -squareLength / 2, 0]
  3127. * </li>
  3128. * <li>
  3129. * point 3: [-squareLength / 2, -squareLength / 2, 0]
  3130. * </li>
  3131. * </ul>
  3132. * <li>
  3133. * for all the other flags, number of input points must be &gt;= 4 and object points can be in any configuration.
  3134. * Only 1 solution is returned.
  3135. * </li>
  3136. * </ul>
  3137. *
  3138. * param objectPoints Array of object points in the object coordinate space, Nx3 1-channel or
  3139. * 1xN/Nx1 3-channel, where N is the number of points. vector&lt;Point3d&gt; can be also passed here.
  3140. * param imagePoints Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
  3141. * where N is the number of points. vector&lt;Point2d&gt; can be also passed here.
  3142. * param cameraMatrix Input camera intrinsic matrix \(\cameramatrix{A}\) .
  3143. * param distCoeffs Input vector of distortion coefficients
  3144. * \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
  3145. * assumed.
  3146. * param rvecs Vector of output rotation vectors (see REF: Rodrigues ) that, together with tvecs, brings points from
  3147. * the model coordinate system to the camera coordinate system.
  3148. * param tvecs Vector of output translation vectors.
  3149. * param useExtrinsicGuess Parameter used for #SOLVEPNP_ITERATIVE. If true (1), the function uses
  3150. * the provided rvec and tvec values as initial approximations of the rotation and translation
  3151. * vectors, respectively, and further optimizes them.
  3152. * param flags Method for solving a PnP problem: see REF: calib3d_solvePnP_flags
  3153. * and useExtrinsicGuess is set to true.
  3154. * and useExtrinsicGuess is set to true.
  3155. * (\( \text{RMSE} = \sqrt{\frac{\sum_{i}^{N} \left ( \hat{y_i} - y_i \right )^2}{N}} \)) between the input image points
  3156. * and the 3D object points projected with the estimated pose.
  3157. *
  3158. * More information is described in REF: calib3d_solvePnP
  3159. *
  3160. * <b>Note:</b>
  3161. * <ul>
  3162. * <li>
  3163. * An example of how to use solvePnP for planar augmented reality can be found at
  3164. * opencv_source_code/samples/python/plane_ar.py
  3165. * </li>
  3166. * <li>
  3167. * If you are using Python:
  3168. * <ul>
  3169. * <li>
  3170. * Numpy array slices won't work as input because solvePnP requires contiguous
  3171. * arrays (enforced by the assertion using cv::Mat::checkVector() around line 55 of
  3172. * modules/calib3d/src/solvepnp.cpp version 2.4.9)
  3173. * </li>
  3174. * <li>
  3175. * The P3P algorithm requires image points to be in an array of shape (N,1,2) due
  3176. * to its calling of #undistortPoints (around line 75 of modules/calib3d/src/solvepnp.cpp version 2.4.9)
  3177. * which requires 2-channel information.
  3178. * </li>
  3179. * <li>
  3180. * Thus, given some data D = np.array(...) where D.shape = (N,M), in order to use a subset of
  3181. * it as, e.g., imagePoints, one must effectively copy it into a new array: imagePoints =
  3182. * np.ascontiguousarray(D[:,:2]).reshape((N,1,2))
  3183. * </li>
  3184. * </ul>
  3185. * <li>
  3186. * The methods REF: SOLVEPNP_DLS and REF: SOLVEPNP_UPNP cannot be used as the current implementations are
  3187. * unstable and sometimes give completely wrong results. If you pass one of these two
  3188. * flags, REF: SOLVEPNP_EPNP method will be used instead.
  3189. * </li>
  3190. * <li>
  3191. * The minimum number of points is 4 in the general case. In the case of REF: SOLVEPNP_P3P and REF: SOLVEPNP_AP3P
  3192. * methods, it is required to use exactly 4 points (the first 3 points are used to estimate all the solutions
  3193. * of the P3P problem, the last one is used to retain the best solution that minimizes the reprojection error).
  3194. * </li>
  3195. * <li>
  3196. * With REF: SOLVEPNP_ITERATIVE method and {code useExtrinsicGuess=true}, the minimum number of points is 3 (3 points
  3197. * are sufficient to compute a pose but there are up to 4 solutions). The initial solution should be close to the
  3198. * global solution to converge.
  3199. * </li>
  3200. * <li>
  3201. * With REF: SOLVEPNP_IPPE input points must be &gt;= 4 and object points must be coplanar.
  3202. * </li>
  3203. * <li>
  3204. * With REF: SOLVEPNP_IPPE_SQUARE this is a special case suitable for marker pose estimation.
  3205. * Number of input points must be 4. Object points must be defined in the following order:
  3206. * <ul>
  3207. * <li>
  3208. * point 0: [-squareLength / 2, squareLength / 2, 0]
  3209. * </li>
  3210. * <li>
  3211. * point 1: [ squareLength / 2, squareLength / 2, 0]
  3212. * </li>
  3213. * <li>
  3214. * point 2: [ squareLength / 2, -squareLength / 2, 0]
  3215. * </li>
  3216. * <li>
  3217. * point 3: [-squareLength / 2, -squareLength / 2, 0]
  3218. * </li>
  3219. * </ul>
  3220. * </li>
  3221. * </ul>
  3222. * return automatically generated
  3223. */
  3224. public static int solvePnPGeneric(Mat objectPoints, Mat imagePoints, Mat cameraMatrix, Mat distCoeffs, List<Mat> rvecs, List<Mat> tvecs, bool useExtrinsicGuess, int flags)
  3225. {
  3226. if (objectPoints != null) objectPoints.ThrowIfDisposed();
  3227. if (imagePoints != null) imagePoints.ThrowIfDisposed();
  3228. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  3229. if (distCoeffs != null) distCoeffs.ThrowIfDisposed();
  3230. Mat rvecs_mat = new Mat();
  3231. Mat tvecs_mat = new Mat();
  3232. int retVal = calib3d_Calib3d_solvePnPGeneric_13(objectPoints.nativeObj, imagePoints.nativeObj, cameraMatrix.nativeObj, distCoeffs.nativeObj, rvecs_mat.nativeObj, tvecs_mat.nativeObj, useExtrinsicGuess, flags);
  3233. Converters.Mat_to_vector_Mat(rvecs_mat, rvecs);
  3234. rvecs_mat.release();
  3235. Converters.Mat_to_vector_Mat(tvecs_mat, tvecs);
  3236. tvecs_mat.release();
  3237. return retVal;
  3238. }
  3239. /**
  3240. * Finds an object pose from 3D-2D point correspondences.
  3241. *
  3242. * SEE: REF: calib3d_solvePnP
  3243. *
  3244. * This function returns a list of all the possible solutions (a solution is a &lt;rotation vector, translation vector&gt;
  3245. * couple), depending on the number of input points and the chosen method:
  3246. * <ul>
  3247. * <li>
  3248. * P3P methods (REF: SOLVEPNP_P3P, REF: SOLVEPNP_AP3P): 3 or 4 input points. Number of returned solutions can be between 0 and 4 with 3 input points.
  3249. * </li>
  3250. * <li>
  3251. * REF: SOLVEPNP_IPPE Input points must be &gt;= 4 and object points must be coplanar. Returns 2 solutions.
  3252. * </li>
  3253. * <li>
  3254. * REF: SOLVEPNP_IPPE_SQUARE Special case suitable for marker pose estimation.
  3255. * Number of input points must be 4 and 2 solutions are returned. Object points must be defined in the following order:
  3256. * <ul>
  3257. * <li>
  3258. * point 0: [-squareLength / 2, squareLength / 2, 0]
  3259. * </li>
  3260. * <li>
  3261. * point 1: [ squareLength / 2, squareLength / 2, 0]
  3262. * </li>
  3263. * <li>
  3264. * point 2: [ squareLength / 2, -squareLength / 2, 0]
  3265. * </li>
  3266. * <li>
  3267. * point 3: [-squareLength / 2, -squareLength / 2, 0]
  3268. * </li>
  3269. * </ul>
  3270. * <li>
  3271. * for all the other flags, number of input points must be &gt;= 4 and object points can be in any configuration.
  3272. * Only 1 solution is returned.
  3273. * </li>
  3274. * </ul>
  3275. *
  3276. * param objectPoints Array of object points in the object coordinate space, Nx3 1-channel or
  3277. * 1xN/Nx1 3-channel, where N is the number of points. vector&lt;Point3d&gt; can be also passed here.
  3278. * param imagePoints Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
  3279. * where N is the number of points. vector&lt;Point2d&gt; can be also passed here.
  3280. * param cameraMatrix Input camera intrinsic matrix \(\cameramatrix{A}\) .
  3281. * param distCoeffs Input vector of distortion coefficients
  3282. * \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
  3283. * assumed.
  3284. * param rvecs Vector of output rotation vectors (see REF: Rodrigues ) that, together with tvecs, brings points from
  3285. * the model coordinate system to the camera coordinate system.
  3286. * param tvecs Vector of output translation vectors.
  3287. * param useExtrinsicGuess Parameter used for #SOLVEPNP_ITERATIVE. If true (1), the function uses
  3288. * the provided rvec and tvec values as initial approximations of the rotation and translation
  3289. * vectors, respectively, and further optimizes them.
  3290. * and useExtrinsicGuess is set to true.
  3291. * and useExtrinsicGuess is set to true.
  3292. * (\( \text{RMSE} = \sqrt{\frac{\sum_{i}^{N} \left ( \hat{y_i} - y_i \right )^2}{N}} \)) between the input image points
  3293. * and the 3D object points projected with the estimated pose.
  3294. *
  3295. * More information is described in REF: calib3d_solvePnP
  3296. *
  3297. * <b>Note:</b>
  3298. * <ul>
  3299. * <li>
  3300. * An example of how to use solvePnP for planar augmented reality can be found at
  3301. * opencv_source_code/samples/python/plane_ar.py
  3302. * </li>
  3303. * <li>
  3304. * If you are using Python:
  3305. * <ul>
  3306. * <li>
  3307. * Numpy array slices won't work as input because solvePnP requires contiguous
  3308. * arrays (enforced by the assertion using cv::Mat::checkVector() around line 55 of
  3309. * modules/calib3d/src/solvepnp.cpp version 2.4.9)
  3310. * </li>
  3311. * <li>
  3312. * The P3P algorithm requires image points to be in an array of shape (N,1,2) due
  3313. * to its calling of #undistortPoints (around line 75 of modules/calib3d/src/solvepnp.cpp version 2.4.9)
  3314. * which requires 2-channel information.
  3315. * </li>
  3316. * <li>
  3317. * Thus, given some data D = np.array(...) where D.shape = (N,M), in order to use a subset of
  3318. * it as, e.g., imagePoints, one must effectively copy it into a new array: imagePoints =
  3319. * np.ascontiguousarray(D[:,:2]).reshape((N,1,2))
  3320. * </li>
  3321. * </ul>
  3322. * <li>
  3323. * The methods REF: SOLVEPNP_DLS and REF: SOLVEPNP_UPNP cannot be used as the current implementations are
  3324. * unstable and sometimes give completely wrong results. If you pass one of these two
  3325. * flags, REF: SOLVEPNP_EPNP method will be used instead.
  3326. * </li>
  3327. * <li>
  3328. * The minimum number of points is 4 in the general case. In the case of REF: SOLVEPNP_P3P and REF: SOLVEPNP_AP3P
  3329. * methods, it is required to use exactly 4 points (the first 3 points are used to estimate all the solutions
  3330. * of the P3P problem, the last one is used to retain the best solution that minimizes the reprojection error).
  3331. * </li>
  3332. * <li>
  3333. * With REF: SOLVEPNP_ITERATIVE method and {code useExtrinsicGuess=true}, the minimum number of points is 3 (3 points
  3334. * are sufficient to compute a pose but there are up to 4 solutions). The initial solution should be close to the
  3335. * global solution to converge.
  3336. * </li>
  3337. * <li>
  3338. * With REF: SOLVEPNP_IPPE input points must be &gt;= 4 and object points must be coplanar.
  3339. * </li>
  3340. * <li>
  3341. * With REF: SOLVEPNP_IPPE_SQUARE this is a special case suitable for marker pose estimation.
  3342. * Number of input points must be 4. Object points must be defined in the following order:
  3343. * <ul>
  3344. * <li>
  3345. * point 0: [-squareLength / 2, squareLength / 2, 0]
  3346. * </li>
  3347. * <li>
  3348. * point 1: [ squareLength / 2, squareLength / 2, 0]
  3349. * </li>
  3350. * <li>
  3351. * point 2: [ squareLength / 2, -squareLength / 2, 0]
  3352. * </li>
  3353. * <li>
  3354. * point 3: [-squareLength / 2, -squareLength / 2, 0]
  3355. * </li>
  3356. * </ul>
  3357. * </li>
  3358. * </ul>
  3359. * return automatically generated
  3360. */
  3361. public static int solvePnPGeneric(Mat objectPoints, Mat imagePoints, Mat cameraMatrix, Mat distCoeffs, List<Mat> rvecs, List<Mat> tvecs, bool useExtrinsicGuess)
  3362. {
  3363. if (objectPoints != null) objectPoints.ThrowIfDisposed();
  3364. if (imagePoints != null) imagePoints.ThrowIfDisposed();
  3365. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  3366. if (distCoeffs != null) distCoeffs.ThrowIfDisposed();
  3367. Mat rvecs_mat = new Mat();
  3368. Mat tvecs_mat = new Mat();
  3369. int retVal = calib3d_Calib3d_solvePnPGeneric_14(objectPoints.nativeObj, imagePoints.nativeObj, cameraMatrix.nativeObj, distCoeffs.nativeObj, rvecs_mat.nativeObj, tvecs_mat.nativeObj, useExtrinsicGuess);
  3370. Converters.Mat_to_vector_Mat(rvecs_mat, rvecs);
  3371. rvecs_mat.release();
  3372. Converters.Mat_to_vector_Mat(tvecs_mat, tvecs);
  3373. tvecs_mat.release();
  3374. return retVal;
  3375. }
  3376. /**
  3377. * Finds an object pose from 3D-2D point correspondences.
  3378. *
  3379. * SEE: REF: calib3d_solvePnP
  3380. *
  3381. * This function returns a list of all the possible solutions (a solution is a &lt;rotation vector, translation vector&gt;
  3382. * couple), depending on the number of input points and the chosen method:
  3383. * <ul>
  3384. * <li>
  3385. * P3P methods (REF: SOLVEPNP_P3P, REF: SOLVEPNP_AP3P): 3 or 4 input points. Number of returned solutions can be between 0 and 4 with 3 input points.
  3386. * </li>
  3387. * <li>
  3388. * REF: SOLVEPNP_IPPE Input points must be &gt;= 4 and object points must be coplanar. Returns 2 solutions.
  3389. * </li>
  3390. * <li>
  3391. * REF: SOLVEPNP_IPPE_SQUARE Special case suitable for marker pose estimation.
  3392. * Number of input points must be 4 and 2 solutions are returned. Object points must be defined in the following order:
  3393. * <ul>
  3394. * <li>
  3395. * point 0: [-squareLength / 2, squareLength / 2, 0]
  3396. * </li>
  3397. * <li>
  3398. * point 1: [ squareLength / 2, squareLength / 2, 0]
  3399. * </li>
  3400. * <li>
  3401. * point 2: [ squareLength / 2, -squareLength / 2, 0]
  3402. * </li>
  3403. * <li>
  3404. * point 3: [-squareLength / 2, -squareLength / 2, 0]
  3405. * </li>
  3406. * </ul>
  3407. * <li>
  3408. * for all the other flags, number of input points must be &gt;= 4 and object points can be in any configuration.
  3409. * Only 1 solution is returned.
  3410. * </li>
  3411. * </ul>
  3412. *
  3413. * param objectPoints Array of object points in the object coordinate space, Nx3 1-channel or
  3414. * 1xN/Nx1 3-channel, where N is the number of points. vector&lt;Point3d&gt; can be also passed here.
  3415. * param imagePoints Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
  3416. * where N is the number of points. vector&lt;Point2d&gt; can be also passed here.
  3417. * param cameraMatrix Input camera intrinsic matrix \(\cameramatrix{A}\) .
  3418. * param distCoeffs Input vector of distortion coefficients
  3419. * \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
  3420. * assumed.
  3421. * param rvecs Vector of output rotation vectors (see REF: Rodrigues ) that, together with tvecs, brings points from
  3422. * the model coordinate system to the camera coordinate system.
  3423. * param tvecs Vector of output translation vectors.
  3424. * the provided rvec and tvec values as initial approximations of the rotation and translation
  3425. * vectors, respectively, and further optimizes them.
  3426. * and useExtrinsicGuess is set to true.
  3427. * and useExtrinsicGuess is set to true.
  3428. * (\( \text{RMSE} = \sqrt{\frac{\sum_{i}^{N} \left ( \hat{y_i} - y_i \right )^2}{N}} \)) between the input image points
  3429. * and the 3D object points projected with the estimated pose.
  3430. *
  3431. * More information is described in REF: calib3d_solvePnP
  3432. *
  3433. * <b>Note:</b>
  3434. * <ul>
  3435. * <li>
  3436. * An example of how to use solvePnP for planar augmented reality can be found at
  3437. * opencv_source_code/samples/python/plane_ar.py
  3438. * </li>
  3439. * <li>
  3440. * If you are using Python:
  3441. * <ul>
  3442. * <li>
  3443. * Numpy array slices won't work as input because solvePnP requires contiguous
  3444. * arrays (enforced by the assertion using cv::Mat::checkVector() around line 55 of
  3445. * modules/calib3d/src/solvepnp.cpp version 2.4.9)
  3446. * </li>
  3447. * <li>
  3448. * The P3P algorithm requires image points to be in an array of shape (N,1,2) due
  3449. * to its calling of #undistortPoints (around line 75 of modules/calib3d/src/solvepnp.cpp version 2.4.9)
  3450. * which requires 2-channel information.
  3451. * </li>
  3452. * <li>
  3453. * Thus, given some data D = np.array(...) where D.shape = (N,M), in order to use a subset of
  3454. * it as, e.g., imagePoints, one must effectively copy it into a new array: imagePoints =
  3455. * np.ascontiguousarray(D[:,:2]).reshape((N,1,2))
  3456. * </li>
  3457. * </ul>
  3458. * <li>
  3459. * The methods REF: SOLVEPNP_DLS and REF: SOLVEPNP_UPNP cannot be used as the current implementations are
  3460. * unstable and sometimes give completely wrong results. If you pass one of these two
  3461. * flags, REF: SOLVEPNP_EPNP method will be used instead.
  3462. * </li>
  3463. * <li>
  3464. * The minimum number of points is 4 in the general case. In the case of REF: SOLVEPNP_P3P and REF: SOLVEPNP_AP3P
  3465. * methods, it is required to use exactly 4 points (the first 3 points are used to estimate all the solutions
  3466. * of the P3P problem, the last one is used to retain the best solution that minimizes the reprojection error).
  3467. * </li>
  3468. * <li>
  3469. * With REF: SOLVEPNP_ITERATIVE method and {code useExtrinsicGuess=true}, the minimum number of points is 3 (3 points
  3470. * are sufficient to compute a pose but there are up to 4 solutions). The initial solution should be close to the
  3471. * global solution to converge.
  3472. * </li>
  3473. * <li>
  3474. * With REF: SOLVEPNP_IPPE input points must be &gt;= 4 and object points must be coplanar.
  3475. * </li>
  3476. * <li>
  3477. * With REF: SOLVEPNP_IPPE_SQUARE this is a special case suitable for marker pose estimation.
  3478. * Number of input points must be 4. Object points must be defined in the following order:
  3479. * <ul>
  3480. * <li>
  3481. * point 0: [-squareLength / 2, squareLength / 2, 0]
  3482. * </li>
  3483. * <li>
  3484. * point 1: [ squareLength / 2, squareLength / 2, 0]
  3485. * </li>
  3486. * <li>
  3487. * point 2: [ squareLength / 2, -squareLength / 2, 0]
  3488. * </li>
  3489. * <li>
  3490. * point 3: [-squareLength / 2, -squareLength / 2, 0]
  3491. * </li>
  3492. * </ul>
  3493. * </li>
  3494. * </ul>
  3495. * return automatically generated
  3496. */
  3497. public static int solvePnPGeneric(Mat objectPoints, Mat imagePoints, Mat cameraMatrix, Mat distCoeffs, List<Mat> rvecs, List<Mat> tvecs)
  3498. {
  3499. if (objectPoints != null) objectPoints.ThrowIfDisposed();
  3500. if (imagePoints != null) imagePoints.ThrowIfDisposed();
  3501. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  3502. if (distCoeffs != null) distCoeffs.ThrowIfDisposed();
  3503. Mat rvecs_mat = new Mat();
  3504. Mat tvecs_mat = new Mat();
  3505. int retVal = calib3d_Calib3d_solvePnPGeneric_15(objectPoints.nativeObj, imagePoints.nativeObj, cameraMatrix.nativeObj, distCoeffs.nativeObj, rvecs_mat.nativeObj, tvecs_mat.nativeObj);
  3506. Converters.Mat_to_vector_Mat(rvecs_mat, rvecs);
  3507. rvecs_mat.release();
  3508. Converters.Mat_to_vector_Mat(tvecs_mat, tvecs);
  3509. tvecs_mat.release();
  3510. return retVal;
  3511. }
  3512. //
  3513. // C++: Mat cv::initCameraMatrix2D(vector_vector_Point3f objectPoints, vector_vector_Point2f imagePoints, Size imageSize, double aspectRatio = 1.0)
  3514. //
  3515. /**
  3516. * Finds an initial camera intrinsic matrix from 3D-2D point correspondences.
  3517. *
  3518. * param objectPoints Vector of vectors of the calibration pattern points in the calibration pattern
  3519. * coordinate space. In the old interface all the per-view vectors are concatenated. See
  3520. * #calibrateCamera for details.
  3521. * param imagePoints Vector of vectors of the projections of the calibration pattern points. In the
  3522. * old interface all the per-view vectors are concatenated.
  3523. * param imageSize Image size in pixels used to initialize the principal point.
  3524. * param aspectRatio If it is zero or negative, both \(f_x\) and \(f_y\) are estimated independently.
  3525. * Otherwise, \(f_x = f_y \cdot \texttt{aspectRatio}\) .
  3526. *
  3527. * The function estimates and returns an initial camera intrinsic matrix for the camera calibration process.
  3528. * Currently, the function only supports planar calibration patterns, which are patterns where each
  3529. * object point has z-coordinate =0.
  3530. * return automatically generated
  3531. */
  3532. public static Mat initCameraMatrix2D(List<MatOfPoint3f> objectPoints, List<MatOfPoint2f> imagePoints, Size imageSize, double aspectRatio)
  3533. {
  3534. List<Mat> objectPoints_tmplm = new List<Mat>((objectPoints != null) ? objectPoints.Count : 0);
  3535. Mat objectPoints_mat = Converters.vector_vector_Point3f_to_Mat(objectPoints, objectPoints_tmplm);
  3536. List<Mat> imagePoints_tmplm = new List<Mat>((imagePoints != null) ? imagePoints.Count : 0);
  3537. Mat imagePoints_mat = Converters.vector_vector_Point2f_to_Mat(imagePoints, imagePoints_tmplm);
  3538. return new Mat(DisposableObject.ThrowIfNullIntPtr(calib3d_Calib3d_initCameraMatrix2D_10(objectPoints_mat.nativeObj, imagePoints_mat.nativeObj, imageSize.width, imageSize.height, aspectRatio)));
  3539. }
  3540. /**
  3541. * Finds an initial camera intrinsic matrix from 3D-2D point correspondences.
  3542. *
  3543. * param objectPoints Vector of vectors of the calibration pattern points in the calibration pattern
  3544. * coordinate space. In the old interface all the per-view vectors are concatenated. See
  3545. * #calibrateCamera for details.
  3546. * param imagePoints Vector of vectors of the projections of the calibration pattern points. In the
  3547. * old interface all the per-view vectors are concatenated.
  3548. * param imageSize Image size in pixels used to initialize the principal point.
  3549. * Otherwise, \(f_x = f_y \cdot \texttt{aspectRatio}\) .
  3550. *
  3551. * The function estimates and returns an initial camera intrinsic matrix for the camera calibration process.
  3552. * Currently, the function only supports planar calibration patterns, which are patterns where each
  3553. * object point has z-coordinate =0.
  3554. * return automatically generated
  3555. */
  3556. public static Mat initCameraMatrix2D(List<MatOfPoint3f> objectPoints, List<MatOfPoint2f> imagePoints, Size imageSize)
  3557. {
  3558. List<Mat> objectPoints_tmplm = new List<Mat>((objectPoints != null) ? objectPoints.Count : 0);
  3559. Mat objectPoints_mat = Converters.vector_vector_Point3f_to_Mat(objectPoints, objectPoints_tmplm);
  3560. List<Mat> imagePoints_tmplm = new List<Mat>((imagePoints != null) ? imagePoints.Count : 0);
  3561. Mat imagePoints_mat = Converters.vector_vector_Point2f_to_Mat(imagePoints, imagePoints_tmplm);
  3562. return new Mat(DisposableObject.ThrowIfNullIntPtr(calib3d_Calib3d_initCameraMatrix2D_11(objectPoints_mat.nativeObj, imagePoints_mat.nativeObj, imageSize.width, imageSize.height)));
  3563. }
  3564. //
  3565. // C++: bool cv::findChessboardCorners(Mat image, Size patternSize, vector_Point2f& corners, int flags = CALIB_CB_ADAPTIVE_THRESH + CALIB_CB_NORMALIZE_IMAGE)
  3566. //
  3567. /**
  3568. * Finds the positions of internal corners of the chessboard.
  3569. *
  3570. * param image Source chessboard view. It must be an 8-bit grayscale or color image.
  3571. * param patternSize Number of inner corners per a chessboard row and column
  3572. * ( patternSize = cv::Size(points_per_row,points_per_colum) = cv::Size(columns,rows) ).
  3573. * param corners Output array of detected corners.
  3574. * param flags Various operation flags that can be zero or a combination of the following values:
  3575. * <ul>
  3576. * <li>
  3577. * REF: CALIB_CB_ADAPTIVE_THRESH Use adaptive thresholding to convert the image to black
  3578. * and white, rather than a fixed threshold level (computed from the average image brightness).
  3579. * </li>
  3580. * <li>
  3581. * REF: CALIB_CB_NORMALIZE_IMAGE Normalize the image gamma with #equalizeHist before
  3582. * applying fixed or adaptive thresholding.
  3583. * </li>
  3584. * <li>
  3585. * REF: CALIB_CB_FILTER_QUADS Use additional criteria (like contour area, perimeter,
  3586. * square-like shape) to filter out false quads extracted at the contour retrieval stage.
  3587. * </li>
  3588. * <li>
  3589. * REF: CALIB_CB_FAST_CHECK Run a fast check on the image that looks for chessboard corners,
  3590. * and shortcut the call if none is found. This can drastically speed up the call in the
  3591. * degenerate condition when no chessboard is observed.
  3592. * </li>
  3593. * </ul>
  3594. *
  3595. * The function attempts to determine whether the input image is a view of the chessboard pattern and
  3596. * locate the internal chessboard corners. The function returns a non-zero value if all of the corners
  3597. * are found and they are placed in a certain order (row by row, left to right in every row).
  3598. * Otherwise, if the function fails to find all the corners or reorder them, it returns 0. For example,
  3599. * a regular chessboard has 8 x 8 squares and 7 x 7 internal corners, that is, points where the black
  3600. * squares touch each other. The detected coordinates are approximate, and to determine their positions
  3601. * more accurately, the function calls #cornerSubPix. You also may use the function #cornerSubPix with
  3602. * different parameters if returned coordinates are not accurate enough.
  3603. *
  3604. * Sample usage of detecting and drawing chessboard corners: :
  3605. * <code>
  3606. * Size patternsize(8,6); //interior number of corners
  3607. * Mat gray = ....; //source image
  3608. * vector&lt;Point2f&gt; corners; //this will be filled by the detected corners
  3609. *
  3610. * //CALIB_CB_FAST_CHECK saves a lot of time on images
  3611. * //that do not contain any chessboard corners
  3612. * bool patternfound = findChessboardCorners(gray, patternsize, corners,
  3613. * CALIB_CB_ADAPTIVE_THRESH + CALIB_CB_NORMALIZE_IMAGE
  3614. * + CALIB_CB_FAST_CHECK);
  3615. *
  3616. * if(patternfound)
  3617. * cornerSubPix(gray, corners, Size(11, 11), Size(-1, -1),
  3618. * TermCriteria(CV_TERMCRIT_EPS + CV_TERMCRIT_ITER, 30, 0.1));
  3619. *
  3620. * drawChessboardCorners(img, patternsize, Mat(corners), patternfound);
  3621. * </code>
  3622. * <b>Note:</b> The function requires white space (like a square-thick border, the wider the better) around
  3623. * the board to make the detection more robust in various environments. Otherwise, if there is no
  3624. * border and the background is dark, the outer black squares cannot be segmented properly and so the
  3625. * square grouping and ordering algorithm fails.
  3626. *
  3627. * Use gen_pattern.py (REF: tutorial_camera_calibration_pattern) to create checkerboard.
  3628. * return automatically generated
  3629. */
  3630. public static bool findChessboardCorners(Mat image, Size patternSize, MatOfPoint2f corners, int flags)
  3631. {
  3632. if (image != null) image.ThrowIfDisposed();
  3633. if (corners != null) corners.ThrowIfDisposed();
  3634. Mat corners_mat = corners;
  3635. return calib3d_Calib3d_findChessboardCorners_10(image.nativeObj, patternSize.width, patternSize.height, corners_mat.nativeObj, flags);
  3636. }
  3637. /**
  3638. * Finds the positions of internal corners of the chessboard.
  3639. *
  3640. * param image Source chessboard view. It must be an 8-bit grayscale or color image.
  3641. * param patternSize Number of inner corners per a chessboard row and column
  3642. * ( patternSize = cv::Size(points_per_row,points_per_colum) = cv::Size(columns,rows) ).
  3643. * param corners Output array of detected corners.
  3644. * <ul>
  3645. * <li>
  3646. * REF: CALIB_CB_ADAPTIVE_THRESH Use adaptive thresholding to convert the image to black
  3647. * and white, rather than a fixed threshold level (computed from the average image brightness).
  3648. * </li>
  3649. * <li>
  3650. * REF: CALIB_CB_NORMALIZE_IMAGE Normalize the image gamma with #equalizeHist before
  3651. * applying fixed or adaptive thresholding.
  3652. * </li>
  3653. * <li>
  3654. * REF: CALIB_CB_FILTER_QUADS Use additional criteria (like contour area, perimeter,
  3655. * square-like shape) to filter out false quads extracted at the contour retrieval stage.
  3656. * </li>
  3657. * <li>
  3658. * REF: CALIB_CB_FAST_CHECK Run a fast check on the image that looks for chessboard corners,
  3659. * and shortcut the call if none is found. This can drastically speed up the call in the
  3660. * degenerate condition when no chessboard is observed.
  3661. * </li>
  3662. * </ul>
  3663. *
  3664. * The function attempts to determine whether the input image is a view of the chessboard pattern and
  3665. * locate the internal chessboard corners. The function returns a non-zero value if all of the corners
  3666. * are found and they are placed in a certain order (row by row, left to right in every row).
  3667. * Otherwise, if the function fails to find all the corners or reorder them, it returns 0. For example,
  3668. * a regular chessboard has 8 x 8 squares and 7 x 7 internal corners, that is, points where the black
  3669. * squares touch each other. The detected coordinates are approximate, and to determine their positions
  3670. * more accurately, the function calls #cornerSubPix. You also may use the function #cornerSubPix with
  3671. * different parameters if returned coordinates are not accurate enough.
  3672. *
  3673. * Sample usage of detecting and drawing chessboard corners: :
  3674. * <code>
  3675. * Size patternsize(8,6); //interior number of corners
  3676. * Mat gray = ....; //source image
  3677. * vector&lt;Point2f&gt; corners; //this will be filled by the detected corners
  3678. *
  3679. * //CALIB_CB_FAST_CHECK saves a lot of time on images
  3680. * //that do not contain any chessboard corners
  3681. * bool patternfound = findChessboardCorners(gray, patternsize, corners,
  3682. * CALIB_CB_ADAPTIVE_THRESH + CALIB_CB_NORMALIZE_IMAGE
  3683. * + CALIB_CB_FAST_CHECK);
  3684. *
  3685. * if(patternfound)
  3686. * cornerSubPix(gray, corners, Size(11, 11), Size(-1, -1),
  3687. * TermCriteria(CV_TERMCRIT_EPS + CV_TERMCRIT_ITER, 30, 0.1));
  3688. *
  3689. * drawChessboardCorners(img, patternsize, Mat(corners), patternfound);
  3690. * </code>
  3691. * <b>Note:</b> The function requires white space (like a square-thick border, the wider the better) around
  3692. * the board to make the detection more robust in various environments. Otherwise, if there is no
  3693. * border and the background is dark, the outer black squares cannot be segmented properly and so the
  3694. * square grouping and ordering algorithm fails.
  3695. *
  3696. * Use gen_pattern.py (REF: tutorial_camera_calibration_pattern) to create checkerboard.
  3697. * return automatically generated
  3698. */
  3699. public static bool findChessboardCorners(Mat image, Size patternSize, MatOfPoint2f corners)
  3700. {
  3701. if (image != null) image.ThrowIfDisposed();
  3702. if (corners != null) corners.ThrowIfDisposed();
  3703. Mat corners_mat = corners;
  3704. return calib3d_Calib3d_findChessboardCorners_11(image.nativeObj, patternSize.width, patternSize.height, corners_mat.nativeObj);
  3705. }
  3706. //
  3707. // C++: bool cv::checkChessboard(Mat img, Size size)
  3708. //
  3709. public static bool checkChessboard(Mat img, Size size)
  3710. {
  3711. if (img != null) img.ThrowIfDisposed();
  3712. return calib3d_Calib3d_checkChessboard_10(img.nativeObj, size.width, size.height);
  3713. }
  3714. //
  3715. // C++: bool cv::findChessboardCornersSB(Mat image, Size patternSize, Mat& corners, int flags, Mat& meta)
  3716. //
  3717. /**
  3718. * Finds the positions of internal corners of the chessboard using a sector based approach.
  3719. *
  3720. * param image Source chessboard view. It must be an 8-bit grayscale or color image.
  3721. * param patternSize Number of inner corners per a chessboard row and column
  3722. * ( patternSize = cv::Size(points_per_row,points_per_colum) = cv::Size(columns,rows) ).
  3723. * param corners Output array of detected corners.
  3724. * param flags Various operation flags that can be zero or a combination of the following values:
  3725. * <ul>
  3726. * <li>
  3727. * REF: CALIB_CB_NORMALIZE_IMAGE Normalize the image gamma with equalizeHist before detection.
  3728. * </li>
  3729. * <li>
  3730. * REF: CALIB_CB_EXHAUSTIVE Run an exhaustive search to improve detection rate.
  3731. * </li>
  3732. * <li>
  3733. * REF: CALIB_CB_ACCURACY Up sample input image to improve sub-pixel accuracy due to aliasing effects.
  3734. * </li>
  3735. * <li>
  3736. * REF: CALIB_CB_LARGER The detected pattern is allowed to be larger than patternSize (see description).
  3737. * </li>
  3738. * <li>
  3739. * REF: CALIB_CB_MARKER The detected pattern must have a marker (see description).
  3740. * This should be used if an accurate camera calibration is required.
  3741. * </li>
  3742. * </ul>
  3743. * param meta Optional output arrray of detected corners (CV_8UC1 and size = cv::Size(columns,rows)).
  3744. * Each entry stands for one corner of the pattern and can have one of the following values:
  3745. * <ul>
  3746. * <li>
  3747. * 0 = no meta data attached
  3748. * </li>
  3749. * <li>
  3750. * 1 = left-top corner of a black cell
  3751. * </li>
  3752. * <li>
  3753. * 2 = left-top corner of a white cell
  3754. * </li>
  3755. * <li>
  3756. * 3 = left-top corner of a black cell with a white marker dot
  3757. * </li>
  3758. * <li>
  3759. * 4 = left-top corner of a white cell with a black marker dot (pattern origin in case of markers otherwise first corner)
  3760. * </li>
  3761. * </ul>
  3762. *
  3763. * The function is analog to #findChessboardCorners but uses a localized radon
  3764. * transformation approximated by box filters being more robust to all sort of
  3765. * noise, faster on larger images and is able to directly return the sub-pixel
  3766. * position of the internal chessboard corners. The Method is based on the paper
  3767. * CITE: duda2018 "Accurate Detection and Localization of Checkerboard Corners for
  3768. * Calibration" demonstrating that the returned sub-pixel positions are more
  3769. * accurate than the one returned by cornerSubPix allowing a precise camera
  3770. * calibration for demanding applications.
  3771. *
  3772. * In the case, the flags REF: CALIB_CB_LARGER or REF: CALIB_CB_MARKER are given,
  3773. * the result can be recovered from the optional meta array. Both flags are
  3774. * helpful to use calibration patterns exceeding the field of view of the camera.
  3775. * These oversized patterns allow more accurate calibrations as corners can be
  3776. * utilized, which are as close as possible to the image borders. For a
  3777. * consistent coordinate system across all images, the optional marker (see image
  3778. * below) can be used to move the origin of the board to the location where the
  3779. * black circle is located.
  3780. *
  3781. * <b>Note:</b> The function requires a white boarder with roughly the same width as one
  3782. * of the checkerboard fields around the whole board to improve the detection in
  3783. * various environments. In addition, because of the localized radon
  3784. * transformation it is beneficial to use round corners for the field corners
  3785. * which are located on the outside of the board. The following figure illustrates
  3786. * a sample checkerboard optimized for the detection. However, any other checkerboard
  3787. * can be used as well.
  3788. *
  3789. * Use gen_pattern.py (REF: tutorial_camera_calibration_pattern) to create checkerboard.
  3790. * ![Checkerboard](pics/checkerboard_radon.png)
  3791. * return automatically generated
  3792. */
  3793. public static bool findChessboardCornersSBWithMeta(Mat image, Size patternSize, Mat corners, int flags, Mat meta)
  3794. {
  3795. if (image != null) image.ThrowIfDisposed();
  3796. if (corners != null) corners.ThrowIfDisposed();
  3797. if (meta != null) meta.ThrowIfDisposed();
  3798. return calib3d_Calib3d_findChessboardCornersSBWithMeta_10(image.nativeObj, patternSize.width, patternSize.height, corners.nativeObj, flags, meta.nativeObj);
  3799. }
  3800. //
  3801. // C++: bool cv::findChessboardCornersSB(Mat image, Size patternSize, Mat& corners, int flags = 0)
  3802. //
  3803. public static bool findChessboardCornersSB(Mat image, Size patternSize, Mat corners, int flags)
  3804. {
  3805. if (image != null) image.ThrowIfDisposed();
  3806. if (corners != null) corners.ThrowIfDisposed();
  3807. return calib3d_Calib3d_findChessboardCornersSB_10(image.nativeObj, patternSize.width, patternSize.height, corners.nativeObj, flags);
  3808. }
  3809. public static bool findChessboardCornersSB(Mat image, Size patternSize, Mat corners)
  3810. {
  3811. if (image != null) image.ThrowIfDisposed();
  3812. if (corners != null) corners.ThrowIfDisposed();
  3813. return calib3d_Calib3d_findChessboardCornersSB_11(image.nativeObj, patternSize.width, patternSize.height, corners.nativeObj);
  3814. }
  3815. //
  3816. // C++: Scalar cv::estimateChessboardSharpness(Mat image, Size patternSize, Mat corners, float rise_distance = 0.8F, bool vertical = false, Mat& sharpness = Mat())
  3817. //
  3818. /**
  3819. * Estimates the sharpness of a detected chessboard.
  3820. *
  3821. * Image sharpness, as well as brightness, are a critical parameter for accuracte
  3822. * camera calibration. For accessing these parameters for filtering out
  3823. * problematic calibraiton images, this method calculates edge profiles by traveling from
  3824. * black to white chessboard cell centers. Based on this, the number of pixels is
  3825. * calculated required to transit from black to white. This width of the
  3826. * transition area is a good indication of how sharp the chessboard is imaged
  3827. * and should be below ~3.0 pixels.
  3828. *
  3829. * param image Gray image used to find chessboard corners
  3830. * param patternSize Size of a found chessboard pattern
  3831. * param corners Corners found by #findChessboardCornersSB
  3832. * param rise_distance Rise distance 0.8 means 10% ... 90% of the final signal strength
  3833. * param vertical By default edge responses for horizontal lines are calculated
  3834. * param sharpness Optional output array with a sharpness value for calculated edge responses (see description)
  3835. *
  3836. * The optional sharpness array is of type CV_32FC1 and has for each calculated
  3837. * profile one row with the following five entries:
  3838. * 0 = x coordinate of the underlying edge in the image
  3839. * 1 = y coordinate of the underlying edge in the image
  3840. * 2 = width of the transition area (sharpness)
  3841. * 3 = signal strength in the black cell (min brightness)
  3842. * 4 = signal strength in the white cell (max brightness)
  3843. *
  3844. * return Scalar(average sharpness, average min brightness, average max brightness,0)
  3845. */
  3846. public static Scalar estimateChessboardSharpness(Mat image, Size patternSize, Mat corners, float rise_distance, bool vertical, Mat sharpness)
  3847. {
  3848. if (image != null) image.ThrowIfDisposed();
  3849. if (corners != null) corners.ThrowIfDisposed();
  3850. if (sharpness != null) sharpness.ThrowIfDisposed();
  3851. double[] tmpArray = new double[4];
  3852. calib3d_Calib3d_estimateChessboardSharpness_10(image.nativeObj, patternSize.width, patternSize.height, corners.nativeObj, rise_distance, vertical, sharpness.nativeObj, tmpArray);
  3853. Scalar retVal = new Scalar(tmpArray);
  3854. return retVal;
  3855. }
  3856. /**
  3857. * Estimates the sharpness of a detected chessboard.
  3858. *
  3859. * Image sharpness, as well as brightness, are a critical parameter for accuracte
  3860. * camera calibration. For accessing these parameters for filtering out
  3861. * problematic calibraiton images, this method calculates edge profiles by traveling from
  3862. * black to white chessboard cell centers. Based on this, the number of pixels is
  3863. * calculated required to transit from black to white. This width of the
  3864. * transition area is a good indication of how sharp the chessboard is imaged
  3865. * and should be below ~3.0 pixels.
  3866. *
  3867. * param image Gray image used to find chessboard corners
  3868. * param patternSize Size of a found chessboard pattern
  3869. * param corners Corners found by #findChessboardCornersSB
  3870. * param rise_distance Rise distance 0.8 means 10% ... 90% of the final signal strength
  3871. * param vertical By default edge responses for horizontal lines are calculated
  3872. *
  3873. * The optional sharpness array is of type CV_32FC1 and has for each calculated
  3874. * profile one row with the following five entries:
  3875. * 0 = x coordinate of the underlying edge in the image
  3876. * 1 = y coordinate of the underlying edge in the image
  3877. * 2 = width of the transition area (sharpness)
  3878. * 3 = signal strength in the black cell (min brightness)
  3879. * 4 = signal strength in the white cell (max brightness)
  3880. *
  3881. * return Scalar(average sharpness, average min brightness, average max brightness,0)
  3882. */
  3883. public static Scalar estimateChessboardSharpness(Mat image, Size patternSize, Mat corners, float rise_distance, bool vertical)
  3884. {
  3885. if (image != null) image.ThrowIfDisposed();
  3886. if (corners != null) corners.ThrowIfDisposed();
  3887. double[] tmpArray = new double[4];
  3888. calib3d_Calib3d_estimateChessboardSharpness_11(image.nativeObj, patternSize.width, patternSize.height, corners.nativeObj, rise_distance, vertical, tmpArray);
  3889. Scalar retVal = new Scalar(tmpArray);
  3890. return retVal;
  3891. }
  3892. /**
  3893. * Estimates the sharpness of a detected chessboard.
  3894. *
  3895. * Image sharpness, as well as brightness, are a critical parameter for accuracte
  3896. * camera calibration. For accessing these parameters for filtering out
  3897. * problematic calibraiton images, this method calculates edge profiles by traveling from
  3898. * black to white chessboard cell centers. Based on this, the number of pixels is
  3899. * calculated required to transit from black to white. This width of the
  3900. * transition area is a good indication of how sharp the chessboard is imaged
  3901. * and should be below ~3.0 pixels.
  3902. *
  3903. * param image Gray image used to find chessboard corners
  3904. * param patternSize Size of a found chessboard pattern
  3905. * param corners Corners found by #findChessboardCornersSB
  3906. * param rise_distance Rise distance 0.8 means 10% ... 90% of the final signal strength
  3907. *
  3908. * The optional sharpness array is of type CV_32FC1 and has for each calculated
  3909. * profile one row with the following five entries:
  3910. * 0 = x coordinate of the underlying edge in the image
  3911. * 1 = y coordinate of the underlying edge in the image
  3912. * 2 = width of the transition area (sharpness)
  3913. * 3 = signal strength in the black cell (min brightness)
  3914. * 4 = signal strength in the white cell (max brightness)
  3915. *
  3916. * return Scalar(average sharpness, average min brightness, average max brightness,0)
  3917. */
  3918. public static Scalar estimateChessboardSharpness(Mat image, Size patternSize, Mat corners, float rise_distance)
  3919. {
  3920. if (image != null) image.ThrowIfDisposed();
  3921. if (corners != null) corners.ThrowIfDisposed();
  3922. double[] tmpArray = new double[4];
  3923. calib3d_Calib3d_estimateChessboardSharpness_12(image.nativeObj, patternSize.width, patternSize.height, corners.nativeObj, rise_distance, tmpArray);
  3924. Scalar retVal = new Scalar(tmpArray);
  3925. return retVal;
  3926. }
  3927. /**
  3928. * Estimates the sharpness of a detected chessboard.
  3929. *
  3930. * Image sharpness, as well as brightness, are a critical parameter for accuracte
  3931. * camera calibration. For accessing these parameters for filtering out
  3932. * problematic calibraiton images, this method calculates edge profiles by traveling from
  3933. * black to white chessboard cell centers. Based on this, the number of pixels is
  3934. * calculated required to transit from black to white. This width of the
  3935. * transition area is a good indication of how sharp the chessboard is imaged
  3936. * and should be below ~3.0 pixels.
  3937. *
  3938. * param image Gray image used to find chessboard corners
  3939. * param patternSize Size of a found chessboard pattern
  3940. * param corners Corners found by #findChessboardCornersSB
  3941. *
  3942. * The optional sharpness array is of type CV_32FC1 and has for each calculated
  3943. * profile one row with the following five entries:
  3944. * 0 = x coordinate of the underlying edge in the image
  3945. * 1 = y coordinate of the underlying edge in the image
  3946. * 2 = width of the transition area (sharpness)
  3947. * 3 = signal strength in the black cell (min brightness)
  3948. * 4 = signal strength in the white cell (max brightness)
  3949. *
  3950. * return Scalar(average sharpness, average min brightness, average max brightness,0)
  3951. */
  3952. public static Scalar estimateChessboardSharpness(Mat image, Size patternSize, Mat corners)
  3953. {
  3954. if (image != null) image.ThrowIfDisposed();
  3955. if (corners != null) corners.ThrowIfDisposed();
  3956. double[] tmpArray = new double[4];
  3957. calib3d_Calib3d_estimateChessboardSharpness_13(image.nativeObj, patternSize.width, patternSize.height, corners.nativeObj, tmpArray);
  3958. Scalar retVal = new Scalar(tmpArray);
  3959. return retVal;
  3960. }
  3961. //
  3962. // C++: bool cv::find4QuadCornerSubpix(Mat img, Mat& corners, Size region_size)
  3963. //
  3964. public static bool find4QuadCornerSubpix(Mat img, Mat corners, Size region_size)
  3965. {
  3966. if (img != null) img.ThrowIfDisposed();
  3967. if (corners != null) corners.ThrowIfDisposed();
  3968. return calib3d_Calib3d_find4QuadCornerSubpix_10(img.nativeObj, corners.nativeObj, region_size.width, region_size.height);
  3969. }
  3970. //
  3971. // C++: void cv::drawChessboardCorners(Mat& image, Size patternSize, vector_Point2f corners, bool patternWasFound)
  3972. //
  3973. /**
  3974. * Renders the detected chessboard corners.
  3975. *
  3976. * param image Destination image. It must be an 8-bit color image.
  3977. * param patternSize Number of inner corners per a chessboard row and column
  3978. * (patternSize = cv::Size(points_per_row,points_per_column)).
  3979. * param corners Array of detected corners, the output of #findChessboardCorners.
  3980. * param patternWasFound Parameter indicating whether the complete board was found or not. The
  3981. * return value of #findChessboardCorners should be passed here.
  3982. *
  3983. * The function draws individual chessboard corners detected either as red circles if the board was not
  3984. * found, or as colored corners connected with lines if the board was found.
  3985. */
  3986. public static void drawChessboardCorners(Mat image, Size patternSize, MatOfPoint2f corners, bool patternWasFound)
  3987. {
  3988. if (image != null) image.ThrowIfDisposed();
  3989. if (corners != null) corners.ThrowIfDisposed();
  3990. Mat corners_mat = corners;
  3991. calib3d_Calib3d_drawChessboardCorners_10(image.nativeObj, patternSize.width, patternSize.height, corners_mat.nativeObj, patternWasFound);
  3992. }
  3993. //
  3994. // C++: void cv::drawFrameAxes(Mat& image, Mat cameraMatrix, Mat distCoeffs, Mat rvec, Mat tvec, float length, int thickness = 3)
  3995. //
  3996. /**
  3997. * Draw axes of the world/object coordinate system from pose estimation. SEE: solvePnP
  3998. *
  3999. * param image Input/output image. It must have 1 or 3 channels. The number of channels is not altered.
  4000. * param cameraMatrix Input 3x3 floating-point matrix of camera intrinsic parameters.
  4001. * \(\cameramatrix{A}\)
  4002. * param distCoeffs Input vector of distortion coefficients
  4003. * \(\distcoeffs\). If the vector is empty, the zero distortion coefficients are assumed.
  4004. * param rvec Rotation vector (see REF: Rodrigues ) that, together with tvec, brings points from
  4005. * the model coordinate system to the camera coordinate system.
  4006. * param tvec Translation vector.
  4007. * param length Length of the painted axes in the same unit than tvec (usually in meters).
  4008. * param thickness Line thickness of the painted axes.
  4009. *
  4010. * This function draws the axes of the world/object coordinate system w.r.t. to the camera frame.
  4011. * OX is drawn in red, OY in green and OZ in blue.
  4012. */
  4013. public static void drawFrameAxes(Mat image, Mat cameraMatrix, Mat distCoeffs, Mat rvec, Mat tvec, float length, int thickness)
  4014. {
  4015. if (image != null) image.ThrowIfDisposed();
  4016. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  4017. if (distCoeffs != null) distCoeffs.ThrowIfDisposed();
  4018. if (rvec != null) rvec.ThrowIfDisposed();
  4019. if (tvec != null) tvec.ThrowIfDisposed();
  4020. calib3d_Calib3d_drawFrameAxes_10(image.nativeObj, cameraMatrix.nativeObj, distCoeffs.nativeObj, rvec.nativeObj, tvec.nativeObj, length, thickness);
  4021. }
  4022. /**
  4023. * Draw axes of the world/object coordinate system from pose estimation. SEE: solvePnP
  4024. *
  4025. * param image Input/output image. It must have 1 or 3 channels. The number of channels is not altered.
  4026. * param cameraMatrix Input 3x3 floating-point matrix of camera intrinsic parameters.
  4027. * \(\cameramatrix{A}\)
  4028. * param distCoeffs Input vector of distortion coefficients
  4029. * \(\distcoeffs\). If the vector is empty, the zero distortion coefficients are assumed.
  4030. * param rvec Rotation vector (see REF: Rodrigues ) that, together with tvec, brings points from
  4031. * the model coordinate system to the camera coordinate system.
  4032. * param tvec Translation vector.
  4033. * param length Length of the painted axes in the same unit than tvec (usually in meters).
  4034. *
  4035. * This function draws the axes of the world/object coordinate system w.r.t. to the camera frame.
  4036. * OX is drawn in red, OY in green and OZ in blue.
  4037. */
  4038. public static void drawFrameAxes(Mat image, Mat cameraMatrix, Mat distCoeffs, Mat rvec, Mat tvec, float length)
  4039. {
  4040. if (image != null) image.ThrowIfDisposed();
  4041. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  4042. if (distCoeffs != null) distCoeffs.ThrowIfDisposed();
  4043. if (rvec != null) rvec.ThrowIfDisposed();
  4044. if (tvec != null) tvec.ThrowIfDisposed();
  4045. calib3d_Calib3d_drawFrameAxes_11(image.nativeObj, cameraMatrix.nativeObj, distCoeffs.nativeObj, rvec.nativeObj, tvec.nativeObj, length);
  4046. }
  4047. //
  4048. // C++: bool cv::findCirclesGrid(Mat image, Size patternSize, Mat& centers, int flags, Ptr_FeatureDetector blobDetector, CirclesGridFinderParameters parameters)
  4049. //
  4050. // Unknown type 'Ptr_FeatureDetector' (I), skipping the function
  4051. //
  4052. // C++: bool cv::findCirclesGrid(Mat image, Size patternSize, Mat& centers, int flags = CALIB_CB_SYMMETRIC_GRID, Ptr_FeatureDetector blobDetector = SimpleBlobDetector::create())
  4053. //
  4054. public static bool findCirclesGrid(Mat image, Size patternSize, Mat centers, int flags)
  4055. {
  4056. if (image != null) image.ThrowIfDisposed();
  4057. if (centers != null) centers.ThrowIfDisposed();
  4058. return calib3d_Calib3d_findCirclesGrid_10(image.nativeObj, patternSize.width, patternSize.height, centers.nativeObj, flags);
  4059. }
  4060. public static bool findCirclesGrid(Mat image, Size patternSize, Mat centers)
  4061. {
  4062. if (image != null) image.ThrowIfDisposed();
  4063. if (centers != null) centers.ThrowIfDisposed();
  4064. return calib3d_Calib3d_findCirclesGrid_12(image.nativeObj, patternSize.width, patternSize.height, centers.nativeObj);
  4065. }
  4066. //
  4067. // C++: double cv::calibrateCamera(vector_Mat objectPoints, vector_Mat imagePoints, Size imageSize, Mat& cameraMatrix, Mat& distCoeffs, vector_Mat& rvecs, vector_Mat& tvecs, Mat& stdDeviationsIntrinsics, Mat& stdDeviationsExtrinsics, Mat& perViewErrors, int flags = 0, TermCriteria criteria = TermCriteria( TermCriteria::COUNT + TermCriteria::EPS, 30, DBL_EPSILON))
  4068. //
  4069. /**
  4070. * Finds the camera intrinsic and extrinsic parameters from several views of a calibration
  4071. * pattern.
  4072. *
  4073. * param objectPoints In the new interface it is a vector of vectors of calibration pattern points in
  4074. * the calibration pattern coordinate space (e.g. std::vector&lt;std::vector&lt;cv::Vec3f&gt;&gt;). The outer
  4075. * vector contains as many elements as the number of pattern views. If the same calibration pattern
  4076. * is shown in each view and it is fully visible, all the vectors will be the same. Although, it is
  4077. * possible to use partially occluded patterns or even different patterns in different views. Then,
  4078. * the vectors will be different. Although the points are 3D, they all lie in the calibration pattern's
  4079. * XY coordinate plane (thus 0 in the Z-coordinate), if the used calibration pattern is a planar rig.
  4080. * In the old interface all the vectors of object points from different views are concatenated
  4081. * together.
  4082. * param imagePoints In the new interface it is a vector of vectors of the projections of calibration
  4083. * pattern points (e.g. std::vector&lt;std::vector&lt;cv::Vec2f&gt;&gt;). imagePoints.size() and
  4084. * objectPoints.size(), and imagePoints[i].size() and objectPoints[i].size() for each i, must be equal,
  4085. * respectively. In the old interface all the vectors of object points from different views are
  4086. * concatenated together.
  4087. * param imageSize Size of the image used only to initialize the camera intrinsic matrix.
  4088. * param cameraMatrix Input/output 3x3 floating-point camera intrinsic matrix
  4089. * \(\cameramatrix{A}\) . If REF: CALIB_USE_INTRINSIC_GUESS
  4090. * and/or REF: CALIB_FIX_ASPECT_RATIO, REF: CALIB_FIX_PRINCIPAL_POINT or REF: CALIB_FIX_FOCAL_LENGTH
  4091. * are specified, some or all of fx, fy, cx, cy must be initialized before calling the function.
  4092. * param distCoeffs Input/output vector of distortion coefficients
  4093. * \(\distcoeffs\).
  4094. * param rvecs Output vector of rotation vectors (REF: Rodrigues ) estimated for each pattern view
  4095. * (e.g. std::vector&lt;cv::Mat&gt;&gt;). That is, each i-th rotation vector together with the corresponding
  4096. * i-th translation vector (see the next output parameter description) brings the calibration pattern
  4097. * from the object coordinate space (in which object points are specified) to the camera coordinate
  4098. * space. In more technical terms, the tuple of the i-th rotation and translation vector performs
  4099. * a change of basis from object coordinate space to camera coordinate space. Due to its duality, this
  4100. * tuple is equivalent to the position of the calibration pattern with respect to the camera coordinate
  4101. * space.
  4102. * param tvecs Output vector of translation vectors estimated for each pattern view, see parameter
  4103. * describtion above.
  4104. * param stdDeviationsIntrinsics Output vector of standard deviations estimated for intrinsic
  4105. * parameters. Order of deviations values:
  4106. * \((f_x, f_y, c_x, c_y, k_1, k_2, p_1, p_2, k_3, k_4, k_5, k_6 , s_1, s_2, s_3,
  4107. * s_4, \tau_x, \tau_y)\) If one of parameters is not estimated, it's deviation is equals to zero.
  4108. * param stdDeviationsExtrinsics Output vector of standard deviations estimated for extrinsic
  4109. * parameters. Order of deviations values: \((R_0, T_0, \dotsc , R_{M - 1}, T_{M - 1})\) where M is
  4110. * the number of pattern views. \(R_i, T_i\) are concatenated 1x3 vectors.
  4111. * param perViewErrors Output vector of the RMS re-projection error estimated for each pattern view.
  4112. * param flags Different flags that may be zero or a combination of the following values:
  4113. * <ul>
  4114. * <li>
  4115. * REF: CALIB_USE_INTRINSIC_GUESS cameraMatrix contains valid initial values of
  4116. * fx, fy, cx, cy that are optimized further. Otherwise, (cx, cy) is initially set to the image
  4117. * center ( imageSize is used), and focal distances are computed in a least-squares fashion.
  4118. * Note, that if intrinsic parameters are known, there is no need to use this function just to
  4119. * estimate extrinsic parameters. Use REF: solvePnP instead.
  4120. * </li>
  4121. * <li>
  4122. * REF: CALIB_FIX_PRINCIPAL_POINT The principal point is not changed during the global
  4123. * optimization. It stays at the center or at a different location specified when
  4124. * REF: CALIB_USE_INTRINSIC_GUESS is set too.
  4125. * </li>
  4126. * <li>
  4127. * REF: CALIB_FIX_ASPECT_RATIO The functions consider only fy as a free parameter. The
  4128. * ratio fx/fy stays the same as in the input cameraMatrix . When
  4129. * REF: CALIB_USE_INTRINSIC_GUESS is not set, the actual input values of fx and fy are
  4130. * ignored, only their ratio is computed and used further.
  4131. * </li>
  4132. * <li>
  4133. * REF: CALIB_ZERO_TANGENT_DIST Tangential distortion coefficients \((p_1, p_2)\) are set
  4134. * to zeros and stay zero.
  4135. * </li>
  4136. * <li>
  4137. * REF: CALIB_FIX_FOCAL_LENGTH The focal length is not changed during the global optimization if
  4138. * REF: CALIB_USE_INTRINSIC_GUESS is set.
  4139. * </li>
  4140. * <li>
  4141. * REF: CALIB_FIX_K1,..., REF: CALIB_FIX_K6 The corresponding radial distortion
  4142. * coefficient is not changed during the optimization. If REF: CALIB_USE_INTRINSIC_GUESS is
  4143. * set, the coefficient from the supplied distCoeffs matrix is used. Otherwise, it is set to 0.
  4144. * </li>
  4145. * <li>
  4146. * REF: CALIB_RATIONAL_MODEL Coefficients k4, k5, and k6 are enabled. To provide the
  4147. * backward compatibility, this extra flag should be explicitly specified to make the
  4148. * calibration function use the rational model and return 8 coefficients or more.
  4149. * </li>
  4150. * <li>
  4151. * REF: CALIB_THIN_PRISM_MODEL Coefficients s1, s2, s3 and s4 are enabled. To provide the
  4152. * backward compatibility, this extra flag should be explicitly specified to make the
  4153. * calibration function use the thin prism model and return 12 coefficients or more.
  4154. * </li>
  4155. * <li>
  4156. * REF: CALIB_FIX_S1_S2_S3_S4 The thin prism distortion coefficients are not changed during
  4157. * the optimization. If REF: CALIB_USE_INTRINSIC_GUESS is set, the coefficient from the
  4158. * supplied distCoeffs matrix is used. Otherwise, it is set to 0.
  4159. * </li>
  4160. * <li>
  4161. * REF: CALIB_TILTED_MODEL Coefficients tauX and tauY are enabled. To provide the
  4162. * backward compatibility, this extra flag should be explicitly specified to make the
  4163. * calibration function use the tilted sensor model and return 14 coefficients.
  4164. * </li>
  4165. * <li>
  4166. * REF: CALIB_FIX_TAUX_TAUY The coefficients of the tilted sensor model are not changed during
  4167. * the optimization. If REF: CALIB_USE_INTRINSIC_GUESS is set, the coefficient from the
  4168. * supplied distCoeffs matrix is used. Otherwise, it is set to 0.
  4169. * </li>
  4170. * </ul>
  4171. * param criteria Termination criteria for the iterative optimization algorithm.
  4172. *
  4173. * return the overall RMS re-projection error.
  4174. *
  4175. * The function estimates the intrinsic camera parameters and extrinsic parameters for each of the
  4176. * views. The algorithm is based on CITE: Zhang2000 and CITE: BouguetMCT . The coordinates of 3D object
  4177. * points and their corresponding 2D projections in each view must be specified. That may be achieved
  4178. * by using an object with known geometry and easily detectable feature points. Such an object is
  4179. * called a calibration rig or calibration pattern, and OpenCV has built-in support for a chessboard as
  4180. * a calibration rig (see REF: findChessboardCorners). Currently, initialization of intrinsic
  4181. * parameters (when REF: CALIB_USE_INTRINSIC_GUESS is not set) is only implemented for planar calibration
  4182. * patterns (where Z-coordinates of the object points must be all zeros). 3D calibration rigs can also
  4183. * be used as long as initial cameraMatrix is provided.
  4184. *
  4185. * The algorithm performs the following steps:
  4186. *
  4187. * <ul>
  4188. * <li>
  4189. * Compute the initial intrinsic parameters (the option only available for planar calibration
  4190. * patterns) or read them from the input parameters. The distortion coefficients are all set to
  4191. * zeros initially unless some of CALIB_FIX_K? are specified.
  4192. * </li>
  4193. * </ul>
  4194. *
  4195. * <ul>
  4196. * <li>
  4197. * Estimate the initial camera pose as if the intrinsic parameters have been already known. This is
  4198. * done using REF: solvePnP .
  4199. * </li>
  4200. * </ul>
  4201. *
  4202. * <ul>
  4203. * <li>
  4204. * Run the global Levenberg-Marquardt optimization algorithm to minimize the reprojection error,
  4205. * that is, the total sum of squared distances between the observed feature points imagePoints and
  4206. * the projected (using the current estimates for camera parameters and the poses) object points
  4207. * objectPoints. See REF: projectPoints for details.
  4208. * </li>
  4209. * </ul>
  4210. *
  4211. * <b>Note:</b>
  4212. * If you use a non-square (i.e. non-N-by-N) grid and REF: findChessboardCorners for calibration,
  4213. * and REF: calibrateCamera returns bad values (zero distortion coefficients, \(c_x\) and
  4214. * \(c_y\) very far from the image center, and/or large differences between \(f_x\) and
  4215. * \(f_y\) (ratios of 10:1 or more)), then you are probably using patternSize=cvSize(rows,cols)
  4216. * instead of using patternSize=cvSize(cols,rows) in REF: findChessboardCorners.
  4217. *
  4218. * SEE:
  4219. * calibrateCameraRO, findChessboardCorners, solvePnP, initCameraMatrix2D, stereoCalibrate,
  4220. * undistort
  4221. */
  4222. public static double calibrateCameraExtended(List<Mat> objectPoints, List<Mat> imagePoints, Size imageSize, Mat cameraMatrix, Mat distCoeffs, List<Mat> rvecs, List<Mat> tvecs, Mat stdDeviationsIntrinsics, Mat stdDeviationsExtrinsics, Mat perViewErrors, int flags, TermCriteria criteria)
  4223. {
  4224. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  4225. if (distCoeffs != null) distCoeffs.ThrowIfDisposed();
  4226. if (stdDeviationsIntrinsics != null) stdDeviationsIntrinsics.ThrowIfDisposed();
  4227. if (stdDeviationsExtrinsics != null) stdDeviationsExtrinsics.ThrowIfDisposed();
  4228. if (perViewErrors != null) perViewErrors.ThrowIfDisposed();
  4229. Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints);
  4230. Mat imagePoints_mat = Converters.vector_Mat_to_Mat(imagePoints);
  4231. Mat rvecs_mat = new Mat();
  4232. Mat tvecs_mat = new Mat();
  4233. double retVal = calib3d_Calib3d_calibrateCameraExtended_10(objectPoints_mat.nativeObj, imagePoints_mat.nativeObj, imageSize.width, imageSize.height, cameraMatrix.nativeObj, distCoeffs.nativeObj, rvecs_mat.nativeObj, tvecs_mat.nativeObj, stdDeviationsIntrinsics.nativeObj, stdDeviationsExtrinsics.nativeObj, perViewErrors.nativeObj, flags, criteria.type, criteria.maxCount, criteria.epsilon);
  4234. Converters.Mat_to_vector_Mat(rvecs_mat, rvecs);
  4235. rvecs_mat.release();
  4236. Converters.Mat_to_vector_Mat(tvecs_mat, tvecs);
  4237. tvecs_mat.release();
  4238. return retVal;
  4239. }
  4240. /**
  4241. * Finds the camera intrinsic and extrinsic parameters from several views of a calibration
  4242. * pattern.
  4243. *
  4244. * param objectPoints In the new interface it is a vector of vectors of calibration pattern points in
  4245. * the calibration pattern coordinate space (e.g. std::vector&lt;std::vector&lt;cv::Vec3f&gt;&gt;). The outer
  4246. * vector contains as many elements as the number of pattern views. If the same calibration pattern
  4247. * is shown in each view and it is fully visible, all the vectors will be the same. Although, it is
  4248. * possible to use partially occluded patterns or even different patterns in different views. Then,
  4249. * the vectors will be different. Although the points are 3D, they all lie in the calibration pattern's
  4250. * XY coordinate plane (thus 0 in the Z-coordinate), if the used calibration pattern is a planar rig.
  4251. * In the old interface all the vectors of object points from different views are concatenated
  4252. * together.
  4253. * param imagePoints In the new interface it is a vector of vectors of the projections of calibration
  4254. * pattern points (e.g. std::vector&lt;std::vector&lt;cv::Vec2f&gt;&gt;). imagePoints.size() and
  4255. * objectPoints.size(), and imagePoints[i].size() and objectPoints[i].size() for each i, must be equal,
  4256. * respectively. In the old interface all the vectors of object points from different views are
  4257. * concatenated together.
  4258. * param imageSize Size of the image used only to initialize the camera intrinsic matrix.
  4259. * param cameraMatrix Input/output 3x3 floating-point camera intrinsic matrix
  4260. * \(\cameramatrix{A}\) . If REF: CALIB_USE_INTRINSIC_GUESS
  4261. * and/or REF: CALIB_FIX_ASPECT_RATIO, REF: CALIB_FIX_PRINCIPAL_POINT or REF: CALIB_FIX_FOCAL_LENGTH
  4262. * are specified, some or all of fx, fy, cx, cy must be initialized before calling the function.
  4263. * param distCoeffs Input/output vector of distortion coefficients
  4264. * \(\distcoeffs\).
  4265. * param rvecs Output vector of rotation vectors (REF: Rodrigues ) estimated for each pattern view
  4266. * (e.g. std::vector&lt;cv::Mat&gt;&gt;). That is, each i-th rotation vector together with the corresponding
  4267. * i-th translation vector (see the next output parameter description) brings the calibration pattern
  4268. * from the object coordinate space (in which object points are specified) to the camera coordinate
  4269. * space. In more technical terms, the tuple of the i-th rotation and translation vector performs
  4270. * a change of basis from object coordinate space to camera coordinate space. Due to its duality, this
  4271. * tuple is equivalent to the position of the calibration pattern with respect to the camera coordinate
  4272. * space.
  4273. * param tvecs Output vector of translation vectors estimated for each pattern view, see parameter
  4274. * describtion above.
  4275. * param stdDeviationsIntrinsics Output vector of standard deviations estimated for intrinsic
  4276. * parameters. Order of deviations values:
  4277. * \((f_x, f_y, c_x, c_y, k_1, k_2, p_1, p_2, k_3, k_4, k_5, k_6 , s_1, s_2, s_3,
  4278. * s_4, \tau_x, \tau_y)\) If one of parameters is not estimated, it's deviation is equals to zero.
  4279. * param stdDeviationsExtrinsics Output vector of standard deviations estimated for extrinsic
  4280. * parameters. Order of deviations values: \((R_0, T_0, \dotsc , R_{M - 1}, T_{M - 1})\) where M is
  4281. * the number of pattern views. \(R_i, T_i\) are concatenated 1x3 vectors.
  4282. * param perViewErrors Output vector of the RMS re-projection error estimated for each pattern view.
  4283. * param flags Different flags that may be zero or a combination of the following values:
  4284. * <ul>
  4285. * <li>
  4286. * REF: CALIB_USE_INTRINSIC_GUESS cameraMatrix contains valid initial values of
  4287. * fx, fy, cx, cy that are optimized further. Otherwise, (cx, cy) is initially set to the image
  4288. * center ( imageSize is used), and focal distances are computed in a least-squares fashion.
  4289. * Note, that if intrinsic parameters are known, there is no need to use this function just to
  4290. * estimate extrinsic parameters. Use REF: solvePnP instead.
  4291. * </li>
  4292. * <li>
  4293. * REF: CALIB_FIX_PRINCIPAL_POINT The principal point is not changed during the global
  4294. * optimization. It stays at the center or at a different location specified when
  4295. * REF: CALIB_USE_INTRINSIC_GUESS is set too.
  4296. * </li>
  4297. * <li>
  4298. * REF: CALIB_FIX_ASPECT_RATIO The functions consider only fy as a free parameter. The
  4299. * ratio fx/fy stays the same as in the input cameraMatrix . When
  4300. * REF: CALIB_USE_INTRINSIC_GUESS is not set, the actual input values of fx and fy are
  4301. * ignored, only their ratio is computed and used further.
  4302. * </li>
  4303. * <li>
  4304. * REF: CALIB_ZERO_TANGENT_DIST Tangential distortion coefficients \((p_1, p_2)\) are set
  4305. * to zeros and stay zero.
  4306. * </li>
  4307. * <li>
  4308. * REF: CALIB_FIX_FOCAL_LENGTH The focal length is not changed during the global optimization if
  4309. * REF: CALIB_USE_INTRINSIC_GUESS is set.
  4310. * </li>
  4311. * <li>
  4312. * REF: CALIB_FIX_K1,..., REF: CALIB_FIX_K6 The corresponding radial distortion
  4313. * coefficient is not changed during the optimization. If REF: CALIB_USE_INTRINSIC_GUESS is
  4314. * set, the coefficient from the supplied distCoeffs matrix is used. Otherwise, it is set to 0.
  4315. * </li>
  4316. * <li>
  4317. * REF: CALIB_RATIONAL_MODEL Coefficients k4, k5, and k6 are enabled. To provide the
  4318. * backward compatibility, this extra flag should be explicitly specified to make the
  4319. * calibration function use the rational model and return 8 coefficients or more.
  4320. * </li>
  4321. * <li>
  4322. * REF: CALIB_THIN_PRISM_MODEL Coefficients s1, s2, s3 and s4 are enabled. To provide the
  4323. * backward compatibility, this extra flag should be explicitly specified to make the
  4324. * calibration function use the thin prism model and return 12 coefficients or more.
  4325. * </li>
  4326. * <li>
  4327. * REF: CALIB_FIX_S1_S2_S3_S4 The thin prism distortion coefficients are not changed during
  4328. * the optimization. If REF: CALIB_USE_INTRINSIC_GUESS is set, the coefficient from the
  4329. * supplied distCoeffs matrix is used. Otherwise, it is set to 0.
  4330. * </li>
  4331. * <li>
  4332. * REF: CALIB_TILTED_MODEL Coefficients tauX and tauY are enabled. To provide the
  4333. * backward compatibility, this extra flag should be explicitly specified to make the
  4334. * calibration function use the tilted sensor model and return 14 coefficients.
  4335. * </li>
  4336. * <li>
  4337. * REF: CALIB_FIX_TAUX_TAUY The coefficients of the tilted sensor model are not changed during
  4338. * the optimization. If REF: CALIB_USE_INTRINSIC_GUESS is set, the coefficient from the
  4339. * supplied distCoeffs matrix is used. Otherwise, it is set to 0.
  4340. * </li>
  4341. * </ul>
  4342. *
  4343. * return the overall RMS re-projection error.
  4344. *
  4345. * The function estimates the intrinsic camera parameters and extrinsic parameters for each of the
  4346. * views. The algorithm is based on CITE: Zhang2000 and CITE: BouguetMCT . The coordinates of 3D object
  4347. * points and their corresponding 2D projections in each view must be specified. That may be achieved
  4348. * by using an object with known geometry and easily detectable feature points. Such an object is
  4349. * called a calibration rig or calibration pattern, and OpenCV has built-in support for a chessboard as
  4350. * a calibration rig (see REF: findChessboardCorners). Currently, initialization of intrinsic
  4351. * parameters (when REF: CALIB_USE_INTRINSIC_GUESS is not set) is only implemented for planar calibration
  4352. * patterns (where Z-coordinates of the object points must be all zeros). 3D calibration rigs can also
  4353. * be used as long as initial cameraMatrix is provided.
  4354. *
  4355. * The algorithm performs the following steps:
  4356. *
  4357. * <ul>
  4358. * <li>
  4359. * Compute the initial intrinsic parameters (the option only available for planar calibration
  4360. * patterns) or read them from the input parameters. The distortion coefficients are all set to
  4361. * zeros initially unless some of CALIB_FIX_K? are specified.
  4362. * </li>
  4363. * </ul>
  4364. *
  4365. * <ul>
  4366. * <li>
  4367. * Estimate the initial camera pose as if the intrinsic parameters have been already known. This is
  4368. * done using REF: solvePnP .
  4369. * </li>
  4370. * </ul>
  4371. *
  4372. * <ul>
  4373. * <li>
  4374. * Run the global Levenberg-Marquardt optimization algorithm to minimize the reprojection error,
  4375. * that is, the total sum of squared distances between the observed feature points imagePoints and
  4376. * the projected (using the current estimates for camera parameters and the poses) object points
  4377. * objectPoints. See REF: projectPoints for details.
  4378. * </li>
  4379. * </ul>
  4380. *
  4381. * <b>Note:</b>
  4382. * If you use a non-square (i.e. non-N-by-N) grid and REF: findChessboardCorners for calibration,
  4383. * and REF: calibrateCamera returns bad values (zero distortion coefficients, \(c_x\) and
  4384. * \(c_y\) very far from the image center, and/or large differences between \(f_x\) and
  4385. * \(f_y\) (ratios of 10:1 or more)), then you are probably using patternSize=cvSize(rows,cols)
  4386. * instead of using patternSize=cvSize(cols,rows) in REF: findChessboardCorners.
  4387. *
  4388. * SEE:
  4389. * calibrateCameraRO, findChessboardCorners, solvePnP, initCameraMatrix2D, stereoCalibrate,
  4390. * undistort
  4391. */
  4392. public static double calibrateCameraExtended(List<Mat> objectPoints, List<Mat> imagePoints, Size imageSize, Mat cameraMatrix, Mat distCoeffs, List<Mat> rvecs, List<Mat> tvecs, Mat stdDeviationsIntrinsics, Mat stdDeviationsExtrinsics, Mat perViewErrors, int flags)
  4393. {
  4394. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  4395. if (distCoeffs != null) distCoeffs.ThrowIfDisposed();
  4396. if (stdDeviationsIntrinsics != null) stdDeviationsIntrinsics.ThrowIfDisposed();
  4397. if (stdDeviationsExtrinsics != null) stdDeviationsExtrinsics.ThrowIfDisposed();
  4398. if (perViewErrors != null) perViewErrors.ThrowIfDisposed();
  4399. Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints);
  4400. Mat imagePoints_mat = Converters.vector_Mat_to_Mat(imagePoints);
  4401. Mat rvecs_mat = new Mat();
  4402. Mat tvecs_mat = new Mat();
  4403. double retVal = calib3d_Calib3d_calibrateCameraExtended_11(objectPoints_mat.nativeObj, imagePoints_mat.nativeObj, imageSize.width, imageSize.height, cameraMatrix.nativeObj, distCoeffs.nativeObj, rvecs_mat.nativeObj, tvecs_mat.nativeObj, stdDeviationsIntrinsics.nativeObj, stdDeviationsExtrinsics.nativeObj, perViewErrors.nativeObj, flags);
  4404. Converters.Mat_to_vector_Mat(rvecs_mat, rvecs);
  4405. rvecs_mat.release();
  4406. Converters.Mat_to_vector_Mat(tvecs_mat, tvecs);
  4407. tvecs_mat.release();
  4408. return retVal;
  4409. }
  4410. /**
  4411. * Finds the camera intrinsic and extrinsic parameters from several views of a calibration
  4412. * pattern.
  4413. *
  4414. * param objectPoints In the new interface it is a vector of vectors of calibration pattern points in
  4415. * the calibration pattern coordinate space (e.g. std::vector&lt;std::vector&lt;cv::Vec3f&gt;&gt;). The outer
  4416. * vector contains as many elements as the number of pattern views. If the same calibration pattern
  4417. * is shown in each view and it is fully visible, all the vectors will be the same. Although, it is
  4418. * possible to use partially occluded patterns or even different patterns in different views. Then,
  4419. * the vectors will be different. Although the points are 3D, they all lie in the calibration pattern's
  4420. * XY coordinate plane (thus 0 in the Z-coordinate), if the used calibration pattern is a planar rig.
  4421. * In the old interface all the vectors of object points from different views are concatenated
  4422. * together.
  4423. * param imagePoints In the new interface it is a vector of vectors of the projections of calibration
  4424. * pattern points (e.g. std::vector&lt;std::vector&lt;cv::Vec2f&gt;&gt;). imagePoints.size() and
  4425. * objectPoints.size(), and imagePoints[i].size() and objectPoints[i].size() for each i, must be equal,
  4426. * respectively. In the old interface all the vectors of object points from different views are
  4427. * concatenated together.
  4428. * param imageSize Size of the image used only to initialize the camera intrinsic matrix.
  4429. * param cameraMatrix Input/output 3x3 floating-point camera intrinsic matrix
  4430. * \(\cameramatrix{A}\) . If REF: CALIB_USE_INTRINSIC_GUESS
  4431. * and/or REF: CALIB_FIX_ASPECT_RATIO, REF: CALIB_FIX_PRINCIPAL_POINT or REF: CALIB_FIX_FOCAL_LENGTH
  4432. * are specified, some or all of fx, fy, cx, cy must be initialized before calling the function.
  4433. * param distCoeffs Input/output vector of distortion coefficients
  4434. * \(\distcoeffs\).
  4435. * param rvecs Output vector of rotation vectors (REF: Rodrigues ) estimated for each pattern view
  4436. * (e.g. std::vector&lt;cv::Mat&gt;&gt;). That is, each i-th rotation vector together with the corresponding
  4437. * i-th translation vector (see the next output parameter description) brings the calibration pattern
  4438. * from the object coordinate space (in which object points are specified) to the camera coordinate
  4439. * space. In more technical terms, the tuple of the i-th rotation and translation vector performs
  4440. * a change of basis from object coordinate space to camera coordinate space. Due to its duality, this
  4441. * tuple is equivalent to the position of the calibration pattern with respect to the camera coordinate
  4442. * space.
  4443. * param tvecs Output vector of translation vectors estimated for each pattern view, see parameter
  4444. * describtion above.
  4445. * param stdDeviationsIntrinsics Output vector of standard deviations estimated for intrinsic
  4446. * parameters. Order of deviations values:
  4447. * \((f_x, f_y, c_x, c_y, k_1, k_2, p_1, p_2, k_3, k_4, k_5, k_6 , s_1, s_2, s_3,
  4448. * s_4, \tau_x, \tau_y)\) If one of parameters is not estimated, it's deviation is equals to zero.
  4449. * param stdDeviationsExtrinsics Output vector of standard deviations estimated for extrinsic
  4450. * parameters. Order of deviations values: \((R_0, T_0, \dotsc , R_{M - 1}, T_{M - 1})\) where M is
  4451. * the number of pattern views. \(R_i, T_i\) are concatenated 1x3 vectors.
  4452. * param perViewErrors Output vector of the RMS re-projection error estimated for each pattern view.
  4453. * <ul>
  4454. * <li>
  4455. * REF: CALIB_USE_INTRINSIC_GUESS cameraMatrix contains valid initial values of
  4456. * fx, fy, cx, cy that are optimized further. Otherwise, (cx, cy) is initially set to the image
  4457. * center ( imageSize is used), and focal distances are computed in a least-squares fashion.
  4458. * Note, that if intrinsic parameters are known, there is no need to use this function just to
  4459. * estimate extrinsic parameters. Use REF: solvePnP instead.
  4460. * </li>
  4461. * <li>
  4462. * REF: CALIB_FIX_PRINCIPAL_POINT The principal point is not changed during the global
  4463. * optimization. It stays at the center or at a different location specified when
  4464. * REF: CALIB_USE_INTRINSIC_GUESS is set too.
  4465. * </li>
  4466. * <li>
  4467. * REF: CALIB_FIX_ASPECT_RATIO The functions consider only fy as a free parameter. The
  4468. * ratio fx/fy stays the same as in the input cameraMatrix . When
  4469. * REF: CALIB_USE_INTRINSIC_GUESS is not set, the actual input values of fx and fy are
  4470. * ignored, only their ratio is computed and used further.
  4471. * </li>
  4472. * <li>
  4473. * REF: CALIB_ZERO_TANGENT_DIST Tangential distortion coefficients \((p_1, p_2)\) are set
  4474. * to zeros and stay zero.
  4475. * </li>
  4476. * <li>
  4477. * REF: CALIB_FIX_FOCAL_LENGTH The focal length is not changed during the global optimization if
  4478. * REF: CALIB_USE_INTRINSIC_GUESS is set.
  4479. * </li>
  4480. * <li>
  4481. * REF: CALIB_FIX_K1,..., REF: CALIB_FIX_K6 The corresponding radial distortion
  4482. * coefficient is not changed during the optimization. If REF: CALIB_USE_INTRINSIC_GUESS is
  4483. * set, the coefficient from the supplied distCoeffs matrix is used. Otherwise, it is set to 0.
  4484. * </li>
  4485. * <li>
  4486. * REF: CALIB_RATIONAL_MODEL Coefficients k4, k5, and k6 are enabled. To provide the
  4487. * backward compatibility, this extra flag should be explicitly specified to make the
  4488. * calibration function use the rational model and return 8 coefficients or more.
  4489. * </li>
  4490. * <li>
  4491. * REF: CALIB_THIN_PRISM_MODEL Coefficients s1, s2, s3 and s4 are enabled. To provide the
  4492. * backward compatibility, this extra flag should be explicitly specified to make the
  4493. * calibration function use the thin prism model and return 12 coefficients or more.
  4494. * </li>
  4495. * <li>
  4496. * REF: CALIB_FIX_S1_S2_S3_S4 The thin prism distortion coefficients are not changed during
  4497. * the optimization. If REF: CALIB_USE_INTRINSIC_GUESS is set, the coefficient from the
  4498. * supplied distCoeffs matrix is used. Otherwise, it is set to 0.
  4499. * </li>
  4500. * <li>
  4501. * REF: CALIB_TILTED_MODEL Coefficients tauX and tauY are enabled. To provide the
  4502. * backward compatibility, this extra flag should be explicitly specified to make the
  4503. * calibration function use the tilted sensor model and return 14 coefficients.
  4504. * </li>
  4505. * <li>
  4506. * REF: CALIB_FIX_TAUX_TAUY The coefficients of the tilted sensor model are not changed during
  4507. * the optimization. If REF: CALIB_USE_INTRINSIC_GUESS is set, the coefficient from the
  4508. * supplied distCoeffs matrix is used. Otherwise, it is set to 0.
  4509. * </li>
  4510. * </ul>
  4511. *
  4512. * return the overall RMS re-projection error.
  4513. *
  4514. * The function estimates the intrinsic camera parameters and extrinsic parameters for each of the
  4515. * views. The algorithm is based on CITE: Zhang2000 and CITE: BouguetMCT . The coordinates of 3D object
  4516. * points and their corresponding 2D projections in each view must be specified. That may be achieved
  4517. * by using an object with known geometry and easily detectable feature points. Such an object is
  4518. * called a calibration rig or calibration pattern, and OpenCV has built-in support for a chessboard as
  4519. * a calibration rig (see REF: findChessboardCorners). Currently, initialization of intrinsic
  4520. * parameters (when REF: CALIB_USE_INTRINSIC_GUESS is not set) is only implemented for planar calibration
  4521. * patterns (where Z-coordinates of the object points must be all zeros). 3D calibration rigs can also
  4522. * be used as long as initial cameraMatrix is provided.
  4523. *
  4524. * The algorithm performs the following steps:
  4525. *
  4526. * <ul>
  4527. * <li>
  4528. * Compute the initial intrinsic parameters (the option only available for planar calibration
  4529. * patterns) or read them from the input parameters. The distortion coefficients are all set to
  4530. * zeros initially unless some of CALIB_FIX_K? are specified.
  4531. * </li>
  4532. * </ul>
  4533. *
  4534. * <ul>
  4535. * <li>
  4536. * Estimate the initial camera pose as if the intrinsic parameters have been already known. This is
  4537. * done using REF: solvePnP .
  4538. * </li>
  4539. * </ul>
  4540. *
  4541. * <ul>
  4542. * <li>
  4543. * Run the global Levenberg-Marquardt optimization algorithm to minimize the reprojection error,
  4544. * that is, the total sum of squared distances between the observed feature points imagePoints and
  4545. * the projected (using the current estimates for camera parameters and the poses) object points
  4546. * objectPoints. See REF: projectPoints for details.
  4547. * </li>
  4548. * </ul>
  4549. *
  4550. * <b>Note:</b>
  4551. * If you use a non-square (i.e. non-N-by-N) grid and REF: findChessboardCorners for calibration,
  4552. * and REF: calibrateCamera returns bad values (zero distortion coefficients, \(c_x\) and
  4553. * \(c_y\) very far from the image center, and/or large differences between \(f_x\) and
  4554. * \(f_y\) (ratios of 10:1 or more)), then you are probably using patternSize=cvSize(rows,cols)
  4555. * instead of using patternSize=cvSize(cols,rows) in REF: findChessboardCorners.
  4556. *
  4557. * SEE:
  4558. * calibrateCameraRO, findChessboardCorners, solvePnP, initCameraMatrix2D, stereoCalibrate,
  4559. * undistort
  4560. */
  4561. public static double calibrateCameraExtended(List<Mat> objectPoints, List<Mat> imagePoints, Size imageSize, Mat cameraMatrix, Mat distCoeffs, List<Mat> rvecs, List<Mat> tvecs, Mat stdDeviationsIntrinsics, Mat stdDeviationsExtrinsics, Mat perViewErrors)
  4562. {
  4563. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  4564. if (distCoeffs != null) distCoeffs.ThrowIfDisposed();
  4565. if (stdDeviationsIntrinsics != null) stdDeviationsIntrinsics.ThrowIfDisposed();
  4566. if (stdDeviationsExtrinsics != null) stdDeviationsExtrinsics.ThrowIfDisposed();
  4567. if (perViewErrors != null) perViewErrors.ThrowIfDisposed();
  4568. Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints);
  4569. Mat imagePoints_mat = Converters.vector_Mat_to_Mat(imagePoints);
  4570. Mat rvecs_mat = new Mat();
  4571. Mat tvecs_mat = new Mat();
  4572. double retVal = calib3d_Calib3d_calibrateCameraExtended_12(objectPoints_mat.nativeObj, imagePoints_mat.nativeObj, imageSize.width, imageSize.height, cameraMatrix.nativeObj, distCoeffs.nativeObj, rvecs_mat.nativeObj, tvecs_mat.nativeObj, stdDeviationsIntrinsics.nativeObj, stdDeviationsExtrinsics.nativeObj, perViewErrors.nativeObj);
  4573. Converters.Mat_to_vector_Mat(rvecs_mat, rvecs);
  4574. rvecs_mat.release();
  4575. Converters.Mat_to_vector_Mat(tvecs_mat, tvecs);
  4576. tvecs_mat.release();
  4577. return retVal;
  4578. }
  4579. //
  4580. // C++: double cv::calibrateCamera(vector_Mat objectPoints, vector_Mat imagePoints, Size imageSize, Mat& cameraMatrix, Mat& distCoeffs, vector_Mat& rvecs, vector_Mat& tvecs, int flags = 0, TermCriteria criteria = TermCriteria( TermCriteria::COUNT + TermCriteria::EPS, 30, DBL_EPSILON))
  4581. //
  4582. public static double calibrateCamera(List<Mat> objectPoints, List<Mat> imagePoints, Size imageSize, Mat cameraMatrix, Mat distCoeffs, List<Mat> rvecs, List<Mat> tvecs, int flags, TermCriteria criteria)
  4583. {
  4584. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  4585. if (distCoeffs != null) distCoeffs.ThrowIfDisposed();
  4586. Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints);
  4587. Mat imagePoints_mat = Converters.vector_Mat_to_Mat(imagePoints);
  4588. Mat rvecs_mat = new Mat();
  4589. Mat tvecs_mat = new Mat();
  4590. double retVal = calib3d_Calib3d_calibrateCamera_10(objectPoints_mat.nativeObj, imagePoints_mat.nativeObj, imageSize.width, imageSize.height, cameraMatrix.nativeObj, distCoeffs.nativeObj, rvecs_mat.nativeObj, tvecs_mat.nativeObj, flags, criteria.type, criteria.maxCount, criteria.epsilon);
  4591. Converters.Mat_to_vector_Mat(rvecs_mat, rvecs);
  4592. rvecs_mat.release();
  4593. Converters.Mat_to_vector_Mat(tvecs_mat, tvecs);
  4594. tvecs_mat.release();
  4595. return retVal;
  4596. }
  4597. public static double calibrateCamera(List<Mat> objectPoints, List<Mat> imagePoints, Size imageSize, Mat cameraMatrix, Mat distCoeffs, List<Mat> rvecs, List<Mat> tvecs, int flags)
  4598. {
  4599. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  4600. if (distCoeffs != null) distCoeffs.ThrowIfDisposed();
  4601. Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints);
  4602. Mat imagePoints_mat = Converters.vector_Mat_to_Mat(imagePoints);
  4603. Mat rvecs_mat = new Mat();
  4604. Mat tvecs_mat = new Mat();
  4605. double retVal = calib3d_Calib3d_calibrateCamera_11(objectPoints_mat.nativeObj, imagePoints_mat.nativeObj, imageSize.width, imageSize.height, cameraMatrix.nativeObj, distCoeffs.nativeObj, rvecs_mat.nativeObj, tvecs_mat.nativeObj, flags);
  4606. Converters.Mat_to_vector_Mat(rvecs_mat, rvecs);
  4607. rvecs_mat.release();
  4608. Converters.Mat_to_vector_Mat(tvecs_mat, tvecs);
  4609. tvecs_mat.release();
  4610. return retVal;
  4611. }
  4612. public static double calibrateCamera(List<Mat> objectPoints, List<Mat> imagePoints, Size imageSize, Mat cameraMatrix, Mat distCoeffs, List<Mat> rvecs, List<Mat> tvecs)
  4613. {
  4614. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  4615. if (distCoeffs != null) distCoeffs.ThrowIfDisposed();
  4616. Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints);
  4617. Mat imagePoints_mat = Converters.vector_Mat_to_Mat(imagePoints);
  4618. Mat rvecs_mat = new Mat();
  4619. Mat tvecs_mat = new Mat();
  4620. double retVal = calib3d_Calib3d_calibrateCamera_12(objectPoints_mat.nativeObj, imagePoints_mat.nativeObj, imageSize.width, imageSize.height, cameraMatrix.nativeObj, distCoeffs.nativeObj, rvecs_mat.nativeObj, tvecs_mat.nativeObj);
  4621. Converters.Mat_to_vector_Mat(rvecs_mat, rvecs);
  4622. rvecs_mat.release();
  4623. Converters.Mat_to_vector_Mat(tvecs_mat, tvecs);
  4624. tvecs_mat.release();
  4625. return retVal;
  4626. }
  4627. //
  4628. // C++: double cv::calibrateCameraRO(vector_Mat objectPoints, vector_Mat imagePoints, Size imageSize, int iFixedPoint, Mat& cameraMatrix, Mat& distCoeffs, vector_Mat& rvecs, vector_Mat& tvecs, Mat& newObjPoints, Mat& stdDeviationsIntrinsics, Mat& stdDeviationsExtrinsics, Mat& stdDeviationsObjPoints, Mat& perViewErrors, int flags = 0, TermCriteria criteria = TermCriteria( TermCriteria::COUNT + TermCriteria::EPS, 30, DBL_EPSILON))
  4629. //
  4630. /**
  4631. * Finds the camera intrinsic and extrinsic parameters from several views of a calibration pattern.
  4632. *
  4633. * This function is an extension of #calibrateCamera with the method of releasing object which was
  4634. * proposed in CITE: strobl2011iccv. In many common cases with inaccurate, unmeasured, roughly planar
  4635. * targets (calibration plates), this method can dramatically improve the precision of the estimated
  4636. * camera parameters. Both the object-releasing method and standard method are supported by this
  4637. * function. Use the parameter <b>iFixedPoint</b> for method selection. In the internal implementation,
  4638. * #calibrateCamera is a wrapper for this function.
  4639. *
  4640. * param objectPoints Vector of vectors of calibration pattern points in the calibration pattern
  4641. * coordinate space. See #calibrateCamera for details. If the method of releasing object to be used,
  4642. * the identical calibration board must be used in each view and it must be fully visible, and all
  4643. * objectPoints[i] must be the same and all points should be roughly close to a plane. <b>The calibration
  4644. * target has to be rigid, or at least static if the camera (rather than the calibration target) is
  4645. * shifted for grabbing images.</b>
  4646. * param imagePoints Vector of vectors of the projections of calibration pattern points. See
  4647. * #calibrateCamera for details.
  4648. * param imageSize Size of the image used only to initialize the intrinsic camera matrix.
  4649. * param iFixedPoint The index of the 3D object point in objectPoints[0] to be fixed. It also acts as
  4650. * a switch for calibration method selection. If object-releasing method to be used, pass in the
  4651. * parameter in the range of [1, objectPoints[0].size()-2], otherwise a value out of this range will
  4652. * make standard calibration method selected. Usually the top-right corner point of the calibration
  4653. * board grid is recommended to be fixed when object-releasing method being utilized. According to
  4654. * \cite strobl2011iccv, two other points are also fixed. In this implementation, objectPoints[0].front
  4655. * and objectPoints[0].back.z are used. With object-releasing method, accurate rvecs, tvecs and
  4656. * newObjPoints are only possible if coordinates of these three fixed points are accurate enough.
  4657. * param cameraMatrix Output 3x3 floating-point camera matrix. See #calibrateCamera for details.
  4658. * param distCoeffs Output vector of distortion coefficients. See #calibrateCamera for details.
  4659. * param rvecs Output vector of rotation vectors estimated for each pattern view. See #calibrateCamera
  4660. * for details.
  4661. * param tvecs Output vector of translation vectors estimated for each pattern view.
  4662. * param newObjPoints The updated output vector of calibration pattern points. The coordinates might
  4663. * be scaled based on three fixed points. The returned coordinates are accurate only if the above
  4664. * mentioned three fixed points are accurate. If not needed, noArray() can be passed in. This parameter
  4665. * is ignored with standard calibration method.
  4666. * param stdDeviationsIntrinsics Output vector of standard deviations estimated for intrinsic parameters.
  4667. * See #calibrateCamera for details.
  4668. * param stdDeviationsExtrinsics Output vector of standard deviations estimated for extrinsic parameters.
  4669. * See #calibrateCamera for details.
  4670. * param stdDeviationsObjPoints Output vector of standard deviations estimated for refined coordinates
  4671. * of calibration pattern points. It has the same size and order as objectPoints[0] vector. This
  4672. * parameter is ignored with standard calibration method.
  4673. * param perViewErrors Output vector of the RMS re-projection error estimated for each pattern view.
  4674. * param flags Different flags that may be zero or a combination of some predefined values. See
  4675. * #calibrateCamera for details. If the method of releasing object is used, the calibration time may
  4676. * be much longer. CALIB_USE_QR or CALIB_USE_LU could be used for faster calibration with potentially
  4677. * less precise and less stable in some rare cases.
  4678. * param criteria Termination criteria for the iterative optimization algorithm.
  4679. *
  4680. * return the overall RMS re-projection error.
  4681. *
  4682. * The function estimates the intrinsic camera parameters and extrinsic parameters for each of the
  4683. * views. The algorithm is based on CITE: Zhang2000, CITE: BouguetMCT and CITE: strobl2011iccv. See
  4684. * #calibrateCamera for other detailed explanations.
  4685. * SEE:
  4686. * calibrateCamera, findChessboardCorners, solvePnP, initCameraMatrix2D, stereoCalibrate, undistort
  4687. */
  4688. public static double calibrateCameraROExtended(List<Mat> objectPoints, List<Mat> imagePoints, Size imageSize, int iFixedPoint, Mat cameraMatrix, Mat distCoeffs, List<Mat> rvecs, List<Mat> tvecs, Mat newObjPoints, Mat stdDeviationsIntrinsics, Mat stdDeviationsExtrinsics, Mat stdDeviationsObjPoints, Mat perViewErrors, int flags, TermCriteria criteria)
  4689. {
  4690. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  4691. if (distCoeffs != null) distCoeffs.ThrowIfDisposed();
  4692. if (newObjPoints != null) newObjPoints.ThrowIfDisposed();
  4693. if (stdDeviationsIntrinsics != null) stdDeviationsIntrinsics.ThrowIfDisposed();
  4694. if (stdDeviationsExtrinsics != null) stdDeviationsExtrinsics.ThrowIfDisposed();
  4695. if (stdDeviationsObjPoints != null) stdDeviationsObjPoints.ThrowIfDisposed();
  4696. if (perViewErrors != null) perViewErrors.ThrowIfDisposed();
  4697. Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints);
  4698. Mat imagePoints_mat = Converters.vector_Mat_to_Mat(imagePoints);
  4699. Mat rvecs_mat = new Mat();
  4700. Mat tvecs_mat = new Mat();
  4701. double retVal = calib3d_Calib3d_calibrateCameraROExtended_10(objectPoints_mat.nativeObj, imagePoints_mat.nativeObj, imageSize.width, imageSize.height, iFixedPoint, cameraMatrix.nativeObj, distCoeffs.nativeObj, rvecs_mat.nativeObj, tvecs_mat.nativeObj, newObjPoints.nativeObj, stdDeviationsIntrinsics.nativeObj, stdDeviationsExtrinsics.nativeObj, stdDeviationsObjPoints.nativeObj, perViewErrors.nativeObj, flags, criteria.type, criteria.maxCount, criteria.epsilon);
  4702. Converters.Mat_to_vector_Mat(rvecs_mat, rvecs);
  4703. rvecs_mat.release();
  4704. Converters.Mat_to_vector_Mat(tvecs_mat, tvecs);
  4705. tvecs_mat.release();
  4706. return retVal;
  4707. }
  4708. /**
  4709. * Finds the camera intrinsic and extrinsic parameters from several views of a calibration pattern.
  4710. *
  4711. * This function is an extension of #calibrateCamera with the method of releasing object which was
  4712. * proposed in CITE: strobl2011iccv. In many common cases with inaccurate, unmeasured, roughly planar
  4713. * targets (calibration plates), this method can dramatically improve the precision of the estimated
  4714. * camera parameters. Both the object-releasing method and standard method are supported by this
  4715. * function. Use the parameter <b>iFixedPoint</b> for method selection. In the internal implementation,
  4716. * #calibrateCamera is a wrapper for this function.
  4717. *
  4718. * param objectPoints Vector of vectors of calibration pattern points in the calibration pattern
  4719. * coordinate space. See #calibrateCamera for details. If the method of releasing object to be used,
  4720. * the identical calibration board must be used in each view and it must be fully visible, and all
  4721. * objectPoints[i] must be the same and all points should be roughly close to a plane. <b>The calibration
  4722. * target has to be rigid, or at least static if the camera (rather than the calibration target) is
  4723. * shifted for grabbing images.</b>
  4724. * param imagePoints Vector of vectors of the projections of calibration pattern points. See
  4725. * #calibrateCamera for details.
  4726. * param imageSize Size of the image used only to initialize the intrinsic camera matrix.
  4727. * param iFixedPoint The index of the 3D object point in objectPoints[0] to be fixed. It also acts as
  4728. * a switch for calibration method selection. If object-releasing method to be used, pass in the
  4729. * parameter in the range of [1, objectPoints[0].size()-2], otherwise a value out of this range will
  4730. * make standard calibration method selected. Usually the top-right corner point of the calibration
  4731. * board grid is recommended to be fixed when object-releasing method being utilized. According to
  4732. * \cite strobl2011iccv, two other points are also fixed. In this implementation, objectPoints[0].front
  4733. * and objectPoints[0].back.z are used. With object-releasing method, accurate rvecs, tvecs and
  4734. * newObjPoints are only possible if coordinates of these three fixed points are accurate enough.
  4735. * param cameraMatrix Output 3x3 floating-point camera matrix. See #calibrateCamera for details.
  4736. * param distCoeffs Output vector of distortion coefficients. See #calibrateCamera for details.
  4737. * param rvecs Output vector of rotation vectors estimated for each pattern view. See #calibrateCamera
  4738. * for details.
  4739. * param tvecs Output vector of translation vectors estimated for each pattern view.
  4740. * param newObjPoints The updated output vector of calibration pattern points. The coordinates might
  4741. * be scaled based on three fixed points. The returned coordinates are accurate only if the above
  4742. * mentioned three fixed points are accurate. If not needed, noArray() can be passed in. This parameter
  4743. * is ignored with standard calibration method.
  4744. * param stdDeviationsIntrinsics Output vector of standard deviations estimated for intrinsic parameters.
  4745. * See #calibrateCamera for details.
  4746. * param stdDeviationsExtrinsics Output vector of standard deviations estimated for extrinsic parameters.
  4747. * See #calibrateCamera for details.
  4748. * param stdDeviationsObjPoints Output vector of standard deviations estimated for refined coordinates
  4749. * of calibration pattern points. It has the same size and order as objectPoints[0] vector. This
  4750. * parameter is ignored with standard calibration method.
  4751. * param perViewErrors Output vector of the RMS re-projection error estimated for each pattern view.
  4752. * param flags Different flags that may be zero or a combination of some predefined values. See
  4753. * #calibrateCamera for details. If the method of releasing object is used, the calibration time may
  4754. * be much longer. CALIB_USE_QR or CALIB_USE_LU could be used for faster calibration with potentially
  4755. * less precise and less stable in some rare cases.
  4756. *
  4757. * return the overall RMS re-projection error.
  4758. *
  4759. * The function estimates the intrinsic camera parameters and extrinsic parameters for each of the
  4760. * views. The algorithm is based on CITE: Zhang2000, CITE: BouguetMCT and CITE: strobl2011iccv. See
  4761. * #calibrateCamera for other detailed explanations.
  4762. * SEE:
  4763. * calibrateCamera, findChessboardCorners, solvePnP, initCameraMatrix2D, stereoCalibrate, undistort
  4764. */
  4765. public static double calibrateCameraROExtended(List<Mat> objectPoints, List<Mat> imagePoints, Size imageSize, int iFixedPoint, Mat cameraMatrix, Mat distCoeffs, List<Mat> rvecs, List<Mat> tvecs, Mat newObjPoints, Mat stdDeviationsIntrinsics, Mat stdDeviationsExtrinsics, Mat stdDeviationsObjPoints, Mat perViewErrors, int flags)
  4766. {
  4767. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  4768. if (distCoeffs != null) distCoeffs.ThrowIfDisposed();
  4769. if (newObjPoints != null) newObjPoints.ThrowIfDisposed();
  4770. if (stdDeviationsIntrinsics != null) stdDeviationsIntrinsics.ThrowIfDisposed();
  4771. if (stdDeviationsExtrinsics != null) stdDeviationsExtrinsics.ThrowIfDisposed();
  4772. if (stdDeviationsObjPoints != null) stdDeviationsObjPoints.ThrowIfDisposed();
  4773. if (perViewErrors != null) perViewErrors.ThrowIfDisposed();
  4774. Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints);
  4775. Mat imagePoints_mat = Converters.vector_Mat_to_Mat(imagePoints);
  4776. Mat rvecs_mat = new Mat();
  4777. Mat tvecs_mat = new Mat();
  4778. double retVal = calib3d_Calib3d_calibrateCameraROExtended_11(objectPoints_mat.nativeObj, imagePoints_mat.nativeObj, imageSize.width, imageSize.height, iFixedPoint, cameraMatrix.nativeObj, distCoeffs.nativeObj, rvecs_mat.nativeObj, tvecs_mat.nativeObj, newObjPoints.nativeObj, stdDeviationsIntrinsics.nativeObj, stdDeviationsExtrinsics.nativeObj, stdDeviationsObjPoints.nativeObj, perViewErrors.nativeObj, flags);
  4779. Converters.Mat_to_vector_Mat(rvecs_mat, rvecs);
  4780. rvecs_mat.release();
  4781. Converters.Mat_to_vector_Mat(tvecs_mat, tvecs);
  4782. tvecs_mat.release();
  4783. return retVal;
  4784. }
  4785. /**
  4786. * Finds the camera intrinsic and extrinsic parameters from several views of a calibration pattern.
  4787. *
  4788. * This function is an extension of #calibrateCamera with the method of releasing object which was
  4789. * proposed in CITE: strobl2011iccv. In many common cases with inaccurate, unmeasured, roughly planar
  4790. * targets (calibration plates), this method can dramatically improve the precision of the estimated
  4791. * camera parameters. Both the object-releasing method and standard method are supported by this
  4792. * function. Use the parameter <b>iFixedPoint</b> for method selection. In the internal implementation,
  4793. * #calibrateCamera is a wrapper for this function.
  4794. *
  4795. * param objectPoints Vector of vectors of calibration pattern points in the calibration pattern
  4796. * coordinate space. See #calibrateCamera for details. If the method of releasing object to be used,
  4797. * the identical calibration board must be used in each view and it must be fully visible, and all
  4798. * objectPoints[i] must be the same and all points should be roughly close to a plane. <b>The calibration
  4799. * target has to be rigid, or at least static if the camera (rather than the calibration target) is
  4800. * shifted for grabbing images.</b>
  4801. * param imagePoints Vector of vectors of the projections of calibration pattern points. See
  4802. * #calibrateCamera for details.
  4803. * param imageSize Size of the image used only to initialize the intrinsic camera matrix.
  4804. * param iFixedPoint The index of the 3D object point in objectPoints[0] to be fixed. It also acts as
  4805. * a switch for calibration method selection. If object-releasing method to be used, pass in the
  4806. * parameter in the range of [1, objectPoints[0].size()-2], otherwise a value out of this range will
  4807. * make standard calibration method selected. Usually the top-right corner point of the calibration
  4808. * board grid is recommended to be fixed when object-releasing method being utilized. According to
  4809. * \cite strobl2011iccv, two other points are also fixed. In this implementation, objectPoints[0].front
  4810. * and objectPoints[0].back.z are used. With object-releasing method, accurate rvecs, tvecs and
  4811. * newObjPoints are only possible if coordinates of these three fixed points are accurate enough.
  4812. * param cameraMatrix Output 3x3 floating-point camera matrix. See #calibrateCamera for details.
  4813. * param distCoeffs Output vector of distortion coefficients. See #calibrateCamera for details.
  4814. * param rvecs Output vector of rotation vectors estimated for each pattern view. See #calibrateCamera
  4815. * for details.
  4816. * param tvecs Output vector of translation vectors estimated for each pattern view.
  4817. * param newObjPoints The updated output vector of calibration pattern points. The coordinates might
  4818. * be scaled based on three fixed points. The returned coordinates are accurate only if the above
  4819. * mentioned three fixed points are accurate. If not needed, noArray() can be passed in. This parameter
  4820. * is ignored with standard calibration method.
  4821. * param stdDeviationsIntrinsics Output vector of standard deviations estimated for intrinsic parameters.
  4822. * See #calibrateCamera for details.
  4823. * param stdDeviationsExtrinsics Output vector of standard deviations estimated for extrinsic parameters.
  4824. * See #calibrateCamera for details.
  4825. * param stdDeviationsObjPoints Output vector of standard deviations estimated for refined coordinates
  4826. * of calibration pattern points. It has the same size and order as objectPoints[0] vector. This
  4827. * parameter is ignored with standard calibration method.
  4828. * param perViewErrors Output vector of the RMS re-projection error estimated for each pattern view.
  4829. * #calibrateCamera for details. If the method of releasing object is used, the calibration time may
  4830. * be much longer. CALIB_USE_QR or CALIB_USE_LU could be used for faster calibration with potentially
  4831. * less precise and less stable in some rare cases.
  4832. *
  4833. * return the overall RMS re-projection error.
  4834. *
  4835. * The function estimates the intrinsic camera parameters and extrinsic parameters for each of the
  4836. * views. The algorithm is based on CITE: Zhang2000, CITE: BouguetMCT and CITE: strobl2011iccv. See
  4837. * #calibrateCamera for other detailed explanations.
  4838. * SEE:
  4839. * calibrateCamera, findChessboardCorners, solvePnP, initCameraMatrix2D, stereoCalibrate, undistort
  4840. */
  4841. public static double calibrateCameraROExtended(List<Mat> objectPoints, List<Mat> imagePoints, Size imageSize, int iFixedPoint, Mat cameraMatrix, Mat distCoeffs, List<Mat> rvecs, List<Mat> tvecs, Mat newObjPoints, Mat stdDeviationsIntrinsics, Mat stdDeviationsExtrinsics, Mat stdDeviationsObjPoints, Mat perViewErrors)
  4842. {
  4843. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  4844. if (distCoeffs != null) distCoeffs.ThrowIfDisposed();
  4845. if (newObjPoints != null) newObjPoints.ThrowIfDisposed();
  4846. if (stdDeviationsIntrinsics != null) stdDeviationsIntrinsics.ThrowIfDisposed();
  4847. if (stdDeviationsExtrinsics != null) stdDeviationsExtrinsics.ThrowIfDisposed();
  4848. if (stdDeviationsObjPoints != null) stdDeviationsObjPoints.ThrowIfDisposed();
  4849. if (perViewErrors != null) perViewErrors.ThrowIfDisposed();
  4850. Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints);
  4851. Mat imagePoints_mat = Converters.vector_Mat_to_Mat(imagePoints);
  4852. Mat rvecs_mat = new Mat();
  4853. Mat tvecs_mat = new Mat();
  4854. double retVal = calib3d_Calib3d_calibrateCameraROExtended_12(objectPoints_mat.nativeObj, imagePoints_mat.nativeObj, imageSize.width, imageSize.height, iFixedPoint, cameraMatrix.nativeObj, distCoeffs.nativeObj, rvecs_mat.nativeObj, tvecs_mat.nativeObj, newObjPoints.nativeObj, stdDeviationsIntrinsics.nativeObj, stdDeviationsExtrinsics.nativeObj, stdDeviationsObjPoints.nativeObj, perViewErrors.nativeObj);
  4855. Converters.Mat_to_vector_Mat(rvecs_mat, rvecs);
  4856. rvecs_mat.release();
  4857. Converters.Mat_to_vector_Mat(tvecs_mat, tvecs);
  4858. tvecs_mat.release();
  4859. return retVal;
  4860. }
  4861. //
  4862. // C++: double cv::calibrateCameraRO(vector_Mat objectPoints, vector_Mat imagePoints, Size imageSize, int iFixedPoint, Mat& cameraMatrix, Mat& distCoeffs, vector_Mat& rvecs, vector_Mat& tvecs, Mat& newObjPoints, int flags = 0, TermCriteria criteria = TermCriteria( TermCriteria::COUNT + TermCriteria::EPS, 30, DBL_EPSILON))
  4863. //
  4864. public static double calibrateCameraRO(List<Mat> objectPoints, List<Mat> imagePoints, Size imageSize, int iFixedPoint, Mat cameraMatrix, Mat distCoeffs, List<Mat> rvecs, List<Mat> tvecs, Mat newObjPoints, int flags, TermCriteria criteria)
  4865. {
  4866. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  4867. if (distCoeffs != null) distCoeffs.ThrowIfDisposed();
  4868. if (newObjPoints != null) newObjPoints.ThrowIfDisposed();
  4869. Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints);
  4870. Mat imagePoints_mat = Converters.vector_Mat_to_Mat(imagePoints);
  4871. Mat rvecs_mat = new Mat();
  4872. Mat tvecs_mat = new Mat();
  4873. double retVal = calib3d_Calib3d_calibrateCameraRO_10(objectPoints_mat.nativeObj, imagePoints_mat.nativeObj, imageSize.width, imageSize.height, iFixedPoint, cameraMatrix.nativeObj, distCoeffs.nativeObj, rvecs_mat.nativeObj, tvecs_mat.nativeObj, newObjPoints.nativeObj, flags, criteria.type, criteria.maxCount, criteria.epsilon);
  4874. Converters.Mat_to_vector_Mat(rvecs_mat, rvecs);
  4875. rvecs_mat.release();
  4876. Converters.Mat_to_vector_Mat(tvecs_mat, tvecs);
  4877. tvecs_mat.release();
  4878. return retVal;
  4879. }
  4880. public static double calibrateCameraRO(List<Mat> objectPoints, List<Mat> imagePoints, Size imageSize, int iFixedPoint, Mat cameraMatrix, Mat distCoeffs, List<Mat> rvecs, List<Mat> tvecs, Mat newObjPoints, int flags)
  4881. {
  4882. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  4883. if (distCoeffs != null) distCoeffs.ThrowIfDisposed();
  4884. if (newObjPoints != null) newObjPoints.ThrowIfDisposed();
  4885. Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints);
  4886. Mat imagePoints_mat = Converters.vector_Mat_to_Mat(imagePoints);
  4887. Mat rvecs_mat = new Mat();
  4888. Mat tvecs_mat = new Mat();
  4889. double retVal = calib3d_Calib3d_calibrateCameraRO_11(objectPoints_mat.nativeObj, imagePoints_mat.nativeObj, imageSize.width, imageSize.height, iFixedPoint, cameraMatrix.nativeObj, distCoeffs.nativeObj, rvecs_mat.nativeObj, tvecs_mat.nativeObj, newObjPoints.nativeObj, flags);
  4890. Converters.Mat_to_vector_Mat(rvecs_mat, rvecs);
  4891. rvecs_mat.release();
  4892. Converters.Mat_to_vector_Mat(tvecs_mat, tvecs);
  4893. tvecs_mat.release();
  4894. return retVal;
  4895. }
  4896. public static double calibrateCameraRO(List<Mat> objectPoints, List<Mat> imagePoints, Size imageSize, int iFixedPoint, Mat cameraMatrix, Mat distCoeffs, List<Mat> rvecs, List<Mat> tvecs, Mat newObjPoints)
  4897. {
  4898. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  4899. if (distCoeffs != null) distCoeffs.ThrowIfDisposed();
  4900. if (newObjPoints != null) newObjPoints.ThrowIfDisposed();
  4901. Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints);
  4902. Mat imagePoints_mat = Converters.vector_Mat_to_Mat(imagePoints);
  4903. Mat rvecs_mat = new Mat();
  4904. Mat tvecs_mat = new Mat();
  4905. double retVal = calib3d_Calib3d_calibrateCameraRO_12(objectPoints_mat.nativeObj, imagePoints_mat.nativeObj, imageSize.width, imageSize.height, iFixedPoint, cameraMatrix.nativeObj, distCoeffs.nativeObj, rvecs_mat.nativeObj, tvecs_mat.nativeObj, newObjPoints.nativeObj);
  4906. Converters.Mat_to_vector_Mat(rvecs_mat, rvecs);
  4907. rvecs_mat.release();
  4908. Converters.Mat_to_vector_Mat(tvecs_mat, tvecs);
  4909. tvecs_mat.release();
  4910. return retVal;
  4911. }
  4912. //
  4913. // C++: void cv::calibrationMatrixValues(Mat cameraMatrix, Size imageSize, double apertureWidth, double apertureHeight, double& fovx, double& fovy, double& focalLength, Point2d& principalPoint, double& aspectRatio)
  4914. //
  4915. /**
  4916. * Computes useful camera characteristics from the camera intrinsic matrix.
  4917. *
  4918. * param cameraMatrix Input camera intrinsic matrix that can be estimated by #calibrateCamera or
  4919. * #stereoCalibrate .
  4920. * param imageSize Input image size in pixels.
  4921. * param apertureWidth Physical width in mm of the sensor.
  4922. * param apertureHeight Physical height in mm of the sensor.
  4923. * param fovx Output field of view in degrees along the horizontal sensor axis.
  4924. * param fovy Output field of view in degrees along the vertical sensor axis.
  4925. * param focalLength Focal length of the lens in mm.
  4926. * param principalPoint Principal point in mm.
  4927. * param aspectRatio \(f_y/f_x\)
  4928. *
  4929. * The function computes various useful camera characteristics from the previously estimated camera
  4930. * matrix.
  4931. *
  4932. * <b>Note:</b>
  4933. * Do keep in mind that the unity measure 'mm' stands for whatever unit of measure one chooses for
  4934. * the chessboard pitch (it can thus be any value).
  4935. */
  4936. public static void calibrationMatrixValues(Mat cameraMatrix, Size imageSize, double apertureWidth, double apertureHeight, double[] fovx, double[] fovy, double[] focalLength, Point principalPoint, double[] aspectRatio)
  4937. {
  4938. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  4939. double[] fovx_out = new double[1];
  4940. double[] fovy_out = new double[1];
  4941. double[] focalLength_out = new double[1];
  4942. double[] principalPoint_out = new double[2];
  4943. double[] aspectRatio_out = new double[1];
  4944. calib3d_Calib3d_calibrationMatrixValues_10(cameraMatrix.nativeObj, imageSize.width, imageSize.height, apertureWidth, apertureHeight, fovx_out, fovy_out, focalLength_out, principalPoint_out, aspectRatio_out);
  4945. if (fovx != null) fovx[0] = (double)fovx_out[0];
  4946. if (fovy != null) fovy[0] = (double)fovy_out[0];
  4947. if (focalLength != null) focalLength[0] = (double)focalLength_out[0];
  4948. if (principalPoint != null) { principalPoint.x = principalPoint_out[0]; principalPoint.y = principalPoint_out[1]; }
  4949. if (aspectRatio != null) aspectRatio[0] = (double)aspectRatio_out[0];
  4950. }
  4951. //
  4952. // C++: double cv::stereoCalibrate(vector_Mat objectPoints, vector_Mat imagePoints1, vector_Mat imagePoints2, Mat& cameraMatrix1, Mat& distCoeffs1, Mat& cameraMatrix2, Mat& distCoeffs2, Size imageSize, Mat& R, Mat& T, Mat& E, Mat& F, vector_Mat& rvecs, vector_Mat& tvecs, Mat& perViewErrors, int flags = CALIB_FIX_INTRINSIC, TermCriteria criteria = TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, 30, 1e-6))
  4953. //
  4954. /**
  4955. * Calibrates a stereo camera set up. This function finds the intrinsic parameters
  4956. * for each of the two cameras and the extrinsic parameters between the two cameras.
  4957. *
  4958. * param objectPoints Vector of vectors of the calibration pattern points. The same structure as
  4959. * in REF: calibrateCamera. For each pattern view, both cameras need to see the same object
  4960. * points. Therefore, objectPoints.size(), imagePoints1.size(), and imagePoints2.size() need to be
  4961. * equal as well as objectPoints[i].size(), imagePoints1[i].size(), and imagePoints2[i].size() need to
  4962. * be equal for each i.
  4963. * param imagePoints1 Vector of vectors of the projections of the calibration pattern points,
  4964. * observed by the first camera. The same structure as in REF: calibrateCamera.
  4965. * param imagePoints2 Vector of vectors of the projections of the calibration pattern points,
  4966. * observed by the second camera. The same structure as in REF: calibrateCamera.
  4967. * param cameraMatrix1 Input/output camera intrinsic matrix for the first camera, the same as in
  4968. * REF: calibrateCamera. Furthermore, for the stereo case, additional flags may be used, see below.
  4969. * param distCoeffs1 Input/output vector of distortion coefficients, the same as in
  4970. * REF: calibrateCamera.
  4971. * param cameraMatrix2 Input/output second camera intrinsic matrix for the second camera. See description for
  4972. * cameraMatrix1.
  4973. * param distCoeffs2 Input/output lens distortion coefficients for the second camera. See
  4974. * description for distCoeffs1.
  4975. * param imageSize Size of the image used only to initialize the camera intrinsic matrices.
  4976. * param R Output rotation matrix. Together with the translation vector T, this matrix brings
  4977. * points given in the first camera's coordinate system to points in the second camera's
  4978. * coordinate system. In more technical terms, the tuple of R and T performs a change of basis
  4979. * from the first camera's coordinate system to the second camera's coordinate system. Due to its
  4980. * duality, this tuple is equivalent to the position of the first camera with respect to the
  4981. * second camera coordinate system.
  4982. * param T Output translation vector, see description above.
  4983. * param E Output essential matrix.
  4984. * param F Output fundamental matrix.
  4985. * param rvecs Output vector of rotation vectors ( REF: Rodrigues ) estimated for each pattern view in the
  4986. * coordinate system of the first camera of the stereo pair (e.g. std::vector&lt;cv::Mat&gt;). More in detail, each
  4987. * i-th rotation vector together with the corresponding i-th translation vector (see the next output parameter
  4988. * description) brings the calibration pattern from the object coordinate space (in which object points are
  4989. * specified) to the camera coordinate space of the first camera of the stereo pair. In more technical terms,
  4990. * the tuple of the i-th rotation and translation vector performs a change of basis from object coordinate space
  4991. * to camera coordinate space of the first camera of the stereo pair.
  4992. * param tvecs Output vector of translation vectors estimated for each pattern view, see parameter description
  4993. * of previous output parameter ( rvecs ).
  4994. * param perViewErrors Output vector of the RMS re-projection error estimated for each pattern view.
  4995. * param flags Different flags that may be zero or a combination of the following values:
  4996. * <ul>
  4997. * <li>
  4998. * REF: CALIB_FIX_INTRINSIC Fix cameraMatrix? and distCoeffs? so that only R, T, E, and F
  4999. * matrices are estimated.
  5000. * </li>
  5001. * <li>
  5002. * REF: CALIB_USE_INTRINSIC_GUESS Optimize some or all of the intrinsic parameters
  5003. * according to the specified flags. Initial values are provided by the user.
  5004. * </li>
  5005. * <li>
  5006. * REF: CALIB_USE_EXTRINSIC_GUESS R and T contain valid initial values that are optimized further.
  5007. * Otherwise R and T are initialized to the median value of the pattern views (each dimension separately).
  5008. * </li>
  5009. * <li>
  5010. * REF: CALIB_FIX_PRINCIPAL_POINT Fix the principal points during the optimization.
  5011. * </li>
  5012. * <li>
  5013. * REF: CALIB_FIX_FOCAL_LENGTH Fix \(f^{(j)}_x\) and \(f^{(j)}_y\) .
  5014. * </li>
  5015. * <li>
  5016. * REF: CALIB_FIX_ASPECT_RATIO Optimize \(f^{(j)}_y\) . Fix the ratio \(f^{(j)}_x/f^{(j)}_y\)
  5017. * .
  5018. * </li>
  5019. * <li>
  5020. * REF: CALIB_SAME_FOCAL_LENGTH Enforce \(f^{(0)}_x=f^{(1)}_x\) and \(f^{(0)}_y=f^{(1)}_y\) .
  5021. * </li>
  5022. * <li>
  5023. * REF: CALIB_ZERO_TANGENT_DIST Set tangential distortion coefficients for each camera to
  5024. * zeros and fix there.
  5025. * </li>
  5026. * <li>
  5027. * REF: CALIB_FIX_K1,..., REF: CALIB_FIX_K6 Do not change the corresponding radial
  5028. * distortion coefficient during the optimization. If REF: CALIB_USE_INTRINSIC_GUESS is set,
  5029. * the coefficient from the supplied distCoeffs matrix is used. Otherwise, it is set to 0.
  5030. * </li>
  5031. * <li>
  5032. * REF: CALIB_RATIONAL_MODEL Enable coefficients k4, k5, and k6. To provide the backward
  5033. * compatibility, this extra flag should be explicitly specified to make the calibration
  5034. * function use the rational model and return 8 coefficients. If the flag is not set, the
  5035. * function computes and returns only 5 distortion coefficients.
  5036. * </li>
  5037. * <li>
  5038. * REF: CALIB_THIN_PRISM_MODEL Coefficients s1, s2, s3 and s4 are enabled. To provide the
  5039. * backward compatibility, this extra flag should be explicitly specified to make the
  5040. * calibration function use the thin prism model and return 12 coefficients. If the flag is not
  5041. * set, the function computes and returns only 5 distortion coefficients.
  5042. * </li>
  5043. * <li>
  5044. * REF: CALIB_FIX_S1_S2_S3_S4 The thin prism distortion coefficients are not changed during
  5045. * the optimization. If REF: CALIB_USE_INTRINSIC_GUESS is set, the coefficient from the
  5046. * supplied distCoeffs matrix is used. Otherwise, it is set to 0.
  5047. * </li>
  5048. * <li>
  5049. * REF: CALIB_TILTED_MODEL Coefficients tauX and tauY are enabled. To provide the
  5050. * backward compatibility, this extra flag should be explicitly specified to make the
  5051. * calibration function use the tilted sensor model and return 14 coefficients. If the flag is not
  5052. * set, the function computes and returns only 5 distortion coefficients.
  5053. * </li>
  5054. * <li>
  5055. * REF: CALIB_FIX_TAUX_TAUY The coefficients of the tilted sensor model are not changed during
  5056. * the optimization. If REF: CALIB_USE_INTRINSIC_GUESS is set, the coefficient from the
  5057. * supplied distCoeffs matrix is used. Otherwise, it is set to 0.
  5058. * </li>
  5059. * </ul>
  5060. * param criteria Termination criteria for the iterative optimization algorithm.
  5061. *
  5062. * The function estimates the transformation between two cameras making a stereo pair. If one computes
  5063. * the poses of an object relative to the first camera and to the second camera,
  5064. * ( \(R_1\),\(T_1\) ) and (\(R_2\),\(T_2\)), respectively, for a stereo camera where the
  5065. * relative position and orientation between the two cameras are fixed, then those poses definitely
  5066. * relate to each other. This means, if the relative position and orientation (\(R\),\(T\)) of the
  5067. * two cameras is known, it is possible to compute (\(R_2\),\(T_2\)) when (\(R_1\),\(T_1\)) is
  5068. * given. This is what the described function does. It computes (\(R\),\(T\)) such that:
  5069. *
  5070. * \(R_2=R R_1\)
  5071. * \(T_2=R T_1 + T.\)
  5072. *
  5073. * Therefore, one can compute the coordinate representation of a 3D point for the second camera's
  5074. * coordinate system when given the point's coordinate representation in the first camera's coordinate
  5075. * system:
  5076. *
  5077. * \(\begin{bmatrix}
  5078. * X_2 \\
  5079. * Y_2 \\
  5080. * Z_2 \\
  5081. * 1
  5082. * \end{bmatrix} = \begin{bmatrix}
  5083. * R &amp; T \\
  5084. * 0 &amp; 1
  5085. * \end{bmatrix} \begin{bmatrix}
  5086. * X_1 \\
  5087. * Y_1 \\
  5088. * Z_1 \\
  5089. * 1
  5090. * \end{bmatrix}.\)
  5091. *
  5092. *
  5093. * Optionally, it computes the essential matrix E:
  5094. *
  5095. * \(E= \vecthreethree{0}{-T_2}{T_1}{T_2}{0}{-T_0}{-T_1}{T_0}{0} R\)
  5096. *
  5097. * where \(T_i\) are components of the translation vector \(T\) : \(T=[T_0, T_1, T_2]^T\) .
  5098. * And the function can also compute the fundamental matrix F:
  5099. *
  5100. * \(F = cameraMatrix2^{-T}\cdot E \cdot cameraMatrix1^{-1}\)
  5101. *
  5102. * Besides the stereo-related information, the function can also perform a full calibration of each of
  5103. * the two cameras. However, due to the high dimensionality of the parameter space and noise in the
  5104. * input data, the function can diverge from the correct solution. If the intrinsic parameters can be
  5105. * estimated with high accuracy for each of the cameras individually (for example, using
  5106. * #calibrateCamera ), you are recommended to do so and then pass REF: CALIB_FIX_INTRINSIC flag to the
  5107. * function along with the computed intrinsic parameters. Otherwise, if all the parameters are
  5108. * estimated at once, it makes sense to restrict some parameters, for example, pass
  5109. * REF: CALIB_SAME_FOCAL_LENGTH and REF: CALIB_ZERO_TANGENT_DIST flags, which is usually a
  5110. * reasonable assumption.
  5111. *
  5112. * Similarly to #calibrateCamera, the function minimizes the total re-projection error for all the
  5113. * points in all the available views from both cameras. The function returns the final value of the
  5114. * re-projection error.
  5115. * return automatically generated
  5116. */
  5117. public static double stereoCalibrateExtended(List<Mat> objectPoints, List<Mat> imagePoints1, List<Mat> imagePoints2, Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Size imageSize, Mat R, Mat T, Mat E, Mat F, List<Mat> rvecs, List<Mat> tvecs, Mat perViewErrors, int flags, TermCriteria criteria)
  5118. {
  5119. if (cameraMatrix1 != null) cameraMatrix1.ThrowIfDisposed();
  5120. if (distCoeffs1 != null) distCoeffs1.ThrowIfDisposed();
  5121. if (cameraMatrix2 != null) cameraMatrix2.ThrowIfDisposed();
  5122. if (distCoeffs2 != null) distCoeffs2.ThrowIfDisposed();
  5123. if (R != null) R.ThrowIfDisposed();
  5124. if (T != null) T.ThrowIfDisposed();
  5125. if (E != null) E.ThrowIfDisposed();
  5126. if (F != null) F.ThrowIfDisposed();
  5127. if (perViewErrors != null) perViewErrors.ThrowIfDisposed();
  5128. Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints);
  5129. Mat imagePoints1_mat = Converters.vector_Mat_to_Mat(imagePoints1);
  5130. Mat imagePoints2_mat = Converters.vector_Mat_to_Mat(imagePoints2);
  5131. Mat rvecs_mat = new Mat();
  5132. Mat tvecs_mat = new Mat();
  5133. double retVal = calib3d_Calib3d_stereoCalibrateExtended_10(objectPoints_mat.nativeObj, imagePoints1_mat.nativeObj, imagePoints2_mat.nativeObj, cameraMatrix1.nativeObj, distCoeffs1.nativeObj, cameraMatrix2.nativeObj, distCoeffs2.nativeObj, imageSize.width, imageSize.height, R.nativeObj, T.nativeObj, E.nativeObj, F.nativeObj, rvecs_mat.nativeObj, tvecs_mat.nativeObj, perViewErrors.nativeObj, flags, criteria.type, criteria.maxCount, criteria.epsilon);
  5134. Converters.Mat_to_vector_Mat(rvecs_mat, rvecs);
  5135. rvecs_mat.release();
  5136. Converters.Mat_to_vector_Mat(tvecs_mat, tvecs);
  5137. tvecs_mat.release();
  5138. return retVal;
  5139. }
  5140. /**
  5141. * Calibrates a stereo camera set up. This function finds the intrinsic parameters
  5142. * for each of the two cameras and the extrinsic parameters between the two cameras.
  5143. *
  5144. * param objectPoints Vector of vectors of the calibration pattern points. The same structure as
  5145. * in REF: calibrateCamera. For each pattern view, both cameras need to see the same object
  5146. * points. Therefore, objectPoints.size(), imagePoints1.size(), and imagePoints2.size() need to be
  5147. * equal as well as objectPoints[i].size(), imagePoints1[i].size(), and imagePoints2[i].size() need to
  5148. * be equal for each i.
  5149. * param imagePoints1 Vector of vectors of the projections of the calibration pattern points,
  5150. * observed by the first camera. The same structure as in REF: calibrateCamera.
  5151. * param imagePoints2 Vector of vectors of the projections of the calibration pattern points,
  5152. * observed by the second camera. The same structure as in REF: calibrateCamera.
  5153. * param cameraMatrix1 Input/output camera intrinsic matrix for the first camera, the same as in
  5154. * REF: calibrateCamera. Furthermore, for the stereo case, additional flags may be used, see below.
  5155. * param distCoeffs1 Input/output vector of distortion coefficients, the same as in
  5156. * REF: calibrateCamera.
  5157. * param cameraMatrix2 Input/output second camera intrinsic matrix for the second camera. See description for
  5158. * cameraMatrix1.
  5159. * param distCoeffs2 Input/output lens distortion coefficients for the second camera. See
  5160. * description for distCoeffs1.
  5161. * param imageSize Size of the image used only to initialize the camera intrinsic matrices.
  5162. * param R Output rotation matrix. Together with the translation vector T, this matrix brings
  5163. * points given in the first camera's coordinate system to points in the second camera's
  5164. * coordinate system. In more technical terms, the tuple of R and T performs a change of basis
  5165. * from the first camera's coordinate system to the second camera's coordinate system. Due to its
  5166. * duality, this tuple is equivalent to the position of the first camera with respect to the
  5167. * second camera coordinate system.
  5168. * param T Output translation vector, see description above.
  5169. * param E Output essential matrix.
  5170. * param F Output fundamental matrix.
  5171. * param rvecs Output vector of rotation vectors ( REF: Rodrigues ) estimated for each pattern view in the
  5172. * coordinate system of the first camera of the stereo pair (e.g. std::vector&lt;cv::Mat&gt;). More in detail, each
  5173. * i-th rotation vector together with the corresponding i-th translation vector (see the next output parameter
  5174. * description) brings the calibration pattern from the object coordinate space (in which object points are
  5175. * specified) to the camera coordinate space of the first camera of the stereo pair. In more technical terms,
  5176. * the tuple of the i-th rotation and translation vector performs a change of basis from object coordinate space
  5177. * to camera coordinate space of the first camera of the stereo pair.
  5178. * param tvecs Output vector of translation vectors estimated for each pattern view, see parameter description
  5179. * of previous output parameter ( rvecs ).
  5180. * param perViewErrors Output vector of the RMS re-projection error estimated for each pattern view.
  5181. * param flags Different flags that may be zero or a combination of the following values:
  5182. * <ul>
  5183. * <li>
  5184. * REF: CALIB_FIX_INTRINSIC Fix cameraMatrix? and distCoeffs? so that only R, T, E, and F
  5185. * matrices are estimated.
  5186. * </li>
  5187. * <li>
  5188. * REF: CALIB_USE_INTRINSIC_GUESS Optimize some or all of the intrinsic parameters
  5189. * according to the specified flags. Initial values are provided by the user.
  5190. * </li>
  5191. * <li>
  5192. * REF: CALIB_USE_EXTRINSIC_GUESS R and T contain valid initial values that are optimized further.
  5193. * Otherwise R and T are initialized to the median value of the pattern views (each dimension separately).
  5194. * </li>
  5195. * <li>
  5196. * REF: CALIB_FIX_PRINCIPAL_POINT Fix the principal points during the optimization.
  5197. * </li>
  5198. * <li>
  5199. * REF: CALIB_FIX_FOCAL_LENGTH Fix \(f^{(j)}_x\) and \(f^{(j)}_y\) .
  5200. * </li>
  5201. * <li>
  5202. * REF: CALIB_FIX_ASPECT_RATIO Optimize \(f^{(j)}_y\) . Fix the ratio \(f^{(j)}_x/f^{(j)}_y\)
  5203. * .
  5204. * </li>
  5205. * <li>
  5206. * REF: CALIB_SAME_FOCAL_LENGTH Enforce \(f^{(0)}_x=f^{(1)}_x\) and \(f^{(0)}_y=f^{(1)}_y\) .
  5207. * </li>
  5208. * <li>
  5209. * REF: CALIB_ZERO_TANGENT_DIST Set tangential distortion coefficients for each camera to
  5210. * zeros and fix there.
  5211. * </li>
  5212. * <li>
  5213. * REF: CALIB_FIX_K1,..., REF: CALIB_FIX_K6 Do not change the corresponding radial
  5214. * distortion coefficient during the optimization. If REF: CALIB_USE_INTRINSIC_GUESS is set,
  5215. * the coefficient from the supplied distCoeffs matrix is used. Otherwise, it is set to 0.
  5216. * </li>
  5217. * <li>
  5218. * REF: CALIB_RATIONAL_MODEL Enable coefficients k4, k5, and k6. To provide the backward
  5219. * compatibility, this extra flag should be explicitly specified to make the calibration
  5220. * function use the rational model and return 8 coefficients. If the flag is not set, the
  5221. * function computes and returns only 5 distortion coefficients.
  5222. * </li>
  5223. * <li>
  5224. * REF: CALIB_THIN_PRISM_MODEL Coefficients s1, s2, s3 and s4 are enabled. To provide the
  5225. * backward compatibility, this extra flag should be explicitly specified to make the
  5226. * calibration function use the thin prism model and return 12 coefficients. If the flag is not
  5227. * set, the function computes and returns only 5 distortion coefficients.
  5228. * </li>
  5229. * <li>
  5230. * REF: CALIB_FIX_S1_S2_S3_S4 The thin prism distortion coefficients are not changed during
  5231. * the optimization. If REF: CALIB_USE_INTRINSIC_GUESS is set, the coefficient from the
  5232. * supplied distCoeffs matrix is used. Otherwise, it is set to 0.
  5233. * </li>
  5234. * <li>
  5235. * REF: CALIB_TILTED_MODEL Coefficients tauX and tauY are enabled. To provide the
  5236. * backward compatibility, this extra flag should be explicitly specified to make the
  5237. * calibration function use the tilted sensor model and return 14 coefficients. If the flag is not
  5238. * set, the function computes and returns only 5 distortion coefficients.
  5239. * </li>
  5240. * <li>
  5241. * REF: CALIB_FIX_TAUX_TAUY The coefficients of the tilted sensor model are not changed during
  5242. * the optimization. If REF: CALIB_USE_INTRINSIC_GUESS is set, the coefficient from the
  5243. * supplied distCoeffs matrix is used. Otherwise, it is set to 0.
  5244. * </li>
  5245. * </ul>
  5246. *
  5247. * The function estimates the transformation between two cameras making a stereo pair. If one computes
  5248. * the poses of an object relative to the first camera and to the second camera,
  5249. * ( \(R_1\),\(T_1\) ) and (\(R_2\),\(T_2\)), respectively, for a stereo camera where the
  5250. * relative position and orientation between the two cameras are fixed, then those poses definitely
  5251. * relate to each other. This means, if the relative position and orientation (\(R\),\(T\)) of the
  5252. * two cameras is known, it is possible to compute (\(R_2\),\(T_2\)) when (\(R_1\),\(T_1\)) is
  5253. * given. This is what the described function does. It computes (\(R\),\(T\)) such that:
  5254. *
  5255. * \(R_2=R R_1\)
  5256. * \(T_2=R T_1 + T.\)
  5257. *
  5258. * Therefore, one can compute the coordinate representation of a 3D point for the second camera's
  5259. * coordinate system when given the point's coordinate representation in the first camera's coordinate
  5260. * system:
  5261. *
  5262. * \(\begin{bmatrix}
  5263. * X_2 \\
  5264. * Y_2 \\
  5265. * Z_2 \\
  5266. * 1
  5267. * \end{bmatrix} = \begin{bmatrix}
  5268. * R &amp; T \\
  5269. * 0 &amp; 1
  5270. * \end{bmatrix} \begin{bmatrix}
  5271. * X_1 \\
  5272. * Y_1 \\
  5273. * Z_1 \\
  5274. * 1
  5275. * \end{bmatrix}.\)
  5276. *
  5277. *
  5278. * Optionally, it computes the essential matrix E:
  5279. *
  5280. * \(E= \vecthreethree{0}{-T_2}{T_1}{T_2}{0}{-T_0}{-T_1}{T_0}{0} R\)
  5281. *
  5282. * where \(T_i\) are components of the translation vector \(T\) : \(T=[T_0, T_1, T_2]^T\) .
  5283. * And the function can also compute the fundamental matrix F:
  5284. *
  5285. * \(F = cameraMatrix2^{-T}\cdot E \cdot cameraMatrix1^{-1}\)
  5286. *
  5287. * Besides the stereo-related information, the function can also perform a full calibration of each of
  5288. * the two cameras. However, due to the high dimensionality of the parameter space and noise in the
  5289. * input data, the function can diverge from the correct solution. If the intrinsic parameters can be
  5290. * estimated with high accuracy for each of the cameras individually (for example, using
  5291. * #calibrateCamera ), you are recommended to do so and then pass REF: CALIB_FIX_INTRINSIC flag to the
  5292. * function along with the computed intrinsic parameters. Otherwise, if all the parameters are
  5293. * estimated at once, it makes sense to restrict some parameters, for example, pass
  5294. * REF: CALIB_SAME_FOCAL_LENGTH and REF: CALIB_ZERO_TANGENT_DIST flags, which is usually a
  5295. * reasonable assumption.
  5296. *
  5297. * Similarly to #calibrateCamera, the function minimizes the total re-projection error for all the
  5298. * points in all the available views from both cameras. The function returns the final value of the
  5299. * re-projection error.
  5300. * return automatically generated
  5301. */
  5302. public static double stereoCalibrateExtended(List<Mat> objectPoints, List<Mat> imagePoints1, List<Mat> imagePoints2, Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Size imageSize, Mat R, Mat T, Mat E, Mat F, List<Mat> rvecs, List<Mat> tvecs, Mat perViewErrors, int flags)
  5303. {
  5304. if (cameraMatrix1 != null) cameraMatrix1.ThrowIfDisposed();
  5305. if (distCoeffs1 != null) distCoeffs1.ThrowIfDisposed();
  5306. if (cameraMatrix2 != null) cameraMatrix2.ThrowIfDisposed();
  5307. if (distCoeffs2 != null) distCoeffs2.ThrowIfDisposed();
  5308. if (R != null) R.ThrowIfDisposed();
  5309. if (T != null) T.ThrowIfDisposed();
  5310. if (E != null) E.ThrowIfDisposed();
  5311. if (F != null) F.ThrowIfDisposed();
  5312. if (perViewErrors != null) perViewErrors.ThrowIfDisposed();
  5313. Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints);
  5314. Mat imagePoints1_mat = Converters.vector_Mat_to_Mat(imagePoints1);
  5315. Mat imagePoints2_mat = Converters.vector_Mat_to_Mat(imagePoints2);
  5316. Mat rvecs_mat = new Mat();
  5317. Mat tvecs_mat = new Mat();
  5318. double retVal = calib3d_Calib3d_stereoCalibrateExtended_11(objectPoints_mat.nativeObj, imagePoints1_mat.nativeObj, imagePoints2_mat.nativeObj, cameraMatrix1.nativeObj, distCoeffs1.nativeObj, cameraMatrix2.nativeObj, distCoeffs2.nativeObj, imageSize.width, imageSize.height, R.nativeObj, T.nativeObj, E.nativeObj, F.nativeObj, rvecs_mat.nativeObj, tvecs_mat.nativeObj, perViewErrors.nativeObj, flags);
  5319. Converters.Mat_to_vector_Mat(rvecs_mat, rvecs);
  5320. rvecs_mat.release();
  5321. Converters.Mat_to_vector_Mat(tvecs_mat, tvecs);
  5322. tvecs_mat.release();
  5323. return retVal;
  5324. }
  5325. /**
  5326. * Calibrates a stereo camera set up. This function finds the intrinsic parameters
  5327. * for each of the two cameras and the extrinsic parameters between the two cameras.
  5328. *
  5329. * param objectPoints Vector of vectors of the calibration pattern points. The same structure as
  5330. * in REF: calibrateCamera. For each pattern view, both cameras need to see the same object
  5331. * points. Therefore, objectPoints.size(), imagePoints1.size(), and imagePoints2.size() need to be
  5332. * equal as well as objectPoints[i].size(), imagePoints1[i].size(), and imagePoints2[i].size() need to
  5333. * be equal for each i.
  5334. * param imagePoints1 Vector of vectors of the projections of the calibration pattern points,
  5335. * observed by the first camera. The same structure as in REF: calibrateCamera.
  5336. * param imagePoints2 Vector of vectors of the projections of the calibration pattern points,
  5337. * observed by the second camera. The same structure as in REF: calibrateCamera.
  5338. * param cameraMatrix1 Input/output camera intrinsic matrix for the first camera, the same as in
  5339. * REF: calibrateCamera. Furthermore, for the stereo case, additional flags may be used, see below.
  5340. * param distCoeffs1 Input/output vector of distortion coefficients, the same as in
  5341. * REF: calibrateCamera.
  5342. * param cameraMatrix2 Input/output second camera intrinsic matrix for the second camera. See description for
  5343. * cameraMatrix1.
  5344. * param distCoeffs2 Input/output lens distortion coefficients for the second camera. See
  5345. * description for distCoeffs1.
  5346. * param imageSize Size of the image used only to initialize the camera intrinsic matrices.
  5347. * param R Output rotation matrix. Together with the translation vector T, this matrix brings
  5348. * points given in the first camera's coordinate system to points in the second camera's
  5349. * coordinate system. In more technical terms, the tuple of R and T performs a change of basis
  5350. * from the first camera's coordinate system to the second camera's coordinate system. Due to its
  5351. * duality, this tuple is equivalent to the position of the first camera with respect to the
  5352. * second camera coordinate system.
  5353. * param T Output translation vector, see description above.
  5354. * param E Output essential matrix.
  5355. * param F Output fundamental matrix.
  5356. * param rvecs Output vector of rotation vectors ( REF: Rodrigues ) estimated for each pattern view in the
  5357. * coordinate system of the first camera of the stereo pair (e.g. std::vector&lt;cv::Mat&gt;). More in detail, each
  5358. * i-th rotation vector together with the corresponding i-th translation vector (see the next output parameter
  5359. * description) brings the calibration pattern from the object coordinate space (in which object points are
  5360. * specified) to the camera coordinate space of the first camera of the stereo pair. In more technical terms,
  5361. * the tuple of the i-th rotation and translation vector performs a change of basis from object coordinate space
  5362. * to camera coordinate space of the first camera of the stereo pair.
  5363. * param tvecs Output vector of translation vectors estimated for each pattern view, see parameter description
  5364. * of previous output parameter ( rvecs ).
  5365. * param perViewErrors Output vector of the RMS re-projection error estimated for each pattern view.
  5366. * <ul>
  5367. * <li>
  5368. * REF: CALIB_FIX_INTRINSIC Fix cameraMatrix? and distCoeffs? so that only R, T, E, and F
  5369. * matrices are estimated.
  5370. * </li>
  5371. * <li>
  5372. * REF: CALIB_USE_INTRINSIC_GUESS Optimize some or all of the intrinsic parameters
  5373. * according to the specified flags. Initial values are provided by the user.
  5374. * </li>
  5375. * <li>
  5376. * REF: CALIB_USE_EXTRINSIC_GUESS R and T contain valid initial values that are optimized further.
  5377. * Otherwise R and T are initialized to the median value of the pattern views (each dimension separately).
  5378. * </li>
  5379. * <li>
  5380. * REF: CALIB_FIX_PRINCIPAL_POINT Fix the principal points during the optimization.
  5381. * </li>
  5382. * <li>
  5383. * REF: CALIB_FIX_FOCAL_LENGTH Fix \(f^{(j)}_x\) and \(f^{(j)}_y\) .
  5384. * </li>
  5385. * <li>
  5386. * REF: CALIB_FIX_ASPECT_RATIO Optimize \(f^{(j)}_y\) . Fix the ratio \(f^{(j)}_x/f^{(j)}_y\)
  5387. * .
  5388. * </li>
  5389. * <li>
  5390. * REF: CALIB_SAME_FOCAL_LENGTH Enforce \(f^{(0)}_x=f^{(1)}_x\) and \(f^{(0)}_y=f^{(1)}_y\) .
  5391. * </li>
  5392. * <li>
  5393. * REF: CALIB_ZERO_TANGENT_DIST Set tangential distortion coefficients for each camera to
  5394. * zeros and fix there.
  5395. * </li>
  5396. * <li>
  5397. * REF: CALIB_FIX_K1,..., REF: CALIB_FIX_K6 Do not change the corresponding radial
  5398. * distortion coefficient during the optimization. If REF: CALIB_USE_INTRINSIC_GUESS is set,
  5399. * the coefficient from the supplied distCoeffs matrix is used. Otherwise, it is set to 0.
  5400. * </li>
  5401. * <li>
  5402. * REF: CALIB_RATIONAL_MODEL Enable coefficients k4, k5, and k6. To provide the backward
  5403. * compatibility, this extra flag should be explicitly specified to make the calibration
  5404. * function use the rational model and return 8 coefficients. If the flag is not set, the
  5405. * function computes and returns only 5 distortion coefficients.
  5406. * </li>
  5407. * <li>
  5408. * REF: CALIB_THIN_PRISM_MODEL Coefficients s1, s2, s3 and s4 are enabled. To provide the
  5409. * backward compatibility, this extra flag should be explicitly specified to make the
  5410. * calibration function use the thin prism model and return 12 coefficients. If the flag is not
  5411. * set, the function computes and returns only 5 distortion coefficients.
  5412. * </li>
  5413. * <li>
  5414. * REF: CALIB_FIX_S1_S2_S3_S4 The thin prism distortion coefficients are not changed during
  5415. * the optimization. If REF: CALIB_USE_INTRINSIC_GUESS is set, the coefficient from the
  5416. * supplied distCoeffs matrix is used. Otherwise, it is set to 0.
  5417. * </li>
  5418. * <li>
  5419. * REF: CALIB_TILTED_MODEL Coefficients tauX and tauY are enabled. To provide the
  5420. * backward compatibility, this extra flag should be explicitly specified to make the
  5421. * calibration function use the tilted sensor model and return 14 coefficients. If the flag is not
  5422. * set, the function computes and returns only 5 distortion coefficients.
  5423. * </li>
  5424. * <li>
  5425. * REF: CALIB_FIX_TAUX_TAUY The coefficients of the tilted sensor model are not changed during
  5426. * the optimization. If REF: CALIB_USE_INTRINSIC_GUESS is set, the coefficient from the
  5427. * supplied distCoeffs matrix is used. Otherwise, it is set to 0.
  5428. * </li>
  5429. * </ul>
  5430. *
  5431. * The function estimates the transformation between two cameras making a stereo pair. If one computes
  5432. * the poses of an object relative to the first camera and to the second camera,
  5433. * ( \(R_1\),\(T_1\) ) and (\(R_2\),\(T_2\)), respectively, for a stereo camera where the
  5434. * relative position and orientation between the two cameras are fixed, then those poses definitely
  5435. * relate to each other. This means, if the relative position and orientation (\(R\),\(T\)) of the
  5436. * two cameras is known, it is possible to compute (\(R_2\),\(T_2\)) when (\(R_1\),\(T_1\)) is
  5437. * given. This is what the described function does. It computes (\(R\),\(T\)) such that:
  5438. *
  5439. * \(R_2=R R_1\)
  5440. * \(T_2=R T_1 + T.\)
  5441. *
  5442. * Therefore, one can compute the coordinate representation of a 3D point for the second camera's
  5443. * coordinate system when given the point's coordinate representation in the first camera's coordinate
  5444. * system:
  5445. *
  5446. * \(\begin{bmatrix}
  5447. * X_2 \\
  5448. * Y_2 \\
  5449. * Z_2 \\
  5450. * 1
  5451. * \end{bmatrix} = \begin{bmatrix}
  5452. * R &amp; T \\
  5453. * 0 &amp; 1
  5454. * \end{bmatrix} \begin{bmatrix}
  5455. * X_1 \\
  5456. * Y_1 \\
  5457. * Z_1 \\
  5458. * 1
  5459. * \end{bmatrix}.\)
  5460. *
  5461. *
  5462. * Optionally, it computes the essential matrix E:
  5463. *
  5464. * \(E= \vecthreethree{0}{-T_2}{T_1}{T_2}{0}{-T_0}{-T_1}{T_0}{0} R\)
  5465. *
  5466. * where \(T_i\) are components of the translation vector \(T\) : \(T=[T_0, T_1, T_2]^T\) .
  5467. * And the function can also compute the fundamental matrix F:
  5468. *
  5469. * \(F = cameraMatrix2^{-T}\cdot E \cdot cameraMatrix1^{-1}\)
  5470. *
  5471. * Besides the stereo-related information, the function can also perform a full calibration of each of
  5472. * the two cameras. However, due to the high dimensionality of the parameter space and noise in the
  5473. * input data, the function can diverge from the correct solution. If the intrinsic parameters can be
  5474. * estimated with high accuracy for each of the cameras individually (for example, using
  5475. * #calibrateCamera ), you are recommended to do so and then pass REF: CALIB_FIX_INTRINSIC flag to the
  5476. * function along with the computed intrinsic parameters. Otherwise, if all the parameters are
  5477. * estimated at once, it makes sense to restrict some parameters, for example, pass
  5478. * REF: CALIB_SAME_FOCAL_LENGTH and REF: CALIB_ZERO_TANGENT_DIST flags, which is usually a
  5479. * reasonable assumption.
  5480. *
  5481. * Similarly to #calibrateCamera, the function minimizes the total re-projection error for all the
  5482. * points in all the available views from both cameras. The function returns the final value of the
  5483. * re-projection error.
  5484. * return automatically generated
  5485. */
  5486. public static double stereoCalibrateExtended(List<Mat> objectPoints, List<Mat> imagePoints1, List<Mat> imagePoints2, Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Size imageSize, Mat R, Mat T, Mat E, Mat F, List<Mat> rvecs, List<Mat> tvecs, Mat perViewErrors)
  5487. {
  5488. if (cameraMatrix1 != null) cameraMatrix1.ThrowIfDisposed();
  5489. if (distCoeffs1 != null) distCoeffs1.ThrowIfDisposed();
  5490. if (cameraMatrix2 != null) cameraMatrix2.ThrowIfDisposed();
  5491. if (distCoeffs2 != null) distCoeffs2.ThrowIfDisposed();
  5492. if (R != null) R.ThrowIfDisposed();
  5493. if (T != null) T.ThrowIfDisposed();
  5494. if (E != null) E.ThrowIfDisposed();
  5495. if (F != null) F.ThrowIfDisposed();
  5496. if (perViewErrors != null) perViewErrors.ThrowIfDisposed();
  5497. Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints);
  5498. Mat imagePoints1_mat = Converters.vector_Mat_to_Mat(imagePoints1);
  5499. Mat imagePoints2_mat = Converters.vector_Mat_to_Mat(imagePoints2);
  5500. Mat rvecs_mat = new Mat();
  5501. Mat tvecs_mat = new Mat();
  5502. double retVal = calib3d_Calib3d_stereoCalibrateExtended_12(objectPoints_mat.nativeObj, imagePoints1_mat.nativeObj, imagePoints2_mat.nativeObj, cameraMatrix1.nativeObj, distCoeffs1.nativeObj, cameraMatrix2.nativeObj, distCoeffs2.nativeObj, imageSize.width, imageSize.height, R.nativeObj, T.nativeObj, E.nativeObj, F.nativeObj, rvecs_mat.nativeObj, tvecs_mat.nativeObj, perViewErrors.nativeObj);
  5503. Converters.Mat_to_vector_Mat(rvecs_mat, rvecs);
  5504. rvecs_mat.release();
  5505. Converters.Mat_to_vector_Mat(tvecs_mat, tvecs);
  5506. tvecs_mat.release();
  5507. return retVal;
  5508. }
  5509. //
  5510. // C++: double cv::stereoCalibrate(vector_Mat objectPoints, vector_Mat imagePoints1, vector_Mat imagePoints2, Mat& cameraMatrix1, Mat& distCoeffs1, Mat& cameraMatrix2, Mat& distCoeffs2, Size imageSize, Mat& R, Mat& T, Mat& E, Mat& F, int flags = CALIB_FIX_INTRINSIC, TermCriteria criteria = TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, 30, 1e-6))
  5511. //
  5512. public static double stereoCalibrate(List<Mat> objectPoints, List<Mat> imagePoints1, List<Mat> imagePoints2, Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Size imageSize, Mat R, Mat T, Mat E, Mat F, int flags, TermCriteria criteria)
  5513. {
  5514. if (cameraMatrix1 != null) cameraMatrix1.ThrowIfDisposed();
  5515. if (distCoeffs1 != null) distCoeffs1.ThrowIfDisposed();
  5516. if (cameraMatrix2 != null) cameraMatrix2.ThrowIfDisposed();
  5517. if (distCoeffs2 != null) distCoeffs2.ThrowIfDisposed();
  5518. if (R != null) R.ThrowIfDisposed();
  5519. if (T != null) T.ThrowIfDisposed();
  5520. if (E != null) E.ThrowIfDisposed();
  5521. if (F != null) F.ThrowIfDisposed();
  5522. Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints);
  5523. Mat imagePoints1_mat = Converters.vector_Mat_to_Mat(imagePoints1);
  5524. Mat imagePoints2_mat = Converters.vector_Mat_to_Mat(imagePoints2);
  5525. return calib3d_Calib3d_stereoCalibrate_10(objectPoints_mat.nativeObj, imagePoints1_mat.nativeObj, imagePoints2_mat.nativeObj, cameraMatrix1.nativeObj, distCoeffs1.nativeObj, cameraMatrix2.nativeObj, distCoeffs2.nativeObj, imageSize.width, imageSize.height, R.nativeObj, T.nativeObj, E.nativeObj, F.nativeObj, flags, criteria.type, criteria.maxCount, criteria.epsilon);
  5526. }
  5527. public static double stereoCalibrate(List<Mat> objectPoints, List<Mat> imagePoints1, List<Mat> imagePoints2, Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Size imageSize, Mat R, Mat T, Mat E, Mat F, int flags)
  5528. {
  5529. if (cameraMatrix1 != null) cameraMatrix1.ThrowIfDisposed();
  5530. if (distCoeffs1 != null) distCoeffs1.ThrowIfDisposed();
  5531. if (cameraMatrix2 != null) cameraMatrix2.ThrowIfDisposed();
  5532. if (distCoeffs2 != null) distCoeffs2.ThrowIfDisposed();
  5533. if (R != null) R.ThrowIfDisposed();
  5534. if (T != null) T.ThrowIfDisposed();
  5535. if (E != null) E.ThrowIfDisposed();
  5536. if (F != null) F.ThrowIfDisposed();
  5537. Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints);
  5538. Mat imagePoints1_mat = Converters.vector_Mat_to_Mat(imagePoints1);
  5539. Mat imagePoints2_mat = Converters.vector_Mat_to_Mat(imagePoints2);
  5540. return calib3d_Calib3d_stereoCalibrate_11(objectPoints_mat.nativeObj, imagePoints1_mat.nativeObj, imagePoints2_mat.nativeObj, cameraMatrix1.nativeObj, distCoeffs1.nativeObj, cameraMatrix2.nativeObj, distCoeffs2.nativeObj, imageSize.width, imageSize.height, R.nativeObj, T.nativeObj, E.nativeObj, F.nativeObj, flags);
  5541. }
  5542. public static double stereoCalibrate(List<Mat> objectPoints, List<Mat> imagePoints1, List<Mat> imagePoints2, Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Size imageSize, Mat R, Mat T, Mat E, Mat F)
  5543. {
  5544. if (cameraMatrix1 != null) cameraMatrix1.ThrowIfDisposed();
  5545. if (distCoeffs1 != null) distCoeffs1.ThrowIfDisposed();
  5546. if (cameraMatrix2 != null) cameraMatrix2.ThrowIfDisposed();
  5547. if (distCoeffs2 != null) distCoeffs2.ThrowIfDisposed();
  5548. if (R != null) R.ThrowIfDisposed();
  5549. if (T != null) T.ThrowIfDisposed();
  5550. if (E != null) E.ThrowIfDisposed();
  5551. if (F != null) F.ThrowIfDisposed();
  5552. Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints);
  5553. Mat imagePoints1_mat = Converters.vector_Mat_to_Mat(imagePoints1);
  5554. Mat imagePoints2_mat = Converters.vector_Mat_to_Mat(imagePoints2);
  5555. return calib3d_Calib3d_stereoCalibrate_12(objectPoints_mat.nativeObj, imagePoints1_mat.nativeObj, imagePoints2_mat.nativeObj, cameraMatrix1.nativeObj, distCoeffs1.nativeObj, cameraMatrix2.nativeObj, distCoeffs2.nativeObj, imageSize.width, imageSize.height, R.nativeObj, T.nativeObj, E.nativeObj, F.nativeObj);
  5556. }
  5557. //
  5558. // C++: double cv::stereoCalibrate(vector_Mat objectPoints, vector_Mat imagePoints1, vector_Mat imagePoints2, Mat& cameraMatrix1, Mat& distCoeffs1, Mat& cameraMatrix2, Mat& distCoeffs2, Size imageSize, Mat& R, Mat& T, Mat& E, Mat& F, Mat& perViewErrors, int flags = CALIB_FIX_INTRINSIC, TermCriteria criteria = TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, 30, 1e-6))
  5559. //
  5560. public static double stereoCalibrate(List<Mat> objectPoints, List<Mat> imagePoints1, List<Mat> imagePoints2, Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Size imageSize, Mat R, Mat T, Mat E, Mat F, Mat perViewErrors, int flags, TermCriteria criteria)
  5561. {
  5562. if (cameraMatrix1 != null) cameraMatrix1.ThrowIfDisposed();
  5563. if (distCoeffs1 != null) distCoeffs1.ThrowIfDisposed();
  5564. if (cameraMatrix2 != null) cameraMatrix2.ThrowIfDisposed();
  5565. if (distCoeffs2 != null) distCoeffs2.ThrowIfDisposed();
  5566. if (R != null) R.ThrowIfDisposed();
  5567. if (T != null) T.ThrowIfDisposed();
  5568. if (E != null) E.ThrowIfDisposed();
  5569. if (F != null) F.ThrowIfDisposed();
  5570. if (perViewErrors != null) perViewErrors.ThrowIfDisposed();
  5571. Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints);
  5572. Mat imagePoints1_mat = Converters.vector_Mat_to_Mat(imagePoints1);
  5573. Mat imagePoints2_mat = Converters.vector_Mat_to_Mat(imagePoints2);
  5574. return calib3d_Calib3d_stereoCalibrate_13(objectPoints_mat.nativeObj, imagePoints1_mat.nativeObj, imagePoints2_mat.nativeObj, cameraMatrix1.nativeObj, distCoeffs1.nativeObj, cameraMatrix2.nativeObj, distCoeffs2.nativeObj, imageSize.width, imageSize.height, R.nativeObj, T.nativeObj, E.nativeObj, F.nativeObj, perViewErrors.nativeObj, flags, criteria.type, criteria.maxCount, criteria.epsilon);
  5575. }
  5576. public static double stereoCalibrate(List<Mat> objectPoints, List<Mat> imagePoints1, List<Mat> imagePoints2, Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Size imageSize, Mat R, Mat T, Mat E, Mat F, Mat perViewErrors, int flags)
  5577. {
  5578. if (cameraMatrix1 != null) cameraMatrix1.ThrowIfDisposed();
  5579. if (distCoeffs1 != null) distCoeffs1.ThrowIfDisposed();
  5580. if (cameraMatrix2 != null) cameraMatrix2.ThrowIfDisposed();
  5581. if (distCoeffs2 != null) distCoeffs2.ThrowIfDisposed();
  5582. if (R != null) R.ThrowIfDisposed();
  5583. if (T != null) T.ThrowIfDisposed();
  5584. if (E != null) E.ThrowIfDisposed();
  5585. if (F != null) F.ThrowIfDisposed();
  5586. if (perViewErrors != null) perViewErrors.ThrowIfDisposed();
  5587. Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints);
  5588. Mat imagePoints1_mat = Converters.vector_Mat_to_Mat(imagePoints1);
  5589. Mat imagePoints2_mat = Converters.vector_Mat_to_Mat(imagePoints2);
  5590. return calib3d_Calib3d_stereoCalibrate_14(objectPoints_mat.nativeObj, imagePoints1_mat.nativeObj, imagePoints2_mat.nativeObj, cameraMatrix1.nativeObj, distCoeffs1.nativeObj, cameraMatrix2.nativeObj, distCoeffs2.nativeObj, imageSize.width, imageSize.height, R.nativeObj, T.nativeObj, E.nativeObj, F.nativeObj, perViewErrors.nativeObj, flags);
  5591. }
  5592. public static double stereoCalibrate(List<Mat> objectPoints, List<Mat> imagePoints1, List<Mat> imagePoints2, Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Size imageSize, Mat R, Mat T, Mat E, Mat F, Mat perViewErrors)
  5593. {
  5594. if (cameraMatrix1 != null) cameraMatrix1.ThrowIfDisposed();
  5595. if (distCoeffs1 != null) distCoeffs1.ThrowIfDisposed();
  5596. if (cameraMatrix2 != null) cameraMatrix2.ThrowIfDisposed();
  5597. if (distCoeffs2 != null) distCoeffs2.ThrowIfDisposed();
  5598. if (R != null) R.ThrowIfDisposed();
  5599. if (T != null) T.ThrowIfDisposed();
  5600. if (E != null) E.ThrowIfDisposed();
  5601. if (F != null) F.ThrowIfDisposed();
  5602. if (perViewErrors != null) perViewErrors.ThrowIfDisposed();
  5603. Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints);
  5604. Mat imagePoints1_mat = Converters.vector_Mat_to_Mat(imagePoints1);
  5605. Mat imagePoints2_mat = Converters.vector_Mat_to_Mat(imagePoints2);
  5606. return calib3d_Calib3d_stereoCalibrate_15(objectPoints_mat.nativeObj, imagePoints1_mat.nativeObj, imagePoints2_mat.nativeObj, cameraMatrix1.nativeObj, distCoeffs1.nativeObj, cameraMatrix2.nativeObj, distCoeffs2.nativeObj, imageSize.width, imageSize.height, R.nativeObj, T.nativeObj, E.nativeObj, F.nativeObj, perViewErrors.nativeObj);
  5607. }
  5608. //
  5609. // C++: void cv::stereoRectify(Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Size imageSize, Mat R, Mat T, Mat& R1, Mat& R2, Mat& P1, Mat& P2, Mat& Q, int flags = CALIB_ZERO_DISPARITY, double alpha = -1, Size newImageSize = Size(), Rect* validPixROI1 = 0, Rect* validPixROI2 = 0)
  5610. //
  5611. /**
  5612. * Computes rectification transforms for each head of a calibrated stereo camera.
  5613. *
  5614. * param cameraMatrix1 First camera intrinsic matrix.
  5615. * param distCoeffs1 First camera distortion parameters.
  5616. * param cameraMatrix2 Second camera intrinsic matrix.
  5617. * param distCoeffs2 Second camera distortion parameters.
  5618. * param imageSize Size of the image used for stereo calibration.
  5619. * param R Rotation matrix from the coordinate system of the first camera to the second camera,
  5620. * see REF: stereoCalibrate.
  5621. * param T Translation vector from the coordinate system of the first camera to the second camera,
  5622. * see REF: stereoCalibrate.
  5623. * param R1 Output 3x3 rectification transform (rotation matrix) for the first camera. This matrix
  5624. * brings points given in the unrectified first camera's coordinate system to points in the rectified
  5625. * first camera's coordinate system. In more technical terms, it performs a change of basis from the
  5626. * unrectified first camera's coordinate system to the rectified first camera's coordinate system.
  5627. * param R2 Output 3x3 rectification transform (rotation matrix) for the second camera. This matrix
  5628. * brings points given in the unrectified second camera's coordinate system to points in the rectified
  5629. * second camera's coordinate system. In more technical terms, it performs a change of basis from the
  5630. * unrectified second camera's coordinate system to the rectified second camera's coordinate system.
  5631. * param P1 Output 3x4 projection matrix in the new (rectified) coordinate systems for the first
  5632. * camera, i.e. it projects points given in the rectified first camera coordinate system into the
  5633. * rectified first camera's image.
  5634. * param P2 Output 3x4 projection matrix in the new (rectified) coordinate systems for the second
  5635. * camera, i.e. it projects points given in the rectified first camera coordinate system into the
  5636. * rectified second camera's image.
  5637. * param Q Output \(4 \times 4\) disparity-to-depth mapping matrix (see REF: reprojectImageTo3D).
  5638. * param flags Operation flags that may be zero or REF: CALIB_ZERO_DISPARITY . If the flag is set,
  5639. * the function makes the principal points of each camera have the same pixel coordinates in the
  5640. * rectified views. And if the flag is not set, the function may still shift the images in the
  5641. * horizontal or vertical direction (depending on the orientation of epipolar lines) to maximize the
  5642. * useful image area.
  5643. * param alpha Free scaling parameter. If it is -1 or absent, the function performs the default
  5644. * scaling. Otherwise, the parameter should be between 0 and 1. alpha=0 means that the rectified
  5645. * images are zoomed and shifted so that only valid pixels are visible (no black areas after
  5646. * rectification). alpha=1 means that the rectified image is decimated and shifted so that all the
  5647. * pixels from the original images from the cameras are retained in the rectified images (no source
  5648. * image pixels are lost). Any intermediate value yields an intermediate result between
  5649. * those two extreme cases.
  5650. * param newImageSize New image resolution after rectification. The same size should be passed to
  5651. * #initUndistortRectifyMap (see the stereo_calib.cpp sample in OpenCV samples directory). When (0,0)
  5652. * is passed (default), it is set to the original imageSize . Setting it to a larger value can help you
  5653. * preserve details in the original image, especially when there is a big radial distortion.
  5654. * param validPixROI1 Optional output rectangles inside the rectified images where all the pixels
  5655. * are valid. If alpha=0 , the ROIs cover the whole images. Otherwise, they are likely to be smaller
  5656. * (see the picture below).
  5657. * param validPixROI2 Optional output rectangles inside the rectified images where all the pixels
  5658. * are valid. If alpha=0 , the ROIs cover the whole images. Otherwise, they are likely to be smaller
  5659. * (see the picture below).
  5660. *
  5661. * The function computes the rotation matrices for each camera that (virtually) make both camera image
  5662. * planes the same plane. Consequently, this makes all the epipolar lines parallel and thus simplifies
  5663. * the dense stereo correspondence problem. The function takes the matrices computed by #stereoCalibrate
  5664. * as input. As output, it provides two rotation matrices and also two projection matrices in the new
  5665. * coordinates. The function distinguishes the following two cases:
  5666. *
  5667. * <ul>
  5668. * <li>
  5669. * <b>Horizontal stereo</b>: the first and the second camera views are shifted relative to each other
  5670. * mainly along the x-axis (with possible small vertical shift). In the rectified images, the
  5671. * corresponding epipolar lines in the left and right cameras are horizontal and have the same
  5672. * y-coordinate. P1 and P2 look like:
  5673. * </li>
  5674. * </ul>
  5675. *
  5676. * \(\texttt{P1} = \begin{bmatrix}
  5677. * f &amp; 0 &amp; cx_1 &amp; 0 \\
  5678. * 0 &amp; f &amp; cy &amp; 0 \\
  5679. * 0 &amp; 0 &amp; 1 &amp; 0
  5680. * \end{bmatrix}\)
  5681. *
  5682. * \(\texttt{P2} = \begin{bmatrix}
  5683. * f &amp; 0 &amp; cx_2 &amp; T_x \cdot f \\
  5684. * 0 &amp; f &amp; cy &amp; 0 \\
  5685. * 0 &amp; 0 &amp; 1 &amp; 0
  5686. * \end{bmatrix} ,\)
  5687. *
  5688. * \(\texttt{Q} = \begin{bmatrix}
  5689. * 1 &amp; 0 &amp; 0 &amp; -cx_1 \\
  5690. * 0 &amp; 1 &amp; 0 &amp; -cy \\
  5691. * 0 &amp; 0 &amp; 0 &amp; f \\
  5692. * 0 &amp; 0 &amp; -\frac{1}{T_x} &amp; \frac{cx_1 - cx_2}{T_x}
  5693. * \end{bmatrix} \)
  5694. *
  5695. * where \(T_x\) is a horizontal shift between the cameras and \(cx_1=cx_2\) if
  5696. * REF: CALIB_ZERO_DISPARITY is set.
  5697. *
  5698. * <ul>
  5699. * <li>
  5700. * <b>Vertical stereo</b>: the first and the second camera views are shifted relative to each other
  5701. * mainly in the vertical direction (and probably a bit in the horizontal direction too). The epipolar
  5702. * lines in the rectified images are vertical and have the same x-coordinate. P1 and P2 look like:
  5703. * </li>
  5704. * </ul>
  5705. *
  5706. * \(\texttt{P1} = \begin{bmatrix}
  5707. * f &amp; 0 &amp; cx &amp; 0 \\
  5708. * 0 &amp; f &amp; cy_1 &amp; 0 \\
  5709. * 0 &amp; 0 &amp; 1 &amp; 0
  5710. * \end{bmatrix}\)
  5711. *
  5712. * \(\texttt{P2} = \begin{bmatrix}
  5713. * f &amp; 0 &amp; cx &amp; 0 \\
  5714. * 0 &amp; f &amp; cy_2 &amp; T_y \cdot f \\
  5715. * 0 &amp; 0 &amp; 1 &amp; 0
  5716. * \end{bmatrix},\)
  5717. *
  5718. * \(\texttt{Q} = \begin{bmatrix}
  5719. * 1 &amp; 0 &amp; 0 &amp; -cx \\
  5720. * 0 &amp; 1 &amp; 0 &amp; -cy_1 \\
  5721. * 0 &amp; 0 &amp; 0 &amp; f \\
  5722. * 0 &amp; 0 &amp; -\frac{1}{T_y} &amp; \frac{cy_1 - cy_2}{T_y}
  5723. * \end{bmatrix} \)
  5724. *
  5725. * where \(T_y\) is a vertical shift between the cameras and \(cy_1=cy_2\) if
  5726. * REF: CALIB_ZERO_DISPARITY is set.
  5727. *
  5728. * As you can see, the first three columns of P1 and P2 will effectively be the new "rectified" camera
  5729. * matrices. The matrices, together with R1 and R2 , can then be passed to #initUndistortRectifyMap to
  5730. * initialize the rectification map for each camera.
  5731. *
  5732. * See below the screenshot from the stereo_calib.cpp sample. Some red horizontal lines pass through
  5733. * the corresponding image regions. This means that the images are well rectified, which is what most
  5734. * stereo correspondence algorithms rely on. The green rectangles are roi1 and roi2 . You see that
  5735. * their interiors are all valid pixels.
  5736. *
  5737. * ![image](pics/stereo_undistort.jpg)
  5738. */
  5739. public static void stereoRectify(Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Size imageSize, Mat R, Mat T, Mat R1, Mat R2, Mat P1, Mat P2, Mat Q, int flags, double alpha, Size newImageSize, Rect validPixROI1, Rect validPixROI2)
  5740. {
  5741. if (cameraMatrix1 != null) cameraMatrix1.ThrowIfDisposed();
  5742. if (distCoeffs1 != null) distCoeffs1.ThrowIfDisposed();
  5743. if (cameraMatrix2 != null) cameraMatrix2.ThrowIfDisposed();
  5744. if (distCoeffs2 != null) distCoeffs2.ThrowIfDisposed();
  5745. if (R != null) R.ThrowIfDisposed();
  5746. if (T != null) T.ThrowIfDisposed();
  5747. if (R1 != null) R1.ThrowIfDisposed();
  5748. if (R2 != null) R2.ThrowIfDisposed();
  5749. if (P1 != null) P1.ThrowIfDisposed();
  5750. if (P2 != null) P2.ThrowIfDisposed();
  5751. if (Q != null) Q.ThrowIfDisposed();
  5752. double[] validPixROI1_out = new double[4];
  5753. double[] validPixROI2_out = new double[4];
  5754. calib3d_Calib3d_stereoRectify_10(cameraMatrix1.nativeObj, distCoeffs1.nativeObj, cameraMatrix2.nativeObj, distCoeffs2.nativeObj, imageSize.width, imageSize.height, R.nativeObj, T.nativeObj, R1.nativeObj, R2.nativeObj, P1.nativeObj, P2.nativeObj, Q.nativeObj, flags, alpha, newImageSize.width, newImageSize.height, validPixROI1_out, validPixROI2_out);
  5755. if (validPixROI1 != null) { validPixROI1.x = (int)validPixROI1_out[0]; validPixROI1.y = (int)validPixROI1_out[1]; validPixROI1.width = (int)validPixROI1_out[2]; validPixROI1.height = (int)validPixROI1_out[3]; }
  5756. if (validPixROI2 != null) { validPixROI2.x = (int)validPixROI2_out[0]; validPixROI2.y = (int)validPixROI2_out[1]; validPixROI2.width = (int)validPixROI2_out[2]; validPixROI2.height = (int)validPixROI2_out[3]; }
  5757. }
  5758. /**
  5759. * Computes rectification transforms for each head of a calibrated stereo camera.
  5760. *
  5761. * param cameraMatrix1 First camera intrinsic matrix.
  5762. * param distCoeffs1 First camera distortion parameters.
  5763. * param cameraMatrix2 Second camera intrinsic matrix.
  5764. * param distCoeffs2 Second camera distortion parameters.
  5765. * param imageSize Size of the image used for stereo calibration.
  5766. * param R Rotation matrix from the coordinate system of the first camera to the second camera,
  5767. * see REF: stereoCalibrate.
  5768. * param T Translation vector from the coordinate system of the first camera to the second camera,
  5769. * see REF: stereoCalibrate.
  5770. * param R1 Output 3x3 rectification transform (rotation matrix) for the first camera. This matrix
  5771. * brings points given in the unrectified first camera's coordinate system to points in the rectified
  5772. * first camera's coordinate system. In more technical terms, it performs a change of basis from the
  5773. * unrectified first camera's coordinate system to the rectified first camera's coordinate system.
  5774. * param R2 Output 3x3 rectification transform (rotation matrix) for the second camera. This matrix
  5775. * brings points given in the unrectified second camera's coordinate system to points in the rectified
  5776. * second camera's coordinate system. In more technical terms, it performs a change of basis from the
  5777. * unrectified second camera's coordinate system to the rectified second camera's coordinate system.
  5778. * param P1 Output 3x4 projection matrix in the new (rectified) coordinate systems for the first
  5779. * camera, i.e. it projects points given in the rectified first camera coordinate system into the
  5780. * rectified first camera's image.
  5781. * param P2 Output 3x4 projection matrix in the new (rectified) coordinate systems for the second
  5782. * camera, i.e. it projects points given in the rectified first camera coordinate system into the
  5783. * rectified second camera's image.
  5784. * param Q Output \(4 \times 4\) disparity-to-depth mapping matrix (see REF: reprojectImageTo3D).
  5785. * param flags Operation flags that may be zero or REF: CALIB_ZERO_DISPARITY . If the flag is set,
  5786. * the function makes the principal points of each camera have the same pixel coordinates in the
  5787. * rectified views. And if the flag is not set, the function may still shift the images in the
  5788. * horizontal or vertical direction (depending on the orientation of epipolar lines) to maximize the
  5789. * useful image area.
  5790. * param alpha Free scaling parameter. If it is -1 or absent, the function performs the default
  5791. * scaling. Otherwise, the parameter should be between 0 and 1. alpha=0 means that the rectified
  5792. * images are zoomed and shifted so that only valid pixels are visible (no black areas after
  5793. * rectification). alpha=1 means that the rectified image is decimated and shifted so that all the
  5794. * pixels from the original images from the cameras are retained in the rectified images (no source
  5795. * image pixels are lost). Any intermediate value yields an intermediate result between
  5796. * those two extreme cases.
  5797. * param newImageSize New image resolution after rectification. The same size should be passed to
  5798. * #initUndistortRectifyMap (see the stereo_calib.cpp sample in OpenCV samples directory). When (0,0)
  5799. * is passed (default), it is set to the original imageSize . Setting it to a larger value can help you
  5800. * preserve details in the original image, especially when there is a big radial distortion.
  5801. * param validPixROI1 Optional output rectangles inside the rectified images where all the pixels
  5802. * are valid. If alpha=0 , the ROIs cover the whole images. Otherwise, they are likely to be smaller
  5803. * (see the picture below).
  5804. * are valid. If alpha=0 , the ROIs cover the whole images. Otherwise, they are likely to be smaller
  5805. * (see the picture below).
  5806. *
  5807. * The function computes the rotation matrices for each camera that (virtually) make both camera image
  5808. * planes the same plane. Consequently, this makes all the epipolar lines parallel and thus simplifies
  5809. * the dense stereo correspondence problem. The function takes the matrices computed by #stereoCalibrate
  5810. * as input. As output, it provides two rotation matrices and also two projection matrices in the new
  5811. * coordinates. The function distinguishes the following two cases:
  5812. *
  5813. * <ul>
  5814. * <li>
  5815. * <b>Horizontal stereo</b>: the first and the second camera views are shifted relative to each other
  5816. * mainly along the x-axis (with possible small vertical shift). In the rectified images, the
  5817. * corresponding epipolar lines in the left and right cameras are horizontal and have the same
  5818. * y-coordinate. P1 and P2 look like:
  5819. * </li>
  5820. * </ul>
  5821. *
  5822. * \(\texttt{P1} = \begin{bmatrix}
  5823. * f &amp; 0 &amp; cx_1 &amp; 0 \\
  5824. * 0 &amp; f &amp; cy &amp; 0 \\
  5825. * 0 &amp; 0 &amp; 1 &amp; 0
  5826. * \end{bmatrix}\)
  5827. *
  5828. * \(\texttt{P2} = \begin{bmatrix}
  5829. * f &amp; 0 &amp; cx_2 &amp; T_x \cdot f \\
  5830. * 0 &amp; f &amp; cy &amp; 0 \\
  5831. * 0 &amp; 0 &amp; 1 &amp; 0
  5832. * \end{bmatrix} ,\)
  5833. *
  5834. * \(\texttt{Q} = \begin{bmatrix}
  5835. * 1 &amp; 0 &amp; 0 &amp; -cx_1 \\
  5836. * 0 &amp; 1 &amp; 0 &amp; -cy \\
  5837. * 0 &amp; 0 &amp; 0 &amp; f \\
  5838. * 0 &amp; 0 &amp; -\frac{1}{T_x} &amp; \frac{cx_1 - cx_2}{T_x}
  5839. * \end{bmatrix} \)
  5840. *
  5841. * where \(T_x\) is a horizontal shift between the cameras and \(cx_1=cx_2\) if
  5842. * REF: CALIB_ZERO_DISPARITY is set.
  5843. *
  5844. * <ul>
  5845. * <li>
  5846. * <b>Vertical stereo</b>: the first and the second camera views are shifted relative to each other
  5847. * mainly in the vertical direction (and probably a bit in the horizontal direction too). The epipolar
  5848. * lines in the rectified images are vertical and have the same x-coordinate. P1 and P2 look like:
  5849. * </li>
  5850. * </ul>
  5851. *
  5852. * \(\texttt{P1} = \begin{bmatrix}
  5853. * f &amp; 0 &amp; cx &amp; 0 \\
  5854. * 0 &amp; f &amp; cy_1 &amp; 0 \\
  5855. * 0 &amp; 0 &amp; 1 &amp; 0
  5856. * \end{bmatrix}\)
  5857. *
  5858. * \(\texttt{P2} = \begin{bmatrix}
  5859. * f &amp; 0 &amp; cx &amp; 0 \\
  5860. * 0 &amp; f &amp; cy_2 &amp; T_y \cdot f \\
  5861. * 0 &amp; 0 &amp; 1 &amp; 0
  5862. * \end{bmatrix},\)
  5863. *
  5864. * \(\texttt{Q} = \begin{bmatrix}
  5865. * 1 &amp; 0 &amp; 0 &amp; -cx \\
  5866. * 0 &amp; 1 &amp; 0 &amp; -cy_1 \\
  5867. * 0 &amp; 0 &amp; 0 &amp; f \\
  5868. * 0 &amp; 0 &amp; -\frac{1}{T_y} &amp; \frac{cy_1 - cy_2}{T_y}
  5869. * \end{bmatrix} \)
  5870. *
  5871. * where \(T_y\) is a vertical shift between the cameras and \(cy_1=cy_2\) if
  5872. * REF: CALIB_ZERO_DISPARITY is set.
  5873. *
  5874. * As you can see, the first three columns of P1 and P2 will effectively be the new "rectified" camera
  5875. * matrices. The matrices, together with R1 and R2 , can then be passed to #initUndistortRectifyMap to
  5876. * initialize the rectification map for each camera.
  5877. *
  5878. * See below the screenshot from the stereo_calib.cpp sample. Some red horizontal lines pass through
  5879. * the corresponding image regions. This means that the images are well rectified, which is what most
  5880. * stereo correspondence algorithms rely on. The green rectangles are roi1 and roi2 . You see that
  5881. * their interiors are all valid pixels.
  5882. *
  5883. * ![image](pics/stereo_undistort.jpg)
  5884. */
  5885. public static void stereoRectify(Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Size imageSize, Mat R, Mat T, Mat R1, Mat R2, Mat P1, Mat P2, Mat Q, int flags, double alpha, Size newImageSize, Rect validPixROI1)
  5886. {
  5887. if (cameraMatrix1 != null) cameraMatrix1.ThrowIfDisposed();
  5888. if (distCoeffs1 != null) distCoeffs1.ThrowIfDisposed();
  5889. if (cameraMatrix2 != null) cameraMatrix2.ThrowIfDisposed();
  5890. if (distCoeffs2 != null) distCoeffs2.ThrowIfDisposed();
  5891. if (R != null) R.ThrowIfDisposed();
  5892. if (T != null) T.ThrowIfDisposed();
  5893. if (R1 != null) R1.ThrowIfDisposed();
  5894. if (R2 != null) R2.ThrowIfDisposed();
  5895. if (P1 != null) P1.ThrowIfDisposed();
  5896. if (P2 != null) P2.ThrowIfDisposed();
  5897. if (Q != null) Q.ThrowIfDisposed();
  5898. double[] validPixROI1_out = new double[4];
  5899. calib3d_Calib3d_stereoRectify_11(cameraMatrix1.nativeObj, distCoeffs1.nativeObj, cameraMatrix2.nativeObj, distCoeffs2.nativeObj, imageSize.width, imageSize.height, R.nativeObj, T.nativeObj, R1.nativeObj, R2.nativeObj, P1.nativeObj, P2.nativeObj, Q.nativeObj, flags, alpha, newImageSize.width, newImageSize.height, validPixROI1_out);
  5900. if (validPixROI1 != null) { validPixROI1.x = (int)validPixROI1_out[0]; validPixROI1.y = (int)validPixROI1_out[1]; validPixROI1.width = (int)validPixROI1_out[2]; validPixROI1.height = (int)validPixROI1_out[3]; }
  5901. }
  5902. /**
  5903. * Computes rectification transforms for each head of a calibrated stereo camera.
  5904. *
  5905. * param cameraMatrix1 First camera intrinsic matrix.
  5906. * param distCoeffs1 First camera distortion parameters.
  5907. * param cameraMatrix2 Second camera intrinsic matrix.
  5908. * param distCoeffs2 Second camera distortion parameters.
  5909. * param imageSize Size of the image used for stereo calibration.
  5910. * param R Rotation matrix from the coordinate system of the first camera to the second camera,
  5911. * see REF: stereoCalibrate.
  5912. * param T Translation vector from the coordinate system of the first camera to the second camera,
  5913. * see REF: stereoCalibrate.
  5914. * param R1 Output 3x3 rectification transform (rotation matrix) for the first camera. This matrix
  5915. * brings points given in the unrectified first camera's coordinate system to points in the rectified
  5916. * first camera's coordinate system. In more technical terms, it performs a change of basis from the
  5917. * unrectified first camera's coordinate system to the rectified first camera's coordinate system.
  5918. * param R2 Output 3x3 rectification transform (rotation matrix) for the second camera. This matrix
  5919. * brings points given in the unrectified second camera's coordinate system to points in the rectified
  5920. * second camera's coordinate system. In more technical terms, it performs a change of basis from the
  5921. * unrectified second camera's coordinate system to the rectified second camera's coordinate system.
  5922. * param P1 Output 3x4 projection matrix in the new (rectified) coordinate systems for the first
  5923. * camera, i.e. it projects points given in the rectified first camera coordinate system into the
  5924. * rectified first camera's image.
  5925. * param P2 Output 3x4 projection matrix in the new (rectified) coordinate systems for the second
  5926. * camera, i.e. it projects points given in the rectified first camera coordinate system into the
  5927. * rectified second camera's image.
  5928. * param Q Output \(4 \times 4\) disparity-to-depth mapping matrix (see REF: reprojectImageTo3D).
  5929. * param flags Operation flags that may be zero or REF: CALIB_ZERO_DISPARITY . If the flag is set,
  5930. * the function makes the principal points of each camera have the same pixel coordinates in the
  5931. * rectified views. And if the flag is not set, the function may still shift the images in the
  5932. * horizontal or vertical direction (depending on the orientation of epipolar lines) to maximize the
  5933. * useful image area.
  5934. * param alpha Free scaling parameter. If it is -1 or absent, the function performs the default
  5935. * scaling. Otherwise, the parameter should be between 0 and 1. alpha=0 means that the rectified
  5936. * images are zoomed and shifted so that only valid pixels are visible (no black areas after
  5937. * rectification). alpha=1 means that the rectified image is decimated and shifted so that all the
  5938. * pixels from the original images from the cameras are retained in the rectified images (no source
  5939. * image pixels are lost). Any intermediate value yields an intermediate result between
  5940. * those two extreme cases.
  5941. * param newImageSize New image resolution after rectification. The same size should be passed to
  5942. * #initUndistortRectifyMap (see the stereo_calib.cpp sample in OpenCV samples directory). When (0,0)
  5943. * is passed (default), it is set to the original imageSize . Setting it to a larger value can help you
  5944. * preserve details in the original image, especially when there is a big radial distortion.
  5945. * are valid. If alpha=0 , the ROIs cover the whole images. Otherwise, they are likely to be smaller
  5946. * (see the picture below).
  5947. * are valid. If alpha=0 , the ROIs cover the whole images. Otherwise, they are likely to be smaller
  5948. * (see the picture below).
  5949. *
  5950. * The function computes the rotation matrices for each camera that (virtually) make both camera image
  5951. * planes the same plane. Consequently, this makes all the epipolar lines parallel and thus simplifies
  5952. * the dense stereo correspondence problem. The function takes the matrices computed by #stereoCalibrate
  5953. * as input. As output, it provides two rotation matrices and also two projection matrices in the new
  5954. * coordinates. The function distinguishes the following two cases:
  5955. *
  5956. * <ul>
  5957. * <li>
  5958. * <b>Horizontal stereo</b>: the first and the second camera views are shifted relative to each other
  5959. * mainly along the x-axis (with possible small vertical shift). In the rectified images, the
  5960. * corresponding epipolar lines in the left and right cameras are horizontal and have the same
  5961. * y-coordinate. P1 and P2 look like:
  5962. * </li>
  5963. * </ul>
  5964. *
  5965. * \(\texttt{P1} = \begin{bmatrix}
  5966. * f &amp; 0 &amp; cx_1 &amp; 0 \\
  5967. * 0 &amp; f &amp; cy &amp; 0 \\
  5968. * 0 &amp; 0 &amp; 1 &amp; 0
  5969. * \end{bmatrix}\)
  5970. *
  5971. * \(\texttt{P2} = \begin{bmatrix}
  5972. * f &amp; 0 &amp; cx_2 &amp; T_x \cdot f \\
  5973. * 0 &amp; f &amp; cy &amp; 0 \\
  5974. * 0 &amp; 0 &amp; 1 &amp; 0
  5975. * \end{bmatrix} ,\)
  5976. *
  5977. * \(\texttt{Q} = \begin{bmatrix}
  5978. * 1 &amp; 0 &amp; 0 &amp; -cx_1 \\
  5979. * 0 &amp; 1 &amp; 0 &amp; -cy \\
  5980. * 0 &amp; 0 &amp; 0 &amp; f \\
  5981. * 0 &amp; 0 &amp; -\frac{1}{T_x} &amp; \frac{cx_1 - cx_2}{T_x}
  5982. * \end{bmatrix} \)
  5983. *
  5984. * where \(T_x\) is a horizontal shift between the cameras and \(cx_1=cx_2\) if
  5985. * REF: CALIB_ZERO_DISPARITY is set.
  5986. *
  5987. * <ul>
  5988. * <li>
  5989. * <b>Vertical stereo</b>: the first and the second camera views are shifted relative to each other
  5990. * mainly in the vertical direction (and probably a bit in the horizontal direction too). The epipolar
  5991. * lines in the rectified images are vertical and have the same x-coordinate. P1 and P2 look like:
  5992. * </li>
  5993. * </ul>
  5994. *
  5995. * \(\texttt{P1} = \begin{bmatrix}
  5996. * f &amp; 0 &amp; cx &amp; 0 \\
  5997. * 0 &amp; f &amp; cy_1 &amp; 0 \\
  5998. * 0 &amp; 0 &amp; 1 &amp; 0
  5999. * \end{bmatrix}\)
  6000. *
  6001. * \(\texttt{P2} = \begin{bmatrix}
  6002. * f &amp; 0 &amp; cx &amp; 0 \\
  6003. * 0 &amp; f &amp; cy_2 &amp; T_y \cdot f \\
  6004. * 0 &amp; 0 &amp; 1 &amp; 0
  6005. * \end{bmatrix},\)
  6006. *
  6007. * \(\texttt{Q} = \begin{bmatrix}
  6008. * 1 &amp; 0 &amp; 0 &amp; -cx \\
  6009. * 0 &amp; 1 &amp; 0 &amp; -cy_1 \\
  6010. * 0 &amp; 0 &amp; 0 &amp; f \\
  6011. * 0 &amp; 0 &amp; -\frac{1}{T_y} &amp; \frac{cy_1 - cy_2}{T_y}
  6012. * \end{bmatrix} \)
  6013. *
  6014. * where \(T_y\) is a vertical shift between the cameras and \(cy_1=cy_2\) if
  6015. * REF: CALIB_ZERO_DISPARITY is set.
  6016. *
  6017. * As you can see, the first three columns of P1 and P2 will effectively be the new "rectified" camera
  6018. * matrices. The matrices, together with R1 and R2 , can then be passed to #initUndistortRectifyMap to
  6019. * initialize the rectification map for each camera.
  6020. *
  6021. * See below the screenshot from the stereo_calib.cpp sample. Some red horizontal lines pass through
  6022. * the corresponding image regions. This means that the images are well rectified, which is what most
  6023. * stereo correspondence algorithms rely on. The green rectangles are roi1 and roi2 . You see that
  6024. * their interiors are all valid pixels.
  6025. *
  6026. * ![image](pics/stereo_undistort.jpg)
  6027. */
  6028. public static void stereoRectify(Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Size imageSize, Mat R, Mat T, Mat R1, Mat R2, Mat P1, Mat P2, Mat Q, int flags, double alpha, Size newImageSize)
  6029. {
  6030. if (cameraMatrix1 != null) cameraMatrix1.ThrowIfDisposed();
  6031. if (distCoeffs1 != null) distCoeffs1.ThrowIfDisposed();
  6032. if (cameraMatrix2 != null) cameraMatrix2.ThrowIfDisposed();
  6033. if (distCoeffs2 != null) distCoeffs2.ThrowIfDisposed();
  6034. if (R != null) R.ThrowIfDisposed();
  6035. if (T != null) T.ThrowIfDisposed();
  6036. if (R1 != null) R1.ThrowIfDisposed();
  6037. if (R2 != null) R2.ThrowIfDisposed();
  6038. if (P1 != null) P1.ThrowIfDisposed();
  6039. if (P2 != null) P2.ThrowIfDisposed();
  6040. if (Q != null) Q.ThrowIfDisposed();
  6041. calib3d_Calib3d_stereoRectify_12(cameraMatrix1.nativeObj, distCoeffs1.nativeObj, cameraMatrix2.nativeObj, distCoeffs2.nativeObj, imageSize.width, imageSize.height, R.nativeObj, T.nativeObj, R1.nativeObj, R2.nativeObj, P1.nativeObj, P2.nativeObj, Q.nativeObj, flags, alpha, newImageSize.width, newImageSize.height);
  6042. }
  6043. /**
  6044. * Computes rectification transforms for each head of a calibrated stereo camera.
  6045. *
  6046. * param cameraMatrix1 First camera intrinsic matrix.
  6047. * param distCoeffs1 First camera distortion parameters.
  6048. * param cameraMatrix2 Second camera intrinsic matrix.
  6049. * param distCoeffs2 Second camera distortion parameters.
  6050. * param imageSize Size of the image used for stereo calibration.
  6051. * param R Rotation matrix from the coordinate system of the first camera to the second camera,
  6052. * see REF: stereoCalibrate.
  6053. * param T Translation vector from the coordinate system of the first camera to the second camera,
  6054. * see REF: stereoCalibrate.
  6055. * param R1 Output 3x3 rectification transform (rotation matrix) for the first camera. This matrix
  6056. * brings points given in the unrectified first camera's coordinate system to points in the rectified
  6057. * first camera's coordinate system. In more technical terms, it performs a change of basis from the
  6058. * unrectified first camera's coordinate system to the rectified first camera's coordinate system.
  6059. * param R2 Output 3x3 rectification transform (rotation matrix) for the second camera. This matrix
  6060. * brings points given in the unrectified second camera's coordinate system to points in the rectified
  6061. * second camera's coordinate system. In more technical terms, it performs a change of basis from the
  6062. * unrectified second camera's coordinate system to the rectified second camera's coordinate system.
  6063. * param P1 Output 3x4 projection matrix in the new (rectified) coordinate systems for the first
  6064. * camera, i.e. it projects points given in the rectified first camera coordinate system into the
  6065. * rectified first camera's image.
  6066. * param P2 Output 3x4 projection matrix in the new (rectified) coordinate systems for the second
  6067. * camera, i.e. it projects points given in the rectified first camera coordinate system into the
  6068. * rectified second camera's image.
  6069. * param Q Output \(4 \times 4\) disparity-to-depth mapping matrix (see REF: reprojectImageTo3D).
  6070. * param flags Operation flags that may be zero or REF: CALIB_ZERO_DISPARITY . If the flag is set,
  6071. * the function makes the principal points of each camera have the same pixel coordinates in the
  6072. * rectified views. And if the flag is not set, the function may still shift the images in the
  6073. * horizontal or vertical direction (depending on the orientation of epipolar lines) to maximize the
  6074. * useful image area.
  6075. * param alpha Free scaling parameter. If it is -1 or absent, the function performs the default
  6076. * scaling. Otherwise, the parameter should be between 0 and 1. alpha=0 means that the rectified
  6077. * images are zoomed and shifted so that only valid pixels are visible (no black areas after
  6078. * rectification). alpha=1 means that the rectified image is decimated and shifted so that all the
  6079. * pixels from the original images from the cameras are retained in the rectified images (no source
  6080. * image pixels are lost). Any intermediate value yields an intermediate result between
  6081. * those two extreme cases.
  6082. * #initUndistortRectifyMap (see the stereo_calib.cpp sample in OpenCV samples directory). When (0,0)
  6083. * is passed (default), it is set to the original imageSize . Setting it to a larger value can help you
  6084. * preserve details in the original image, especially when there is a big radial distortion.
  6085. * are valid. If alpha=0 , the ROIs cover the whole images. Otherwise, they are likely to be smaller
  6086. * (see the picture below).
  6087. * are valid. If alpha=0 , the ROIs cover the whole images. Otherwise, they are likely to be smaller
  6088. * (see the picture below).
  6089. *
  6090. * The function computes the rotation matrices for each camera that (virtually) make both camera image
  6091. * planes the same plane. Consequently, this makes all the epipolar lines parallel and thus simplifies
  6092. * the dense stereo correspondence problem. The function takes the matrices computed by #stereoCalibrate
  6093. * as input. As output, it provides two rotation matrices and also two projection matrices in the new
  6094. * coordinates. The function distinguishes the following two cases:
  6095. *
  6096. * <ul>
  6097. * <li>
  6098. * <b>Horizontal stereo</b>: the first and the second camera views are shifted relative to each other
  6099. * mainly along the x-axis (with possible small vertical shift). In the rectified images, the
  6100. * corresponding epipolar lines in the left and right cameras are horizontal and have the same
  6101. * y-coordinate. P1 and P2 look like:
  6102. * </li>
  6103. * </ul>
  6104. *
  6105. * \(\texttt{P1} = \begin{bmatrix}
  6106. * f &amp; 0 &amp; cx_1 &amp; 0 \\
  6107. * 0 &amp; f &amp; cy &amp; 0 \\
  6108. * 0 &amp; 0 &amp; 1 &amp; 0
  6109. * \end{bmatrix}\)
  6110. *
  6111. * \(\texttt{P2} = \begin{bmatrix}
  6112. * f &amp; 0 &amp; cx_2 &amp; T_x \cdot f \\
  6113. * 0 &amp; f &amp; cy &amp; 0 \\
  6114. * 0 &amp; 0 &amp; 1 &amp; 0
  6115. * \end{bmatrix} ,\)
  6116. *
  6117. * \(\texttt{Q} = \begin{bmatrix}
  6118. * 1 &amp; 0 &amp; 0 &amp; -cx_1 \\
  6119. * 0 &amp; 1 &amp; 0 &amp; -cy \\
  6120. * 0 &amp; 0 &amp; 0 &amp; f \\
  6121. * 0 &amp; 0 &amp; -\frac{1}{T_x} &amp; \frac{cx_1 - cx_2}{T_x}
  6122. * \end{bmatrix} \)
  6123. *
  6124. * where \(T_x\) is a horizontal shift between the cameras and \(cx_1=cx_2\) if
  6125. * REF: CALIB_ZERO_DISPARITY is set.
  6126. *
  6127. * <ul>
  6128. * <li>
  6129. * <b>Vertical stereo</b>: the first and the second camera views are shifted relative to each other
  6130. * mainly in the vertical direction (and probably a bit in the horizontal direction too). The epipolar
  6131. * lines in the rectified images are vertical and have the same x-coordinate. P1 and P2 look like:
  6132. * </li>
  6133. * </ul>
  6134. *
  6135. * \(\texttt{P1} = \begin{bmatrix}
  6136. * f &amp; 0 &amp; cx &amp; 0 \\
  6137. * 0 &amp; f &amp; cy_1 &amp; 0 \\
  6138. * 0 &amp; 0 &amp; 1 &amp; 0
  6139. * \end{bmatrix}\)
  6140. *
  6141. * \(\texttt{P2} = \begin{bmatrix}
  6142. * f &amp; 0 &amp; cx &amp; 0 \\
  6143. * 0 &amp; f &amp; cy_2 &amp; T_y \cdot f \\
  6144. * 0 &amp; 0 &amp; 1 &amp; 0
  6145. * \end{bmatrix},\)
  6146. *
  6147. * \(\texttt{Q} = \begin{bmatrix}
  6148. * 1 &amp; 0 &amp; 0 &amp; -cx \\
  6149. * 0 &amp; 1 &amp; 0 &amp; -cy_1 \\
  6150. * 0 &amp; 0 &amp; 0 &amp; f \\
  6151. * 0 &amp; 0 &amp; -\frac{1}{T_y} &amp; \frac{cy_1 - cy_2}{T_y}
  6152. * \end{bmatrix} \)
  6153. *
  6154. * where \(T_y\) is a vertical shift between the cameras and \(cy_1=cy_2\) if
  6155. * REF: CALIB_ZERO_DISPARITY is set.
  6156. *
  6157. * As you can see, the first three columns of P1 and P2 will effectively be the new "rectified" camera
  6158. * matrices. The matrices, together with R1 and R2 , can then be passed to #initUndistortRectifyMap to
  6159. * initialize the rectification map for each camera.
  6160. *
  6161. * See below the screenshot from the stereo_calib.cpp sample. Some red horizontal lines pass through
  6162. * the corresponding image regions. This means that the images are well rectified, which is what most
  6163. * stereo correspondence algorithms rely on. The green rectangles are roi1 and roi2 . You see that
  6164. * their interiors are all valid pixels.
  6165. *
  6166. * ![image](pics/stereo_undistort.jpg)
  6167. */
  6168. public static void stereoRectify(Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Size imageSize, Mat R, Mat T, Mat R1, Mat R2, Mat P1, Mat P2, Mat Q, int flags, double alpha)
  6169. {
  6170. if (cameraMatrix1 != null) cameraMatrix1.ThrowIfDisposed();
  6171. if (distCoeffs1 != null) distCoeffs1.ThrowIfDisposed();
  6172. if (cameraMatrix2 != null) cameraMatrix2.ThrowIfDisposed();
  6173. if (distCoeffs2 != null) distCoeffs2.ThrowIfDisposed();
  6174. if (R != null) R.ThrowIfDisposed();
  6175. if (T != null) T.ThrowIfDisposed();
  6176. if (R1 != null) R1.ThrowIfDisposed();
  6177. if (R2 != null) R2.ThrowIfDisposed();
  6178. if (P1 != null) P1.ThrowIfDisposed();
  6179. if (P2 != null) P2.ThrowIfDisposed();
  6180. if (Q != null) Q.ThrowIfDisposed();
  6181. calib3d_Calib3d_stereoRectify_13(cameraMatrix1.nativeObj, distCoeffs1.nativeObj, cameraMatrix2.nativeObj, distCoeffs2.nativeObj, imageSize.width, imageSize.height, R.nativeObj, T.nativeObj, R1.nativeObj, R2.nativeObj, P1.nativeObj, P2.nativeObj, Q.nativeObj, flags, alpha);
  6182. }
  6183. /**
  6184. * Computes rectification transforms for each head of a calibrated stereo camera.
  6185. *
  6186. * param cameraMatrix1 First camera intrinsic matrix.
  6187. * param distCoeffs1 First camera distortion parameters.
  6188. * param cameraMatrix2 Second camera intrinsic matrix.
  6189. * param distCoeffs2 Second camera distortion parameters.
  6190. * param imageSize Size of the image used for stereo calibration.
  6191. * param R Rotation matrix from the coordinate system of the first camera to the second camera,
  6192. * see REF: stereoCalibrate.
  6193. * param T Translation vector from the coordinate system of the first camera to the second camera,
  6194. * see REF: stereoCalibrate.
  6195. * param R1 Output 3x3 rectification transform (rotation matrix) for the first camera. This matrix
  6196. * brings points given in the unrectified first camera's coordinate system to points in the rectified
  6197. * first camera's coordinate system. In more technical terms, it performs a change of basis from the
  6198. * unrectified first camera's coordinate system to the rectified first camera's coordinate system.
  6199. * param R2 Output 3x3 rectification transform (rotation matrix) for the second camera. This matrix
  6200. * brings points given in the unrectified second camera's coordinate system to points in the rectified
  6201. * second camera's coordinate system. In more technical terms, it performs a change of basis from the
  6202. * unrectified second camera's coordinate system to the rectified second camera's coordinate system.
  6203. * param P1 Output 3x4 projection matrix in the new (rectified) coordinate systems for the first
  6204. * camera, i.e. it projects points given in the rectified first camera coordinate system into the
  6205. * rectified first camera's image.
  6206. * param P2 Output 3x4 projection matrix in the new (rectified) coordinate systems for the second
  6207. * camera, i.e. it projects points given in the rectified first camera coordinate system into the
  6208. * rectified second camera's image.
  6209. * param Q Output \(4 \times 4\) disparity-to-depth mapping matrix (see REF: reprojectImageTo3D).
  6210. * param flags Operation flags that may be zero or REF: CALIB_ZERO_DISPARITY . If the flag is set,
  6211. * the function makes the principal points of each camera have the same pixel coordinates in the
  6212. * rectified views. And if the flag is not set, the function may still shift the images in the
  6213. * horizontal or vertical direction (depending on the orientation of epipolar lines) to maximize the
  6214. * useful image area.
  6215. * scaling. Otherwise, the parameter should be between 0 and 1. alpha=0 means that the rectified
  6216. * images are zoomed and shifted so that only valid pixels are visible (no black areas after
  6217. * rectification). alpha=1 means that the rectified image is decimated and shifted so that all the
  6218. * pixels from the original images from the cameras are retained in the rectified images (no source
  6219. * image pixels are lost). Any intermediate value yields an intermediate result between
  6220. * those two extreme cases.
  6221. * #initUndistortRectifyMap (see the stereo_calib.cpp sample in OpenCV samples directory). When (0,0)
  6222. * is passed (default), it is set to the original imageSize . Setting it to a larger value can help you
  6223. * preserve details in the original image, especially when there is a big radial distortion.
  6224. * are valid. If alpha=0 , the ROIs cover the whole images. Otherwise, they are likely to be smaller
  6225. * (see the picture below).
  6226. * are valid. If alpha=0 , the ROIs cover the whole images. Otherwise, they are likely to be smaller
  6227. * (see the picture below).
  6228. *
  6229. * The function computes the rotation matrices for each camera that (virtually) make both camera image
  6230. * planes the same plane. Consequently, this makes all the epipolar lines parallel and thus simplifies
  6231. * the dense stereo correspondence problem. The function takes the matrices computed by #stereoCalibrate
  6232. * as input. As output, it provides two rotation matrices and also two projection matrices in the new
  6233. * coordinates. The function distinguishes the following two cases:
  6234. *
  6235. * <ul>
  6236. * <li>
  6237. * <b>Horizontal stereo</b>: the first and the second camera views are shifted relative to each other
  6238. * mainly along the x-axis (with possible small vertical shift). In the rectified images, the
  6239. * corresponding epipolar lines in the left and right cameras are horizontal and have the same
  6240. * y-coordinate. P1 and P2 look like:
  6241. * </li>
  6242. * </ul>
  6243. *
  6244. * \(\texttt{P1} = \begin{bmatrix}
  6245. * f &amp; 0 &amp; cx_1 &amp; 0 \\
  6246. * 0 &amp; f &amp; cy &amp; 0 \\
  6247. * 0 &amp; 0 &amp; 1 &amp; 0
  6248. * \end{bmatrix}\)
  6249. *
  6250. * \(\texttt{P2} = \begin{bmatrix}
  6251. * f &amp; 0 &amp; cx_2 &amp; T_x \cdot f \\
  6252. * 0 &amp; f &amp; cy &amp; 0 \\
  6253. * 0 &amp; 0 &amp; 1 &amp; 0
  6254. * \end{bmatrix} ,\)
  6255. *
  6256. * \(\texttt{Q} = \begin{bmatrix}
  6257. * 1 &amp; 0 &amp; 0 &amp; -cx_1 \\
  6258. * 0 &amp; 1 &amp; 0 &amp; -cy \\
  6259. * 0 &amp; 0 &amp; 0 &amp; f \\
  6260. * 0 &amp; 0 &amp; -\frac{1}{T_x} &amp; \frac{cx_1 - cx_2}{T_x}
  6261. * \end{bmatrix} \)
  6262. *
  6263. * where \(T_x\) is a horizontal shift between the cameras and \(cx_1=cx_2\) if
  6264. * REF: CALIB_ZERO_DISPARITY is set.
  6265. *
  6266. * <ul>
  6267. * <li>
  6268. * <b>Vertical stereo</b>: the first and the second camera views are shifted relative to each other
  6269. * mainly in the vertical direction (and probably a bit in the horizontal direction too). The epipolar
  6270. * lines in the rectified images are vertical and have the same x-coordinate. P1 and P2 look like:
  6271. * </li>
  6272. * </ul>
  6273. *
  6274. * \(\texttt{P1} = \begin{bmatrix}
  6275. * f &amp; 0 &amp; cx &amp; 0 \\
  6276. * 0 &amp; f &amp; cy_1 &amp; 0 \\
  6277. * 0 &amp; 0 &amp; 1 &amp; 0
  6278. * \end{bmatrix}\)
  6279. *
  6280. * \(\texttt{P2} = \begin{bmatrix}
  6281. * f &amp; 0 &amp; cx &amp; 0 \\
  6282. * 0 &amp; f &amp; cy_2 &amp; T_y \cdot f \\
  6283. * 0 &amp; 0 &amp; 1 &amp; 0
  6284. * \end{bmatrix},\)
  6285. *
  6286. * \(\texttt{Q} = \begin{bmatrix}
  6287. * 1 &amp; 0 &amp; 0 &amp; -cx \\
  6288. * 0 &amp; 1 &amp; 0 &amp; -cy_1 \\
  6289. * 0 &amp; 0 &amp; 0 &amp; f \\
  6290. * 0 &amp; 0 &amp; -\frac{1}{T_y} &amp; \frac{cy_1 - cy_2}{T_y}
  6291. * \end{bmatrix} \)
  6292. *
  6293. * where \(T_y\) is a vertical shift between the cameras and \(cy_1=cy_2\) if
  6294. * REF: CALIB_ZERO_DISPARITY is set.
  6295. *
  6296. * As you can see, the first three columns of P1 and P2 will effectively be the new "rectified" camera
  6297. * matrices. The matrices, together with R1 and R2 , can then be passed to #initUndistortRectifyMap to
  6298. * initialize the rectification map for each camera.
  6299. *
  6300. * See below the screenshot from the stereo_calib.cpp sample. Some red horizontal lines pass through
  6301. * the corresponding image regions. This means that the images are well rectified, which is what most
  6302. * stereo correspondence algorithms rely on. The green rectangles are roi1 and roi2 . You see that
  6303. * their interiors are all valid pixels.
  6304. *
  6305. * ![image](pics/stereo_undistort.jpg)
  6306. */
  6307. public static void stereoRectify(Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Size imageSize, Mat R, Mat T, Mat R1, Mat R2, Mat P1, Mat P2, Mat Q, int flags)
  6308. {
  6309. if (cameraMatrix1 != null) cameraMatrix1.ThrowIfDisposed();
  6310. if (distCoeffs1 != null) distCoeffs1.ThrowIfDisposed();
  6311. if (cameraMatrix2 != null) cameraMatrix2.ThrowIfDisposed();
  6312. if (distCoeffs2 != null) distCoeffs2.ThrowIfDisposed();
  6313. if (R != null) R.ThrowIfDisposed();
  6314. if (T != null) T.ThrowIfDisposed();
  6315. if (R1 != null) R1.ThrowIfDisposed();
  6316. if (R2 != null) R2.ThrowIfDisposed();
  6317. if (P1 != null) P1.ThrowIfDisposed();
  6318. if (P2 != null) P2.ThrowIfDisposed();
  6319. if (Q != null) Q.ThrowIfDisposed();
  6320. calib3d_Calib3d_stereoRectify_14(cameraMatrix1.nativeObj, distCoeffs1.nativeObj, cameraMatrix2.nativeObj, distCoeffs2.nativeObj, imageSize.width, imageSize.height, R.nativeObj, T.nativeObj, R1.nativeObj, R2.nativeObj, P1.nativeObj, P2.nativeObj, Q.nativeObj, flags);
  6321. }
  6322. /**
  6323. * Computes rectification transforms for each head of a calibrated stereo camera.
  6324. *
  6325. * param cameraMatrix1 First camera intrinsic matrix.
  6326. * param distCoeffs1 First camera distortion parameters.
  6327. * param cameraMatrix2 Second camera intrinsic matrix.
  6328. * param distCoeffs2 Second camera distortion parameters.
  6329. * param imageSize Size of the image used for stereo calibration.
  6330. * param R Rotation matrix from the coordinate system of the first camera to the second camera,
  6331. * see REF: stereoCalibrate.
  6332. * param T Translation vector from the coordinate system of the first camera to the second camera,
  6333. * see REF: stereoCalibrate.
  6334. * param R1 Output 3x3 rectification transform (rotation matrix) for the first camera. This matrix
  6335. * brings points given in the unrectified first camera's coordinate system to points in the rectified
  6336. * first camera's coordinate system. In more technical terms, it performs a change of basis from the
  6337. * unrectified first camera's coordinate system to the rectified first camera's coordinate system.
  6338. * param R2 Output 3x3 rectification transform (rotation matrix) for the second camera. This matrix
  6339. * brings points given in the unrectified second camera's coordinate system to points in the rectified
  6340. * second camera's coordinate system. In more technical terms, it performs a change of basis from the
  6341. * unrectified second camera's coordinate system to the rectified second camera's coordinate system.
  6342. * param P1 Output 3x4 projection matrix in the new (rectified) coordinate systems for the first
  6343. * camera, i.e. it projects points given in the rectified first camera coordinate system into the
  6344. * rectified first camera's image.
  6345. * param P2 Output 3x4 projection matrix in the new (rectified) coordinate systems for the second
  6346. * camera, i.e. it projects points given in the rectified first camera coordinate system into the
  6347. * rectified second camera's image.
  6348. * param Q Output \(4 \times 4\) disparity-to-depth mapping matrix (see REF: reprojectImageTo3D).
  6349. * the function makes the principal points of each camera have the same pixel coordinates in the
  6350. * rectified views. And if the flag is not set, the function may still shift the images in the
  6351. * horizontal or vertical direction (depending on the orientation of epipolar lines) to maximize the
  6352. * useful image area.
  6353. * scaling. Otherwise, the parameter should be between 0 and 1. alpha=0 means that the rectified
  6354. * images are zoomed and shifted so that only valid pixels are visible (no black areas after
  6355. * rectification). alpha=1 means that the rectified image is decimated and shifted so that all the
  6356. * pixels from the original images from the cameras are retained in the rectified images (no source
  6357. * image pixels are lost). Any intermediate value yields an intermediate result between
  6358. * those two extreme cases.
  6359. * #initUndistortRectifyMap (see the stereo_calib.cpp sample in OpenCV samples directory). When (0,0)
  6360. * is passed (default), it is set to the original imageSize . Setting it to a larger value can help you
  6361. * preserve details in the original image, especially when there is a big radial distortion.
  6362. * are valid. If alpha=0 , the ROIs cover the whole images. Otherwise, they are likely to be smaller
  6363. * (see the picture below).
  6364. * are valid. If alpha=0 , the ROIs cover the whole images. Otherwise, they are likely to be smaller
  6365. * (see the picture below).
  6366. *
  6367. * The function computes the rotation matrices for each camera that (virtually) make both camera image
  6368. * planes the same plane. Consequently, this makes all the epipolar lines parallel and thus simplifies
  6369. * the dense stereo correspondence problem. The function takes the matrices computed by #stereoCalibrate
  6370. * as input. As output, it provides two rotation matrices and also two projection matrices in the new
  6371. * coordinates. The function distinguishes the following two cases:
  6372. *
  6373. * <ul>
  6374. * <li>
  6375. * <b>Horizontal stereo</b>: the first and the second camera views are shifted relative to each other
  6376. * mainly along the x-axis (with possible small vertical shift). In the rectified images, the
  6377. * corresponding epipolar lines in the left and right cameras are horizontal and have the same
  6378. * y-coordinate. P1 and P2 look like:
  6379. * </li>
  6380. * </ul>
  6381. *
  6382. * \(\texttt{P1} = \begin{bmatrix}
  6383. * f &amp; 0 &amp; cx_1 &amp; 0 \\
  6384. * 0 &amp; f &amp; cy &amp; 0 \\
  6385. * 0 &amp; 0 &amp; 1 &amp; 0
  6386. * \end{bmatrix}\)
  6387. *
  6388. * \(\texttt{P2} = \begin{bmatrix}
  6389. * f &amp; 0 &amp; cx_2 &amp; T_x \cdot f \\
  6390. * 0 &amp; f &amp; cy &amp; 0 \\
  6391. * 0 &amp; 0 &amp; 1 &amp; 0
  6392. * \end{bmatrix} ,\)
  6393. *
  6394. * \(\texttt{Q} = \begin{bmatrix}
  6395. * 1 &amp; 0 &amp; 0 &amp; -cx_1 \\
  6396. * 0 &amp; 1 &amp; 0 &amp; -cy \\
  6397. * 0 &amp; 0 &amp; 0 &amp; f \\
  6398. * 0 &amp; 0 &amp; -\frac{1}{T_x} &amp; \frac{cx_1 - cx_2}{T_x}
  6399. * \end{bmatrix} \)
  6400. *
  6401. * where \(T_x\) is a horizontal shift between the cameras and \(cx_1=cx_2\) if
  6402. * REF: CALIB_ZERO_DISPARITY is set.
  6403. *
  6404. * <ul>
  6405. * <li>
  6406. * <b>Vertical stereo</b>: the first and the second camera views are shifted relative to each other
  6407. * mainly in the vertical direction (and probably a bit in the horizontal direction too). The epipolar
  6408. * lines in the rectified images are vertical and have the same x-coordinate. P1 and P2 look like:
  6409. * </li>
  6410. * </ul>
  6411. *
  6412. * \(\texttt{P1} = \begin{bmatrix}
  6413. * f &amp; 0 &amp; cx &amp; 0 \\
  6414. * 0 &amp; f &amp; cy_1 &amp; 0 \\
  6415. * 0 &amp; 0 &amp; 1 &amp; 0
  6416. * \end{bmatrix}\)
  6417. *
  6418. * \(\texttt{P2} = \begin{bmatrix}
  6419. * f &amp; 0 &amp; cx &amp; 0 \\
  6420. * 0 &amp; f &amp; cy_2 &amp; T_y \cdot f \\
  6421. * 0 &amp; 0 &amp; 1 &amp; 0
  6422. * \end{bmatrix},\)
  6423. *
  6424. * \(\texttt{Q} = \begin{bmatrix}
  6425. * 1 &amp; 0 &amp; 0 &amp; -cx \\
  6426. * 0 &amp; 1 &amp; 0 &amp; -cy_1 \\
  6427. * 0 &amp; 0 &amp; 0 &amp; f \\
  6428. * 0 &amp; 0 &amp; -\frac{1}{T_y} &amp; \frac{cy_1 - cy_2}{T_y}
  6429. * \end{bmatrix} \)
  6430. *
  6431. * where \(T_y\) is a vertical shift between the cameras and \(cy_1=cy_2\) if
  6432. * REF: CALIB_ZERO_DISPARITY is set.
  6433. *
  6434. * As you can see, the first three columns of P1 and P2 will effectively be the new "rectified" camera
  6435. * matrices. The matrices, together with R1 and R2 , can then be passed to #initUndistortRectifyMap to
  6436. * initialize the rectification map for each camera.
  6437. *
  6438. * See below the screenshot from the stereo_calib.cpp sample. Some red horizontal lines pass through
  6439. * the corresponding image regions. This means that the images are well rectified, which is what most
  6440. * stereo correspondence algorithms rely on. The green rectangles are roi1 and roi2 . You see that
  6441. * their interiors are all valid pixels.
  6442. *
  6443. * ![image](pics/stereo_undistort.jpg)
  6444. */
  6445. public static void stereoRectify(Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Size imageSize, Mat R, Mat T, Mat R1, Mat R2, Mat P1, Mat P2, Mat Q)
  6446. {
  6447. if (cameraMatrix1 != null) cameraMatrix1.ThrowIfDisposed();
  6448. if (distCoeffs1 != null) distCoeffs1.ThrowIfDisposed();
  6449. if (cameraMatrix2 != null) cameraMatrix2.ThrowIfDisposed();
  6450. if (distCoeffs2 != null) distCoeffs2.ThrowIfDisposed();
  6451. if (R != null) R.ThrowIfDisposed();
  6452. if (T != null) T.ThrowIfDisposed();
  6453. if (R1 != null) R1.ThrowIfDisposed();
  6454. if (R2 != null) R2.ThrowIfDisposed();
  6455. if (P1 != null) P1.ThrowIfDisposed();
  6456. if (P2 != null) P2.ThrowIfDisposed();
  6457. if (Q != null) Q.ThrowIfDisposed();
  6458. calib3d_Calib3d_stereoRectify_15(cameraMatrix1.nativeObj, distCoeffs1.nativeObj, cameraMatrix2.nativeObj, distCoeffs2.nativeObj, imageSize.width, imageSize.height, R.nativeObj, T.nativeObj, R1.nativeObj, R2.nativeObj, P1.nativeObj, P2.nativeObj, Q.nativeObj);
  6459. }
  6460. //
  6461. // C++: bool cv::stereoRectifyUncalibrated(Mat points1, Mat points2, Mat F, Size imgSize, Mat& H1, Mat& H2, double threshold = 5)
  6462. //
  6463. /**
  6464. * Computes a rectification transform for an uncalibrated stereo camera.
  6465. *
  6466. * param points1 Array of feature points in the first image.
  6467. * param points2 The corresponding points in the second image. The same formats as in
  6468. * #findFundamentalMat are supported.
  6469. * param F Input fundamental matrix. It can be computed from the same set of point pairs using
  6470. * #findFundamentalMat .
  6471. * param imgSize Size of the image.
  6472. * param H1 Output rectification homography matrix for the first image.
  6473. * param H2 Output rectification homography matrix for the second image.
  6474. * param threshold Optional threshold used to filter out the outliers. If the parameter is greater
  6475. * than zero, all the point pairs that do not comply with the epipolar geometry (that is, the points
  6476. * for which \(|\texttt{points2[i]}^T \cdot \texttt{F} \cdot \texttt{points1[i]}|&gt;\texttt{threshold}\) )
  6477. * are rejected prior to computing the homographies. Otherwise, all the points are considered inliers.
  6478. *
  6479. * The function computes the rectification transformations without knowing intrinsic parameters of the
  6480. * cameras and their relative position in the space, which explains the suffix "uncalibrated". Another
  6481. * related difference from #stereoRectify is that the function outputs not the rectification
  6482. * transformations in the object (3D) space, but the planar perspective transformations encoded by the
  6483. * homography matrices H1 and H2 . The function implements the algorithm CITE: Hartley99 .
  6484. *
  6485. * <b>Note:</b>
  6486. * While the algorithm does not need to know the intrinsic parameters of the cameras, it heavily
  6487. * depends on the epipolar geometry. Therefore, if the camera lenses have a significant distortion,
  6488. * it would be better to correct it before computing the fundamental matrix and calling this
  6489. * function. For example, distortion coefficients can be estimated for each head of stereo camera
  6490. * separately by using #calibrateCamera . Then, the images can be corrected using #undistort , or
  6491. * just the point coordinates can be corrected with #undistortPoints .
  6492. * return automatically generated
  6493. */
  6494. public static bool stereoRectifyUncalibrated(Mat points1, Mat points2, Mat F, Size imgSize, Mat H1, Mat H2, double threshold)
  6495. {
  6496. if (points1 != null) points1.ThrowIfDisposed();
  6497. if (points2 != null) points2.ThrowIfDisposed();
  6498. if (F != null) F.ThrowIfDisposed();
  6499. if (H1 != null) H1.ThrowIfDisposed();
  6500. if (H2 != null) H2.ThrowIfDisposed();
  6501. return calib3d_Calib3d_stereoRectifyUncalibrated_10(points1.nativeObj, points2.nativeObj, F.nativeObj, imgSize.width, imgSize.height, H1.nativeObj, H2.nativeObj, threshold);
  6502. }
  6503. /**
  6504. * Computes a rectification transform for an uncalibrated stereo camera.
  6505. *
  6506. * param points1 Array of feature points in the first image.
  6507. * param points2 The corresponding points in the second image. The same formats as in
  6508. * #findFundamentalMat are supported.
  6509. * param F Input fundamental matrix. It can be computed from the same set of point pairs using
  6510. * #findFundamentalMat .
  6511. * param imgSize Size of the image.
  6512. * param H1 Output rectification homography matrix for the first image.
  6513. * param H2 Output rectification homography matrix for the second image.
  6514. * than zero, all the point pairs that do not comply with the epipolar geometry (that is, the points
  6515. * for which \(|\texttt{points2[i]}^T \cdot \texttt{F} \cdot \texttt{points1[i]}|&gt;\texttt{threshold}\) )
  6516. * are rejected prior to computing the homographies. Otherwise, all the points are considered inliers.
  6517. *
  6518. * The function computes the rectification transformations without knowing intrinsic parameters of the
  6519. * cameras and their relative position in the space, which explains the suffix "uncalibrated". Another
  6520. * related difference from #stereoRectify is that the function outputs not the rectification
  6521. * transformations in the object (3D) space, but the planar perspective transformations encoded by the
  6522. * homography matrices H1 and H2 . The function implements the algorithm CITE: Hartley99 .
  6523. *
  6524. * <b>Note:</b>
  6525. * While the algorithm does not need to know the intrinsic parameters of the cameras, it heavily
  6526. * depends on the epipolar geometry. Therefore, if the camera lenses have a significant distortion,
  6527. * it would be better to correct it before computing the fundamental matrix and calling this
  6528. * function. For example, distortion coefficients can be estimated for each head of stereo camera
  6529. * separately by using #calibrateCamera . Then, the images can be corrected using #undistort , or
  6530. * just the point coordinates can be corrected with #undistortPoints .
  6531. * return automatically generated
  6532. */
  6533. public static bool stereoRectifyUncalibrated(Mat points1, Mat points2, Mat F, Size imgSize, Mat H1, Mat H2)
  6534. {
  6535. if (points1 != null) points1.ThrowIfDisposed();
  6536. if (points2 != null) points2.ThrowIfDisposed();
  6537. if (F != null) F.ThrowIfDisposed();
  6538. if (H1 != null) H1.ThrowIfDisposed();
  6539. if (H2 != null) H2.ThrowIfDisposed();
  6540. return calib3d_Calib3d_stereoRectifyUncalibrated_11(points1.nativeObj, points2.nativeObj, F.nativeObj, imgSize.width, imgSize.height, H1.nativeObj, H2.nativeObj);
  6541. }
  6542. //
  6543. // C++: float cv::rectify3Collinear(Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Mat cameraMatrix3, Mat distCoeffs3, vector_Mat imgpt1, vector_Mat imgpt3, Size imageSize, Mat R12, Mat T12, Mat R13, Mat T13, Mat& R1, Mat& R2, Mat& R3, Mat& P1, Mat& P2, Mat& P3, Mat& Q, double alpha, Size newImgSize, Rect* roi1, Rect* roi2, int flags)
  6544. //
  6545. public static float rectify3Collinear(Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Mat cameraMatrix3, Mat distCoeffs3, List<Mat> imgpt1, List<Mat> imgpt3, Size imageSize, Mat R12, Mat T12, Mat R13, Mat T13, Mat R1, Mat R2, Mat R3, Mat P1, Mat P2, Mat P3, Mat Q, double alpha, Size newImgSize, Rect roi1, Rect roi2, int flags)
  6546. {
  6547. if (cameraMatrix1 != null) cameraMatrix1.ThrowIfDisposed();
  6548. if (distCoeffs1 != null) distCoeffs1.ThrowIfDisposed();
  6549. if (cameraMatrix2 != null) cameraMatrix2.ThrowIfDisposed();
  6550. if (distCoeffs2 != null) distCoeffs2.ThrowIfDisposed();
  6551. if (cameraMatrix3 != null) cameraMatrix3.ThrowIfDisposed();
  6552. if (distCoeffs3 != null) distCoeffs3.ThrowIfDisposed();
  6553. if (R12 != null) R12.ThrowIfDisposed();
  6554. if (T12 != null) T12.ThrowIfDisposed();
  6555. if (R13 != null) R13.ThrowIfDisposed();
  6556. if (T13 != null) T13.ThrowIfDisposed();
  6557. if (R1 != null) R1.ThrowIfDisposed();
  6558. if (R2 != null) R2.ThrowIfDisposed();
  6559. if (R3 != null) R3.ThrowIfDisposed();
  6560. if (P1 != null) P1.ThrowIfDisposed();
  6561. if (P2 != null) P2.ThrowIfDisposed();
  6562. if (P3 != null) P3.ThrowIfDisposed();
  6563. if (Q != null) Q.ThrowIfDisposed();
  6564. Mat imgpt1_mat = Converters.vector_Mat_to_Mat(imgpt1);
  6565. Mat imgpt3_mat = Converters.vector_Mat_to_Mat(imgpt3);
  6566. double[] roi1_out = new double[4];
  6567. double[] roi2_out = new double[4];
  6568. float retVal = calib3d_Calib3d_rectify3Collinear_10(cameraMatrix1.nativeObj, distCoeffs1.nativeObj, cameraMatrix2.nativeObj, distCoeffs2.nativeObj, cameraMatrix3.nativeObj, distCoeffs3.nativeObj, imgpt1_mat.nativeObj, imgpt3_mat.nativeObj, imageSize.width, imageSize.height, R12.nativeObj, T12.nativeObj, R13.nativeObj, T13.nativeObj, R1.nativeObj, R2.nativeObj, R3.nativeObj, P1.nativeObj, P2.nativeObj, P3.nativeObj, Q.nativeObj, alpha, newImgSize.width, newImgSize.height, roi1_out, roi2_out, flags);
  6569. if (roi1 != null) { roi1.x = (int)roi1_out[0]; roi1.y = (int)roi1_out[1]; roi1.width = (int)roi1_out[2]; roi1.height = (int)roi1_out[3]; }
  6570. if (roi2 != null) { roi2.x = (int)roi2_out[0]; roi2.y = (int)roi2_out[1]; roi2.width = (int)roi2_out[2]; roi2.height = (int)roi2_out[3]; }
  6571. return retVal;
  6572. }
  6573. //
  6574. // C++: Mat cv::getOptimalNewCameraMatrix(Mat cameraMatrix, Mat distCoeffs, Size imageSize, double alpha, Size newImgSize = Size(), Rect* validPixROI = 0, bool centerPrincipalPoint = false)
  6575. //
  6576. /**
  6577. * Returns the new camera intrinsic matrix based on the free scaling parameter.
  6578. *
  6579. * param cameraMatrix Input camera intrinsic matrix.
  6580. * param distCoeffs Input vector of distortion coefficients
  6581. * \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
  6582. * assumed.
  6583. * param imageSize Original image size.
  6584. * param alpha Free scaling parameter between 0 (when all the pixels in the undistorted image are
  6585. * valid) and 1 (when all the source image pixels are retained in the undistorted image). See
  6586. * #stereoRectify for details.
  6587. * param newImgSize Image size after rectification. By default, it is set to imageSize .
  6588. * param validPixROI Optional output rectangle that outlines all-good-pixels region in the
  6589. * undistorted image. See roi1, roi2 description in #stereoRectify .
  6590. * param centerPrincipalPoint Optional flag that indicates whether in the new camera intrinsic matrix the
  6591. * principal point should be at the image center or not. By default, the principal point is chosen to
  6592. * best fit a subset of the source image (determined by alpha) to the corrected image.
  6593. * return new_camera_matrix Output new camera intrinsic matrix.
  6594. *
  6595. * The function computes and returns the optimal new camera intrinsic matrix based on the free scaling parameter.
  6596. * By varying this parameter, you may retrieve only sensible pixels alpha=0 , keep all the original
  6597. * image pixels if there is valuable information in the corners alpha=1 , or get something in between.
  6598. * When alpha&gt;0 , the undistorted result is likely to have some black pixels corresponding to
  6599. * "virtual" pixels outside of the captured distorted image. The original camera intrinsic matrix, distortion
  6600. * coefficients, the computed new camera intrinsic matrix, and newImageSize should be passed to
  6601. * #initUndistortRectifyMap to produce the maps for #remap .
  6602. */
  6603. public static Mat getOptimalNewCameraMatrix(Mat cameraMatrix, Mat distCoeffs, Size imageSize, double alpha, Size newImgSize, Rect validPixROI, bool centerPrincipalPoint)
  6604. {
  6605. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  6606. if (distCoeffs != null) distCoeffs.ThrowIfDisposed();
  6607. double[] validPixROI_out = new double[4];
  6608. Mat retVal = new Mat(DisposableObject.ThrowIfNullIntPtr(calib3d_Calib3d_getOptimalNewCameraMatrix_10(cameraMatrix.nativeObj, distCoeffs.nativeObj, imageSize.width, imageSize.height, alpha, newImgSize.width, newImgSize.height, validPixROI_out, centerPrincipalPoint)));
  6609. if (validPixROI != null) { validPixROI.x = (int)validPixROI_out[0]; validPixROI.y = (int)validPixROI_out[1]; validPixROI.width = (int)validPixROI_out[2]; validPixROI.height = (int)validPixROI_out[3]; }
  6610. return retVal;
  6611. }
  6612. /**
  6613. * Returns the new camera intrinsic matrix based on the free scaling parameter.
  6614. *
  6615. * param cameraMatrix Input camera intrinsic matrix.
  6616. * param distCoeffs Input vector of distortion coefficients
  6617. * \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
  6618. * assumed.
  6619. * param imageSize Original image size.
  6620. * param alpha Free scaling parameter between 0 (when all the pixels in the undistorted image are
  6621. * valid) and 1 (when all the source image pixels are retained in the undistorted image). See
  6622. * #stereoRectify for details.
  6623. * param newImgSize Image size after rectification. By default, it is set to imageSize .
  6624. * param validPixROI Optional output rectangle that outlines all-good-pixels region in the
  6625. * undistorted image. See roi1, roi2 description in #stereoRectify .
  6626. * principal point should be at the image center or not. By default, the principal point is chosen to
  6627. * best fit a subset of the source image (determined by alpha) to the corrected image.
  6628. * return new_camera_matrix Output new camera intrinsic matrix.
  6629. *
  6630. * The function computes and returns the optimal new camera intrinsic matrix based on the free scaling parameter.
  6631. * By varying this parameter, you may retrieve only sensible pixels alpha=0 , keep all the original
  6632. * image pixels if there is valuable information in the corners alpha=1 , or get something in between.
  6633. * When alpha&gt;0 , the undistorted result is likely to have some black pixels corresponding to
  6634. * "virtual" pixels outside of the captured distorted image. The original camera intrinsic matrix, distortion
  6635. * coefficients, the computed new camera intrinsic matrix, and newImageSize should be passed to
  6636. * #initUndistortRectifyMap to produce the maps for #remap .
  6637. */
  6638. public static Mat getOptimalNewCameraMatrix(Mat cameraMatrix, Mat distCoeffs, Size imageSize, double alpha, Size newImgSize, Rect validPixROI)
  6639. {
  6640. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  6641. if (distCoeffs != null) distCoeffs.ThrowIfDisposed();
  6642. double[] validPixROI_out = new double[4];
  6643. Mat retVal = new Mat(DisposableObject.ThrowIfNullIntPtr(calib3d_Calib3d_getOptimalNewCameraMatrix_11(cameraMatrix.nativeObj, distCoeffs.nativeObj, imageSize.width, imageSize.height, alpha, newImgSize.width, newImgSize.height, validPixROI_out)));
  6644. if (validPixROI != null) { validPixROI.x = (int)validPixROI_out[0]; validPixROI.y = (int)validPixROI_out[1]; validPixROI.width = (int)validPixROI_out[2]; validPixROI.height = (int)validPixROI_out[3]; }
  6645. return retVal;
  6646. }
  6647. /**
  6648. * Returns the new camera intrinsic matrix based on the free scaling parameter.
  6649. *
  6650. * param cameraMatrix Input camera intrinsic matrix.
  6651. * param distCoeffs Input vector of distortion coefficients
  6652. * \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
  6653. * assumed.
  6654. * param imageSize Original image size.
  6655. * param alpha Free scaling parameter between 0 (when all the pixels in the undistorted image are
  6656. * valid) and 1 (when all the source image pixels are retained in the undistorted image). See
  6657. * #stereoRectify for details.
  6658. * param newImgSize Image size after rectification. By default, it is set to imageSize .
  6659. * undistorted image. See roi1, roi2 description in #stereoRectify .
  6660. * principal point should be at the image center or not. By default, the principal point is chosen to
  6661. * best fit a subset of the source image (determined by alpha) to the corrected image.
  6662. * return new_camera_matrix Output new camera intrinsic matrix.
  6663. *
  6664. * The function computes and returns the optimal new camera intrinsic matrix based on the free scaling parameter.
  6665. * By varying this parameter, you may retrieve only sensible pixels alpha=0 , keep all the original
  6666. * image pixels if there is valuable information in the corners alpha=1 , or get something in between.
  6667. * When alpha&gt;0 , the undistorted result is likely to have some black pixels corresponding to
  6668. * "virtual" pixels outside of the captured distorted image. The original camera intrinsic matrix, distortion
  6669. * coefficients, the computed new camera intrinsic matrix, and newImageSize should be passed to
  6670. * #initUndistortRectifyMap to produce the maps for #remap .
  6671. */
  6672. public static Mat getOptimalNewCameraMatrix(Mat cameraMatrix, Mat distCoeffs, Size imageSize, double alpha, Size newImgSize)
  6673. {
  6674. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  6675. if (distCoeffs != null) distCoeffs.ThrowIfDisposed();
  6676. return new Mat(DisposableObject.ThrowIfNullIntPtr(calib3d_Calib3d_getOptimalNewCameraMatrix_12(cameraMatrix.nativeObj, distCoeffs.nativeObj, imageSize.width, imageSize.height, alpha, newImgSize.width, newImgSize.height)));
  6677. }
  6678. /**
  6679. * Returns the new camera intrinsic matrix based on the free scaling parameter.
  6680. *
  6681. * param cameraMatrix Input camera intrinsic matrix.
  6682. * param distCoeffs Input vector of distortion coefficients
  6683. * \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
  6684. * assumed.
  6685. * param imageSize Original image size.
  6686. * param alpha Free scaling parameter between 0 (when all the pixels in the undistorted image are
  6687. * valid) and 1 (when all the source image pixels are retained in the undistorted image). See
  6688. * #stereoRectify for details.
  6689. * undistorted image. See roi1, roi2 description in #stereoRectify .
  6690. * principal point should be at the image center or not. By default, the principal point is chosen to
  6691. * best fit a subset of the source image (determined by alpha) to the corrected image.
  6692. * return new_camera_matrix Output new camera intrinsic matrix.
  6693. *
  6694. * The function computes and returns the optimal new camera intrinsic matrix based on the free scaling parameter.
  6695. * By varying this parameter, you may retrieve only sensible pixels alpha=0 , keep all the original
  6696. * image pixels if there is valuable information in the corners alpha=1 , or get something in between.
  6697. * When alpha&gt;0 , the undistorted result is likely to have some black pixels corresponding to
  6698. * "virtual" pixels outside of the captured distorted image. The original camera intrinsic matrix, distortion
  6699. * coefficients, the computed new camera intrinsic matrix, and newImageSize should be passed to
  6700. * #initUndistortRectifyMap to produce the maps for #remap .
  6701. */
  6702. public static Mat getOptimalNewCameraMatrix(Mat cameraMatrix, Mat distCoeffs, Size imageSize, double alpha)
  6703. {
  6704. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  6705. if (distCoeffs != null) distCoeffs.ThrowIfDisposed();
  6706. return new Mat(DisposableObject.ThrowIfNullIntPtr(calib3d_Calib3d_getOptimalNewCameraMatrix_13(cameraMatrix.nativeObj, distCoeffs.nativeObj, imageSize.width, imageSize.height, alpha)));
  6707. }
  6708. //
  6709. // C++: void cv::calibrateHandEye(vector_Mat R_gripper2base, vector_Mat t_gripper2base, vector_Mat R_target2cam, vector_Mat t_target2cam, Mat& R_cam2gripper, Mat& t_cam2gripper, HandEyeCalibrationMethod method = CALIB_HAND_EYE_TSAI)
  6710. //
  6711. /**
  6712. * Computes Hand-Eye calibration: \(_{}^{g}\textrm{T}_c\)
  6713. *
  6714. * param R_gripper2base Rotation part extracted from the homogeneous matrix that transforms a point
  6715. * expressed in the gripper frame to the robot base frame (\(_{}^{b}\textrm{T}_g\)).
  6716. * This is a vector ({code vector&lt;Mat&gt;}) that contains the rotation, {code (3x3)} rotation matrices or {code (3x1)} rotation vectors,
  6717. * for all the transformations from gripper frame to robot base frame.
  6718. * param t_gripper2base Translation part extracted from the homogeneous matrix that transforms a point
  6719. * expressed in the gripper frame to the robot base frame (\(_{}^{b}\textrm{T}_g\)).
  6720. * This is a vector ({code vector&lt;Mat&gt;}) that contains the {code (3x1)} translation vectors for all the transformations
  6721. * from gripper frame to robot base frame.
  6722. * param R_target2cam Rotation part extracted from the homogeneous matrix that transforms a point
  6723. * expressed in the target frame to the camera frame (\(_{}^{c}\textrm{T}_t\)).
  6724. * This is a vector ({code vector&lt;Mat&gt;}) that contains the rotation, {code (3x3)} rotation matrices or {code (3x1)} rotation vectors,
  6725. * for all the transformations from calibration target frame to camera frame.
  6726. * param t_target2cam Rotation part extracted from the homogeneous matrix that transforms a point
  6727. * expressed in the target frame to the camera frame (\(_{}^{c}\textrm{T}_t\)).
  6728. * This is a vector ({code vector&lt;Mat&gt;}) that contains the {code (3x1)} translation vectors for all the transformations
  6729. * from calibration target frame to camera frame.
  6730. * param R_cam2gripper Estimated {code (3x3)} rotation part extracted from the homogeneous matrix that transforms a point
  6731. * expressed in the camera frame to the gripper frame (\(_{}^{g}\textrm{T}_c\)).
  6732. * param t_cam2gripper Estimated {code (3x1)} translation part extracted from the homogeneous matrix that transforms a point
  6733. * expressed in the camera frame to the gripper frame (\(_{}^{g}\textrm{T}_c\)).
  6734. * param method One of the implemented Hand-Eye calibration method, see cv::HandEyeCalibrationMethod
  6735. *
  6736. * The function performs the Hand-Eye calibration using various methods. One approach consists in estimating the
  6737. * rotation then the translation (separable solutions) and the following methods are implemented:
  6738. * <ul>
  6739. * <li>
  6740. * R. Tsai, R. Lenz A New Technique for Fully Autonomous and Efficient 3D Robotics Hand/EyeCalibration \cite Tsai89
  6741. * </li>
  6742. * <li>
  6743. * F. Park, B. Martin Robot Sensor Calibration: Solving AX = XB on the Euclidean Group \cite Park94
  6744. * </li>
  6745. * <li>
  6746. * R. Horaud, F. Dornaika Hand-Eye Calibration \cite Horaud95
  6747. * </li>
  6748. * </ul>
  6749. *
  6750. * Another approach consists in estimating simultaneously the rotation and the translation (simultaneous solutions),
  6751. * with the following implemented methods:
  6752. * <ul>
  6753. * <li>
  6754. * N. Andreff, R. Horaud, B. Espiau On-line Hand-Eye Calibration \cite Andreff99
  6755. * </li>
  6756. * <li>
  6757. * K. Daniilidis Hand-Eye Calibration Using Dual Quaternions \cite Daniilidis98
  6758. * </li>
  6759. * </ul>
  6760. *
  6761. * The following picture describes the Hand-Eye calibration problem where the transformation between a camera ("eye")
  6762. * mounted on a robot gripper ("hand") has to be estimated. This configuration is called eye-in-hand.
  6763. *
  6764. * The eye-to-hand configuration consists in a static camera observing a calibration pattern mounted on the robot
  6765. * end-effector. The transformation from the camera to the robot base frame can then be estimated by inputting
  6766. * the suitable transformations to the function, see below.
  6767. *
  6768. * ![](pics/hand-eye_figure.png)
  6769. *
  6770. * The calibration procedure is the following:
  6771. * <ul>
  6772. * <li>
  6773. * a static calibration pattern is used to estimate the transformation between the target frame
  6774. * and the camera frame
  6775. * </li>
  6776. * <li>
  6777. * the robot gripper is moved in order to acquire several poses
  6778. * </li>
  6779. * <li>
  6780. * for each pose, the homogeneous transformation between the gripper frame and the robot base frame is recorded using for
  6781. * instance the robot kinematics
  6782. * \(
  6783. * \begin{bmatrix}
  6784. * X_b\\
  6785. * Y_b\\
  6786. * Z_b\\
  6787. * 1
  6788. * \end{bmatrix}
  6789. * =
  6790. * \begin{bmatrix}
  6791. * _{}^{b}\textrm{R}_g &amp; _{}^{b}\textrm{t}_g \\
  6792. * 0_{1 \times 3} &amp; 1
  6793. * \end{bmatrix}
  6794. * \begin{bmatrix}
  6795. * X_g\\
  6796. * Y_g\\
  6797. * Z_g\\
  6798. * 1
  6799. * \end{bmatrix}
  6800. * \)
  6801. * </li>
  6802. * <li>
  6803. * for each pose, the homogeneous transformation between the calibration target frame and the camera frame is recorded using
  6804. * for instance a pose estimation method (PnP) from 2D-3D point correspondences
  6805. * \(
  6806. * \begin{bmatrix}
  6807. * X_c\\
  6808. * Y_c\\
  6809. * Z_c\\
  6810. * 1
  6811. * \end{bmatrix}
  6812. * =
  6813. * \begin{bmatrix}
  6814. * _{}^{c}\textrm{R}_t &amp; _{}^{c}\textrm{t}_t \\
  6815. * 0_{1 \times 3} &amp; 1
  6816. * \end{bmatrix}
  6817. * \begin{bmatrix}
  6818. * X_t\\
  6819. * Y_t\\
  6820. * Z_t\\
  6821. * 1
  6822. * \end{bmatrix}
  6823. * \)
  6824. * </li>
  6825. * </ul>
  6826. *
  6827. * The Hand-Eye calibration procedure returns the following homogeneous transformation
  6828. * \(
  6829. * \begin{bmatrix}
  6830. * X_g\\
  6831. * Y_g\\
  6832. * Z_g\\
  6833. * 1
  6834. * \end{bmatrix}
  6835. * =
  6836. * \begin{bmatrix}
  6837. * _{}^{g}\textrm{R}_c &amp; _{}^{g}\textrm{t}_c \\
  6838. * 0_{1 \times 3} &amp; 1
  6839. * \end{bmatrix}
  6840. * \begin{bmatrix}
  6841. * X_c\\
  6842. * Y_c\\
  6843. * Z_c\\
  6844. * 1
  6845. * \end{bmatrix}
  6846. * \)
  6847. *
  6848. * This problem is also known as solving the \(\mathbf{A}\mathbf{X}=\mathbf{X}\mathbf{B}\) equation:
  6849. * <ul>
  6850. * <li>
  6851. * for an eye-in-hand configuration
  6852. * \(
  6853. * \begin{align*}
  6854. * ^{b}{\textrm{T}_g}^{(1)} \hspace{0.2em} ^{g}\textrm{T}_c \hspace{0.2em} ^{c}{\textrm{T}_t}^{(1)} &amp;=
  6855. * \hspace{0.1em} ^{b}{\textrm{T}_g}^{(2)} \hspace{0.2em} ^{g}\textrm{T}_c \hspace{0.2em} ^{c}{\textrm{T}_t}^{(2)} \\
  6856. * </li>
  6857. * </ul>
  6858. *
  6859. * (^{b}{\textrm{T}_g}^{(2)})^{-1} \hspace{0.2em} ^{b}{\textrm{T}_g}^{(1)} \hspace{0.2em} ^{g}\textrm{T}_c &amp;=
  6860. * \hspace{0.1em} ^{g}\textrm{T}_c \hspace{0.2em} ^{c}{\textrm{T}_t}^{(2)} (^{c}{\textrm{T}_t}^{(1)})^{-1} \\
  6861. *
  6862. * \textrm{A}_i \textrm{X} &amp;= \textrm{X} \textrm{B}_i \\
  6863. * \end{align*}
  6864. * \)
  6865. *
  6866. * <ul>
  6867. * <li>
  6868. * for an eye-to-hand configuration
  6869. * \(
  6870. * \begin{align*}
  6871. * ^{g}{\textrm{T}_b}^{(1)} \hspace{0.2em} ^{b}\textrm{T}_c \hspace{0.2em} ^{c}{\textrm{T}_t}^{(1)} &amp;=
  6872. * \hspace{0.1em} ^{g}{\textrm{T}_b}^{(2)} \hspace{0.2em} ^{b}\textrm{T}_c \hspace{0.2em} ^{c}{\textrm{T}_t}^{(2)} \\
  6873. * </li>
  6874. * </ul>
  6875. *
  6876. * (^{g}{\textrm{T}_b}^{(2)})^{-1} \hspace{0.2em} ^{g}{\textrm{T}_b}^{(1)} \hspace{0.2em} ^{b}\textrm{T}_c &amp;=
  6877. * \hspace{0.1em} ^{b}\textrm{T}_c \hspace{0.2em} ^{c}{\textrm{T}_t}^{(2)} (^{c}{\textrm{T}_t}^{(1)})^{-1} \\
  6878. *
  6879. * \textrm{A}_i \textrm{X} &amp;= \textrm{X} \textrm{B}_i \\
  6880. * \end{align*}
  6881. * \)
  6882. *
  6883. * \note
  6884. * Additional information can be found on this [website](http://campar.in.tum.de/Chair/HandEyeCalibration).
  6885. * \note
  6886. * A minimum of 2 motions with non parallel rotation axes are necessary to determine the hand-eye transformation.
  6887. * So at least 3 different poses are required, but it is strongly recommended to use many more poses.
  6888. */
  6889. public static void calibrateHandEye(List<Mat> R_gripper2base, List<Mat> t_gripper2base, List<Mat> R_target2cam, List<Mat> t_target2cam, Mat R_cam2gripper, Mat t_cam2gripper, int method)
  6890. {
  6891. if (R_cam2gripper != null) R_cam2gripper.ThrowIfDisposed();
  6892. if (t_cam2gripper != null) t_cam2gripper.ThrowIfDisposed();
  6893. Mat R_gripper2base_mat = Converters.vector_Mat_to_Mat(R_gripper2base);
  6894. Mat t_gripper2base_mat = Converters.vector_Mat_to_Mat(t_gripper2base);
  6895. Mat R_target2cam_mat = Converters.vector_Mat_to_Mat(R_target2cam);
  6896. Mat t_target2cam_mat = Converters.vector_Mat_to_Mat(t_target2cam);
  6897. calib3d_Calib3d_calibrateHandEye_10(R_gripper2base_mat.nativeObj, t_gripper2base_mat.nativeObj, R_target2cam_mat.nativeObj, t_target2cam_mat.nativeObj, R_cam2gripper.nativeObj, t_cam2gripper.nativeObj, method);
  6898. }
  6899. /**
  6900. * Computes Hand-Eye calibration: \(_{}^{g}\textrm{T}_c\)
  6901. *
  6902. * param R_gripper2base Rotation part extracted from the homogeneous matrix that transforms a point
  6903. * expressed in the gripper frame to the robot base frame (\(_{}^{b}\textrm{T}_g\)).
  6904. * This is a vector ({code vector&lt;Mat&gt;}) that contains the rotation, {code (3x3)} rotation matrices or {code (3x1)} rotation vectors,
  6905. * for all the transformations from gripper frame to robot base frame.
  6906. * param t_gripper2base Translation part extracted from the homogeneous matrix that transforms a point
  6907. * expressed in the gripper frame to the robot base frame (\(_{}^{b}\textrm{T}_g\)).
  6908. * This is a vector ({code vector&lt;Mat&gt;}) that contains the {code (3x1)} translation vectors for all the transformations
  6909. * from gripper frame to robot base frame.
  6910. * param R_target2cam Rotation part extracted from the homogeneous matrix that transforms a point
  6911. * expressed in the target frame to the camera frame (\(_{}^{c}\textrm{T}_t\)).
  6912. * This is a vector ({code vector&lt;Mat&gt;}) that contains the rotation, {code (3x3)} rotation matrices or {code (3x1)} rotation vectors,
  6913. * for all the transformations from calibration target frame to camera frame.
  6914. * param t_target2cam Rotation part extracted from the homogeneous matrix that transforms a point
  6915. * expressed in the target frame to the camera frame (\(_{}^{c}\textrm{T}_t\)).
  6916. * This is a vector ({code vector&lt;Mat&gt;}) that contains the {code (3x1)} translation vectors for all the transformations
  6917. * from calibration target frame to camera frame.
  6918. * param R_cam2gripper Estimated {code (3x3)} rotation part extracted from the homogeneous matrix that transforms a point
  6919. * expressed in the camera frame to the gripper frame (\(_{}^{g}\textrm{T}_c\)).
  6920. * param t_cam2gripper Estimated {code (3x1)} translation part extracted from the homogeneous matrix that transforms a point
  6921. * expressed in the camera frame to the gripper frame (\(_{}^{g}\textrm{T}_c\)).
  6922. *
  6923. * The function performs the Hand-Eye calibration using various methods. One approach consists in estimating the
  6924. * rotation then the translation (separable solutions) and the following methods are implemented:
  6925. * <ul>
  6926. * <li>
  6927. * R. Tsai, R. Lenz A New Technique for Fully Autonomous and Efficient 3D Robotics Hand/EyeCalibration \cite Tsai89
  6928. * </li>
  6929. * <li>
  6930. * F. Park, B. Martin Robot Sensor Calibration: Solving AX = XB on the Euclidean Group \cite Park94
  6931. * </li>
  6932. * <li>
  6933. * R. Horaud, F. Dornaika Hand-Eye Calibration \cite Horaud95
  6934. * </li>
  6935. * </ul>
  6936. *
  6937. * Another approach consists in estimating simultaneously the rotation and the translation (simultaneous solutions),
  6938. * with the following implemented methods:
  6939. * <ul>
  6940. * <li>
  6941. * N. Andreff, R. Horaud, B. Espiau On-line Hand-Eye Calibration \cite Andreff99
  6942. * </li>
  6943. * <li>
  6944. * K. Daniilidis Hand-Eye Calibration Using Dual Quaternions \cite Daniilidis98
  6945. * </li>
  6946. * </ul>
  6947. *
  6948. * The following picture describes the Hand-Eye calibration problem where the transformation between a camera ("eye")
  6949. * mounted on a robot gripper ("hand") has to be estimated. This configuration is called eye-in-hand.
  6950. *
  6951. * The eye-to-hand configuration consists in a static camera observing a calibration pattern mounted on the robot
  6952. * end-effector. The transformation from the camera to the robot base frame can then be estimated by inputting
  6953. * the suitable transformations to the function, see below.
  6954. *
  6955. * ![](pics/hand-eye_figure.png)
  6956. *
  6957. * The calibration procedure is the following:
  6958. * <ul>
  6959. * <li>
  6960. * a static calibration pattern is used to estimate the transformation between the target frame
  6961. * and the camera frame
  6962. * </li>
  6963. * <li>
  6964. * the robot gripper is moved in order to acquire several poses
  6965. * </li>
  6966. * <li>
  6967. * for each pose, the homogeneous transformation between the gripper frame and the robot base frame is recorded using for
  6968. * instance the robot kinematics
  6969. * \(
  6970. * \begin{bmatrix}
  6971. * X_b\\
  6972. * Y_b\\
  6973. * Z_b\\
  6974. * 1
  6975. * \end{bmatrix}
  6976. * =
  6977. * \begin{bmatrix}
  6978. * _{}^{b}\textrm{R}_g &amp; _{}^{b}\textrm{t}_g \\
  6979. * 0_{1 \times 3} &amp; 1
  6980. * \end{bmatrix}
  6981. * \begin{bmatrix}
  6982. * X_g\\
  6983. * Y_g\\
  6984. * Z_g\\
  6985. * 1
  6986. * \end{bmatrix}
  6987. * \)
  6988. * </li>
  6989. * <li>
  6990. * for each pose, the homogeneous transformation between the calibration target frame and the camera frame is recorded using
  6991. * for instance a pose estimation method (PnP) from 2D-3D point correspondences
  6992. * \(
  6993. * \begin{bmatrix}
  6994. * X_c\\
  6995. * Y_c\\
  6996. * Z_c\\
  6997. * 1
  6998. * \end{bmatrix}
  6999. * =
  7000. * \begin{bmatrix}
  7001. * _{}^{c}\textrm{R}_t &amp; _{}^{c}\textrm{t}_t \\
  7002. * 0_{1 \times 3} &amp; 1
  7003. * \end{bmatrix}
  7004. * \begin{bmatrix}
  7005. * X_t\\
  7006. * Y_t\\
  7007. * Z_t\\
  7008. * 1
  7009. * \end{bmatrix}
  7010. * \)
  7011. * </li>
  7012. * </ul>
  7013. *
  7014. * The Hand-Eye calibration procedure returns the following homogeneous transformation
  7015. * \(
  7016. * \begin{bmatrix}
  7017. * X_g\\
  7018. * Y_g\\
  7019. * Z_g\\
  7020. * 1
  7021. * \end{bmatrix}
  7022. * =
  7023. * \begin{bmatrix}
  7024. * _{}^{g}\textrm{R}_c &amp; _{}^{g}\textrm{t}_c \\
  7025. * 0_{1 \times 3} &amp; 1
  7026. * \end{bmatrix}
  7027. * \begin{bmatrix}
  7028. * X_c\\
  7029. * Y_c\\
  7030. * Z_c\\
  7031. * 1
  7032. * \end{bmatrix}
  7033. * \)
  7034. *
  7035. * This problem is also known as solving the \(\mathbf{A}\mathbf{X}=\mathbf{X}\mathbf{B}\) equation:
  7036. * <ul>
  7037. * <li>
  7038. * for an eye-in-hand configuration
  7039. * \(
  7040. * \begin{align*}
  7041. * ^{b}{\textrm{T}_g}^{(1)} \hspace{0.2em} ^{g}\textrm{T}_c \hspace{0.2em} ^{c}{\textrm{T}_t}^{(1)} &amp;=
  7042. * \hspace{0.1em} ^{b}{\textrm{T}_g}^{(2)} \hspace{0.2em} ^{g}\textrm{T}_c \hspace{0.2em} ^{c}{\textrm{T}_t}^{(2)} \\
  7043. * </li>
  7044. * </ul>
  7045. *
  7046. * (^{b}{\textrm{T}_g}^{(2)})^{-1} \hspace{0.2em} ^{b}{\textrm{T}_g}^{(1)} \hspace{0.2em} ^{g}\textrm{T}_c &amp;=
  7047. * \hspace{0.1em} ^{g}\textrm{T}_c \hspace{0.2em} ^{c}{\textrm{T}_t}^{(2)} (^{c}{\textrm{T}_t}^{(1)})^{-1} \\
  7048. *
  7049. * \textrm{A}_i \textrm{X} &amp;= \textrm{X} \textrm{B}_i \\
  7050. * \end{align*}
  7051. * \)
  7052. *
  7053. * <ul>
  7054. * <li>
  7055. * for an eye-to-hand configuration
  7056. * \(
  7057. * \begin{align*}
  7058. * ^{g}{\textrm{T}_b}^{(1)} \hspace{0.2em} ^{b}\textrm{T}_c \hspace{0.2em} ^{c}{\textrm{T}_t}^{(1)} &amp;=
  7059. * \hspace{0.1em} ^{g}{\textrm{T}_b}^{(2)} \hspace{0.2em} ^{b}\textrm{T}_c \hspace{0.2em} ^{c}{\textrm{T}_t}^{(2)} \\
  7060. * </li>
  7061. * </ul>
  7062. *
  7063. * (^{g}{\textrm{T}_b}^{(2)})^{-1} \hspace{0.2em} ^{g}{\textrm{T}_b}^{(1)} \hspace{0.2em} ^{b}\textrm{T}_c &amp;=
  7064. * \hspace{0.1em} ^{b}\textrm{T}_c \hspace{0.2em} ^{c}{\textrm{T}_t}^{(2)} (^{c}{\textrm{T}_t}^{(1)})^{-1} \\
  7065. *
  7066. * \textrm{A}_i \textrm{X} &amp;= \textrm{X} \textrm{B}_i \\
  7067. * \end{align*}
  7068. * \)
  7069. *
  7070. * \note
  7071. * Additional information can be found on this [website](http://campar.in.tum.de/Chair/HandEyeCalibration).
  7072. * \note
  7073. * A minimum of 2 motions with non parallel rotation axes are necessary to determine the hand-eye transformation.
  7074. * So at least 3 different poses are required, but it is strongly recommended to use many more poses.
  7075. */
  7076. public static void calibrateHandEye(List<Mat> R_gripper2base, List<Mat> t_gripper2base, List<Mat> R_target2cam, List<Mat> t_target2cam, Mat R_cam2gripper, Mat t_cam2gripper)
  7077. {
  7078. if (R_cam2gripper != null) R_cam2gripper.ThrowIfDisposed();
  7079. if (t_cam2gripper != null) t_cam2gripper.ThrowIfDisposed();
  7080. Mat R_gripper2base_mat = Converters.vector_Mat_to_Mat(R_gripper2base);
  7081. Mat t_gripper2base_mat = Converters.vector_Mat_to_Mat(t_gripper2base);
  7082. Mat R_target2cam_mat = Converters.vector_Mat_to_Mat(R_target2cam);
  7083. Mat t_target2cam_mat = Converters.vector_Mat_to_Mat(t_target2cam);
  7084. calib3d_Calib3d_calibrateHandEye_11(R_gripper2base_mat.nativeObj, t_gripper2base_mat.nativeObj, R_target2cam_mat.nativeObj, t_target2cam_mat.nativeObj, R_cam2gripper.nativeObj, t_cam2gripper.nativeObj);
  7085. }
  7086. //
  7087. // C++: void cv::calibrateRobotWorldHandEye(vector_Mat R_world2cam, vector_Mat t_world2cam, vector_Mat R_base2gripper, vector_Mat t_base2gripper, Mat& R_base2world, Mat& t_base2world, Mat& R_gripper2cam, Mat& t_gripper2cam, RobotWorldHandEyeCalibrationMethod method = CALIB_ROBOT_WORLD_HAND_EYE_SHAH)
  7088. //
  7089. /**
  7090. * Computes Robot-World/Hand-Eye calibration: \(_{}^{w}\textrm{T}_b\) and \(_{}^{c}\textrm{T}_g\)
  7091. *
  7092. * param R_world2cam Rotation part extracted from the homogeneous matrix that transforms a point
  7093. * expressed in the world frame to the camera frame (\(_{}^{c}\textrm{T}_w\)).
  7094. * This is a vector ({code vector&lt;Mat&gt;}) that contains the rotation, {code (3x3)} rotation matrices or {code (3x1)} rotation vectors,
  7095. * for all the transformations from world frame to the camera frame.
  7096. * param t_world2cam Translation part extracted from the homogeneous matrix that transforms a point
  7097. * expressed in the world frame to the camera frame (\(_{}^{c}\textrm{T}_w\)).
  7098. * This is a vector ({code vector&lt;Mat&gt;}) that contains the {code (3x1)} translation vectors for all the transformations
  7099. * from world frame to the camera frame.
  7100. * param R_base2gripper Rotation part extracted from the homogeneous matrix that transforms a point
  7101. * expressed in the robot base frame to the gripper frame (\(_{}^{g}\textrm{T}_b\)).
  7102. * This is a vector ({code vector&lt;Mat&gt;}) that contains the rotation, {code (3x3)} rotation matrices or {code (3x1)} rotation vectors,
  7103. * for all the transformations from robot base frame to the gripper frame.
  7104. * param t_base2gripper Rotation part extracted from the homogeneous matrix that transforms a point
  7105. * expressed in the robot base frame to the gripper frame (\(_{}^{g}\textrm{T}_b\)).
  7106. * This is a vector ({code vector&lt;Mat&gt;}) that contains the {code (3x1)} translation vectors for all the transformations
  7107. * from robot base frame to the gripper frame.
  7108. * param R_base2world Estimated {code (3x3)} rotation part extracted from the homogeneous matrix that transforms a point
  7109. * expressed in the robot base frame to the world frame (\(_{}^{w}\textrm{T}_b\)).
  7110. * param t_base2world Estimated {code (3x1)} translation part extracted from the homogeneous matrix that transforms a point
  7111. * expressed in the robot base frame to the world frame (\(_{}^{w}\textrm{T}_b\)).
  7112. * param R_gripper2cam Estimated {code (3x3)} rotation part extracted from the homogeneous matrix that transforms a point
  7113. * expressed in the gripper frame to the camera frame (\(_{}^{c}\textrm{T}_g\)).
  7114. * param t_gripper2cam Estimated {code (3x1)} translation part extracted from the homogeneous matrix that transforms a point
  7115. * expressed in the gripper frame to the camera frame (\(_{}^{c}\textrm{T}_g\)).
  7116. * param method One of the implemented Robot-World/Hand-Eye calibration method, see cv::RobotWorldHandEyeCalibrationMethod
  7117. *
  7118. * The function performs the Robot-World/Hand-Eye calibration using various methods. One approach consists in estimating the
  7119. * rotation then the translation (separable solutions):
  7120. * <ul>
  7121. * <li>
  7122. * M. Shah, Solving the robot-world/hand-eye calibration problem using the kronecker product \cite Shah2013SolvingTR
  7123. * </li>
  7124. * </ul>
  7125. *
  7126. * Another approach consists in estimating simultaneously the rotation and the translation (simultaneous solutions),
  7127. * with the following implemented method:
  7128. * <ul>
  7129. * <li>
  7130. * A. Li, L. Wang, and D. Wu, Simultaneous robot-world and hand-eye calibration using dual-quaternions and kronecker product \cite Li2010SimultaneousRA
  7131. * </li>
  7132. * </ul>
  7133. *
  7134. * The following picture describes the Robot-World/Hand-Eye calibration problem where the transformations between a robot and a world frame
  7135. * and between a robot gripper ("hand") and a camera ("eye") mounted at the robot end-effector have to be estimated.
  7136. *
  7137. * ![](pics/robot-world_hand-eye_figure.png)
  7138. *
  7139. * The calibration procedure is the following:
  7140. * <ul>
  7141. * <li>
  7142. * a static calibration pattern is used to estimate the transformation between the target frame
  7143. * and the camera frame
  7144. * </li>
  7145. * <li>
  7146. * the robot gripper is moved in order to acquire several poses
  7147. * </li>
  7148. * <li>
  7149. * for each pose, the homogeneous transformation between the gripper frame and the robot base frame is recorded using for
  7150. * instance the robot kinematics
  7151. * \(
  7152. * \begin{bmatrix}
  7153. * X_g\\
  7154. * Y_g\\
  7155. * Z_g\\
  7156. * 1
  7157. * \end{bmatrix}
  7158. * =
  7159. * \begin{bmatrix}
  7160. * _{}^{g}\textrm{R}_b &amp; _{}^{g}\textrm{t}_b \\
  7161. * 0_{1 \times 3} &amp; 1
  7162. * \end{bmatrix}
  7163. * \begin{bmatrix}
  7164. * X_b\\
  7165. * Y_b\\
  7166. * Z_b\\
  7167. * 1
  7168. * \end{bmatrix}
  7169. * \)
  7170. * </li>
  7171. * <li>
  7172. * for each pose, the homogeneous transformation between the calibration target frame (the world frame) and the camera frame is recorded using
  7173. * for instance a pose estimation method (PnP) from 2D-3D point correspondences
  7174. * \(
  7175. * \begin{bmatrix}
  7176. * X_c\\
  7177. * Y_c\\
  7178. * Z_c\\
  7179. * 1
  7180. * \end{bmatrix}
  7181. * =
  7182. * \begin{bmatrix}
  7183. * _{}^{c}\textrm{R}_w &amp; _{}^{c}\textrm{t}_w \\
  7184. * 0_{1 \times 3} &amp; 1
  7185. * \end{bmatrix}
  7186. * \begin{bmatrix}
  7187. * X_w\\
  7188. * Y_w\\
  7189. * Z_w\\
  7190. * 1
  7191. * \end{bmatrix}
  7192. * \)
  7193. * </li>
  7194. * </ul>
  7195. *
  7196. * The Robot-World/Hand-Eye calibration procedure returns the following homogeneous transformations
  7197. * \(
  7198. * \begin{bmatrix}
  7199. * X_w\\
  7200. * Y_w\\
  7201. * Z_w\\
  7202. * 1
  7203. * \end{bmatrix}
  7204. * =
  7205. * \begin{bmatrix}
  7206. * _{}^{w}\textrm{R}_b &amp; _{}^{w}\textrm{t}_b \\
  7207. * 0_{1 \times 3} &amp; 1
  7208. * \end{bmatrix}
  7209. * \begin{bmatrix}
  7210. * X_b\\
  7211. * Y_b\\
  7212. * Z_b\\
  7213. * 1
  7214. * \end{bmatrix}
  7215. * \)
  7216. * \(
  7217. * \begin{bmatrix}
  7218. * X_c\\
  7219. * Y_c\\
  7220. * Z_c\\
  7221. * 1
  7222. * \end{bmatrix}
  7223. * =
  7224. * \begin{bmatrix}
  7225. * _{}^{c}\textrm{R}_g &amp; _{}^{c}\textrm{t}_g \\
  7226. * 0_{1 \times 3} &amp; 1
  7227. * \end{bmatrix}
  7228. * \begin{bmatrix}
  7229. * X_g\\
  7230. * Y_g\\
  7231. * Z_g\\
  7232. * 1
  7233. * \end{bmatrix}
  7234. * \)
  7235. *
  7236. * This problem is also known as solving the \(\mathbf{A}\mathbf{X}=\mathbf{Z}\mathbf{B}\) equation, with:
  7237. * <ul>
  7238. * <li>
  7239. * \(\mathbf{A} \Leftrightarrow \hspace{0.1em} _{}^{c}\textrm{T}_w\)
  7240. * </li>
  7241. * <li>
  7242. * \(\mathbf{X} \Leftrightarrow \hspace{0.1em} _{}^{w}\textrm{T}_b\)
  7243. * </li>
  7244. * <li>
  7245. * \(\mathbf{Z} \Leftrightarrow \hspace{0.1em} _{}^{c}\textrm{T}_g\)
  7246. * </li>
  7247. * <li>
  7248. * \(\mathbf{B} \Leftrightarrow \hspace{0.1em} _{}^{g}\textrm{T}_b\)
  7249. * </li>
  7250. * </ul>
  7251. *
  7252. * \note
  7253. * At least 3 measurements are required (input vectors size must be greater or equal to 3).
  7254. */
  7255. public static void calibrateRobotWorldHandEye(List<Mat> R_world2cam, List<Mat> t_world2cam, List<Mat> R_base2gripper, List<Mat> t_base2gripper, Mat R_base2world, Mat t_base2world, Mat R_gripper2cam, Mat t_gripper2cam, int method)
  7256. {
  7257. if (R_base2world != null) R_base2world.ThrowIfDisposed();
  7258. if (t_base2world != null) t_base2world.ThrowIfDisposed();
  7259. if (R_gripper2cam != null) R_gripper2cam.ThrowIfDisposed();
  7260. if (t_gripper2cam != null) t_gripper2cam.ThrowIfDisposed();
  7261. Mat R_world2cam_mat = Converters.vector_Mat_to_Mat(R_world2cam);
  7262. Mat t_world2cam_mat = Converters.vector_Mat_to_Mat(t_world2cam);
  7263. Mat R_base2gripper_mat = Converters.vector_Mat_to_Mat(R_base2gripper);
  7264. Mat t_base2gripper_mat = Converters.vector_Mat_to_Mat(t_base2gripper);
  7265. calib3d_Calib3d_calibrateRobotWorldHandEye_10(R_world2cam_mat.nativeObj, t_world2cam_mat.nativeObj, R_base2gripper_mat.nativeObj, t_base2gripper_mat.nativeObj, R_base2world.nativeObj, t_base2world.nativeObj, R_gripper2cam.nativeObj, t_gripper2cam.nativeObj, method);
  7266. }
  7267. /**
  7268. * Computes Robot-World/Hand-Eye calibration: \(_{}^{w}\textrm{T}_b\) and \(_{}^{c}\textrm{T}_g\)
  7269. *
  7270. * param R_world2cam Rotation part extracted from the homogeneous matrix that transforms a point
  7271. * expressed in the world frame to the camera frame (\(_{}^{c}\textrm{T}_w\)).
  7272. * This is a vector ({code vector&lt;Mat&gt;}) that contains the rotation, {code (3x3)} rotation matrices or {code (3x1)} rotation vectors,
  7273. * for all the transformations from world frame to the camera frame.
  7274. * param t_world2cam Translation part extracted from the homogeneous matrix that transforms a point
  7275. * expressed in the world frame to the camera frame (\(_{}^{c}\textrm{T}_w\)).
  7276. * This is a vector ({code vector&lt;Mat&gt;}) that contains the {code (3x1)} translation vectors for all the transformations
  7277. * from world frame to the camera frame.
  7278. * param R_base2gripper Rotation part extracted from the homogeneous matrix that transforms a point
  7279. * expressed in the robot base frame to the gripper frame (\(_{}^{g}\textrm{T}_b\)).
  7280. * This is a vector ({code vector&lt;Mat&gt;}) that contains the rotation, {code (3x3)} rotation matrices or {code (3x1)} rotation vectors,
  7281. * for all the transformations from robot base frame to the gripper frame.
  7282. * param t_base2gripper Rotation part extracted from the homogeneous matrix that transforms a point
  7283. * expressed in the robot base frame to the gripper frame (\(_{}^{g}\textrm{T}_b\)).
  7284. * This is a vector ({code vector&lt;Mat&gt;}) that contains the {code (3x1)} translation vectors for all the transformations
  7285. * from robot base frame to the gripper frame.
  7286. * param R_base2world Estimated {code (3x3)} rotation part extracted from the homogeneous matrix that transforms a point
  7287. * expressed in the robot base frame to the world frame (\(_{}^{w}\textrm{T}_b\)).
  7288. * param t_base2world Estimated {code (3x1)} translation part extracted from the homogeneous matrix that transforms a point
  7289. * expressed in the robot base frame to the world frame (\(_{}^{w}\textrm{T}_b\)).
  7290. * param R_gripper2cam Estimated {code (3x3)} rotation part extracted from the homogeneous matrix that transforms a point
  7291. * expressed in the gripper frame to the camera frame (\(_{}^{c}\textrm{T}_g\)).
  7292. * param t_gripper2cam Estimated {code (3x1)} translation part extracted from the homogeneous matrix that transforms a point
  7293. * expressed in the gripper frame to the camera frame (\(_{}^{c}\textrm{T}_g\)).
  7294. *
  7295. * The function performs the Robot-World/Hand-Eye calibration using various methods. One approach consists in estimating the
  7296. * rotation then the translation (separable solutions):
  7297. * <ul>
  7298. * <li>
  7299. * M. Shah, Solving the robot-world/hand-eye calibration problem using the kronecker product \cite Shah2013SolvingTR
  7300. * </li>
  7301. * </ul>
  7302. *
  7303. * Another approach consists in estimating simultaneously the rotation and the translation (simultaneous solutions),
  7304. * with the following implemented method:
  7305. * <ul>
  7306. * <li>
  7307. * A. Li, L. Wang, and D. Wu, Simultaneous robot-world and hand-eye calibration using dual-quaternions and kronecker product \cite Li2010SimultaneousRA
  7308. * </li>
  7309. * </ul>
  7310. *
  7311. * The following picture describes the Robot-World/Hand-Eye calibration problem where the transformations between a robot and a world frame
  7312. * and between a robot gripper ("hand") and a camera ("eye") mounted at the robot end-effector have to be estimated.
  7313. *
  7314. * ![](pics/robot-world_hand-eye_figure.png)
  7315. *
  7316. * The calibration procedure is the following:
  7317. * <ul>
  7318. * <li>
  7319. * a static calibration pattern is used to estimate the transformation between the target frame
  7320. * and the camera frame
  7321. * </li>
  7322. * <li>
  7323. * the robot gripper is moved in order to acquire several poses
  7324. * </li>
  7325. * <li>
  7326. * for each pose, the homogeneous transformation between the gripper frame and the robot base frame is recorded using for
  7327. * instance the robot kinematics
  7328. * \(
  7329. * \begin{bmatrix}
  7330. * X_g\\
  7331. * Y_g\\
  7332. * Z_g\\
  7333. * 1
  7334. * \end{bmatrix}
  7335. * =
  7336. * \begin{bmatrix}
  7337. * _{}^{g}\textrm{R}_b &amp; _{}^{g}\textrm{t}_b \\
  7338. * 0_{1 \times 3} &amp; 1
  7339. * \end{bmatrix}
  7340. * \begin{bmatrix}
  7341. * X_b\\
  7342. * Y_b\\
  7343. * Z_b\\
  7344. * 1
  7345. * \end{bmatrix}
  7346. * \)
  7347. * </li>
  7348. * <li>
  7349. * for each pose, the homogeneous transformation between the calibration target frame (the world frame) and the camera frame is recorded using
  7350. * for instance a pose estimation method (PnP) from 2D-3D point correspondences
  7351. * \(
  7352. * \begin{bmatrix}
  7353. * X_c\\
  7354. * Y_c\\
  7355. * Z_c\\
  7356. * 1
  7357. * \end{bmatrix}
  7358. * =
  7359. * \begin{bmatrix}
  7360. * _{}^{c}\textrm{R}_w &amp; _{}^{c}\textrm{t}_w \\
  7361. * 0_{1 \times 3} &amp; 1
  7362. * \end{bmatrix}
  7363. * \begin{bmatrix}
  7364. * X_w\\
  7365. * Y_w\\
  7366. * Z_w\\
  7367. * 1
  7368. * \end{bmatrix}
  7369. * \)
  7370. * </li>
  7371. * </ul>
  7372. *
  7373. * The Robot-World/Hand-Eye calibration procedure returns the following homogeneous transformations
  7374. * \(
  7375. * \begin{bmatrix}
  7376. * X_w\\
  7377. * Y_w\\
  7378. * Z_w\\
  7379. * 1
  7380. * \end{bmatrix}
  7381. * =
  7382. * \begin{bmatrix}
  7383. * _{}^{w}\textrm{R}_b &amp; _{}^{w}\textrm{t}_b \\
  7384. * 0_{1 \times 3} &amp; 1
  7385. * \end{bmatrix}
  7386. * \begin{bmatrix}
  7387. * X_b\\
  7388. * Y_b\\
  7389. * Z_b\\
  7390. * 1
  7391. * \end{bmatrix}
  7392. * \)
  7393. * \(
  7394. * \begin{bmatrix}
  7395. * X_c\\
  7396. * Y_c\\
  7397. * Z_c\\
  7398. * 1
  7399. * \end{bmatrix}
  7400. * =
  7401. * \begin{bmatrix}
  7402. * _{}^{c}\textrm{R}_g &amp; _{}^{c}\textrm{t}_g \\
  7403. * 0_{1 \times 3} &amp; 1
  7404. * \end{bmatrix}
  7405. * \begin{bmatrix}
  7406. * X_g\\
  7407. * Y_g\\
  7408. * Z_g\\
  7409. * 1
  7410. * \end{bmatrix}
  7411. * \)
  7412. *
  7413. * This problem is also known as solving the \(\mathbf{A}\mathbf{X}=\mathbf{Z}\mathbf{B}\) equation, with:
  7414. * <ul>
  7415. * <li>
  7416. * \(\mathbf{A} \Leftrightarrow \hspace{0.1em} _{}^{c}\textrm{T}_w\)
  7417. * </li>
  7418. * <li>
  7419. * \(\mathbf{X} \Leftrightarrow \hspace{0.1em} _{}^{w}\textrm{T}_b\)
  7420. * </li>
  7421. * <li>
  7422. * \(\mathbf{Z} \Leftrightarrow \hspace{0.1em} _{}^{c}\textrm{T}_g\)
  7423. * </li>
  7424. * <li>
  7425. * \(\mathbf{B} \Leftrightarrow \hspace{0.1em} _{}^{g}\textrm{T}_b\)
  7426. * </li>
  7427. * </ul>
  7428. *
  7429. * \note
  7430. * At least 3 measurements are required (input vectors size must be greater or equal to 3).
  7431. */
  7432. public static void calibrateRobotWorldHandEye(List<Mat> R_world2cam, List<Mat> t_world2cam, List<Mat> R_base2gripper, List<Mat> t_base2gripper, Mat R_base2world, Mat t_base2world, Mat R_gripper2cam, Mat t_gripper2cam)
  7433. {
  7434. if (R_base2world != null) R_base2world.ThrowIfDisposed();
  7435. if (t_base2world != null) t_base2world.ThrowIfDisposed();
  7436. if (R_gripper2cam != null) R_gripper2cam.ThrowIfDisposed();
  7437. if (t_gripper2cam != null) t_gripper2cam.ThrowIfDisposed();
  7438. Mat R_world2cam_mat = Converters.vector_Mat_to_Mat(R_world2cam);
  7439. Mat t_world2cam_mat = Converters.vector_Mat_to_Mat(t_world2cam);
  7440. Mat R_base2gripper_mat = Converters.vector_Mat_to_Mat(R_base2gripper);
  7441. Mat t_base2gripper_mat = Converters.vector_Mat_to_Mat(t_base2gripper);
  7442. calib3d_Calib3d_calibrateRobotWorldHandEye_11(R_world2cam_mat.nativeObj, t_world2cam_mat.nativeObj, R_base2gripper_mat.nativeObj, t_base2gripper_mat.nativeObj, R_base2world.nativeObj, t_base2world.nativeObj, R_gripper2cam.nativeObj, t_gripper2cam.nativeObj);
  7443. }
  7444. //
  7445. // C++: void cv::convertPointsToHomogeneous(Mat src, Mat& dst)
  7446. //
  7447. /**
  7448. * Converts points from Euclidean to homogeneous space.
  7449. *
  7450. * param src Input vector of N-dimensional points.
  7451. * param dst Output vector of N+1-dimensional points.
  7452. *
  7453. * The function converts points from Euclidean to homogeneous space by appending 1's to the tuple of
  7454. * point coordinates. That is, each point (x1, x2, ..., xn) is converted to (x1, x2, ..., xn, 1).
  7455. */
  7456. public static void convertPointsToHomogeneous(Mat src, Mat dst)
  7457. {
  7458. if (src != null) src.ThrowIfDisposed();
  7459. if (dst != null) dst.ThrowIfDisposed();
  7460. calib3d_Calib3d_convertPointsToHomogeneous_10(src.nativeObj, dst.nativeObj);
  7461. }
  7462. //
  7463. // C++: void cv::convertPointsFromHomogeneous(Mat src, Mat& dst)
  7464. //
  7465. /**
  7466. * Converts points from homogeneous to Euclidean space.
  7467. *
  7468. * param src Input vector of N-dimensional points.
  7469. * param dst Output vector of N-1-dimensional points.
  7470. *
  7471. * The function converts points homogeneous to Euclidean space using perspective projection. That is,
  7472. * each point (x1, x2, ... x(n-1), xn) is converted to (x1/xn, x2/xn, ..., x(n-1)/xn). When xn=0, the
  7473. * output point coordinates will be (0,0,0,...).
  7474. */
  7475. public static void convertPointsFromHomogeneous(Mat src, Mat dst)
  7476. {
  7477. if (src != null) src.ThrowIfDisposed();
  7478. if (dst != null) dst.ThrowIfDisposed();
  7479. calib3d_Calib3d_convertPointsFromHomogeneous_10(src.nativeObj, dst.nativeObj);
  7480. }
  7481. //
  7482. // C++: Mat cv::findFundamentalMat(vector_Point2f points1, vector_Point2f points2, int method, double ransacReprojThreshold, double confidence, int maxIters, Mat& mask = Mat())
  7483. //
  7484. /**
  7485. * Calculates a fundamental matrix from the corresponding points in two images.
  7486. *
  7487. * param points1 Array of N points from the first image. The point coordinates should be
  7488. * floating-point (single or double precision).
  7489. * param points2 Array of the second image points of the same size and format as points1 .
  7490. * param method Method for computing a fundamental matrix.
  7491. * <ul>
  7492. * <li>
  7493. * REF: FM_7POINT for a 7-point algorithm. \(N = 7\)
  7494. * </li>
  7495. * <li>
  7496. * REF: FM_8POINT for an 8-point algorithm. \(N \ge 8\)
  7497. * </li>
  7498. * <li>
  7499. * REF: FM_RANSAC for the RANSAC algorithm. \(N \ge 8\)
  7500. * </li>
  7501. * <li>
  7502. * REF: FM_LMEDS for the LMedS algorithm. \(N \ge 8\)
  7503. * </li>
  7504. * </ul>
  7505. * param ransacReprojThreshold Parameter used only for RANSAC. It is the maximum distance from a point to an epipolar
  7506. * line in pixels, beyond which the point is considered an outlier and is not used for computing the
  7507. * final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
  7508. * point localization, image resolution, and the image noise.
  7509. * param confidence Parameter used for the RANSAC and LMedS methods only. It specifies a desirable level
  7510. * of confidence (probability) that the estimated matrix is correct.
  7511. * param mask optional output mask
  7512. * param maxIters The maximum number of robust method iterations.
  7513. *
  7514. * The epipolar geometry is described by the following equation:
  7515. *
  7516. * \([p_2; 1]^T F [p_1; 1] = 0\)
  7517. *
  7518. * where \(F\) is a fundamental matrix, \(p_1\) and \(p_2\) are corresponding points in the first and the
  7519. * second images, respectively.
  7520. *
  7521. * The function calculates the fundamental matrix using one of four methods listed above and returns
  7522. * the found fundamental matrix. Normally just one matrix is found. But in case of the 7-point
  7523. * algorithm, the function may return up to 3 solutions ( \(9 \times 3\) matrix that stores all 3
  7524. * matrices sequentially).
  7525. *
  7526. * The calculated fundamental matrix may be passed further to #computeCorrespondEpilines that finds the
  7527. * epipolar lines corresponding to the specified points. It can also be passed to
  7528. * #stereoRectifyUncalibrated to compute the rectification transformation. :
  7529. * <code>
  7530. * // Example. Estimation of fundamental matrix using the RANSAC algorithm
  7531. * int point_count = 100;
  7532. * vector&lt;Point2f&gt; points1(point_count);
  7533. * vector&lt;Point2f&gt; points2(point_count);
  7534. *
  7535. * // initialize the points here ...
  7536. * for( int i = 0; i &lt; point_count; i++ )
  7537. * {
  7538. * points1[i] = ...;
  7539. * points2[i] = ...;
  7540. * }
  7541. *
  7542. * Mat fundamental_matrix =
  7543. * findFundamentalMat(points1, points2, FM_RANSAC, 3, 0.99);
  7544. * </code>
  7545. * return automatically generated
  7546. */
  7547. public static Mat findFundamentalMat(MatOfPoint2f points1, MatOfPoint2f points2, int method, double ransacReprojThreshold, double confidence, int maxIters, Mat mask)
  7548. {
  7549. if (points1 != null) points1.ThrowIfDisposed();
  7550. if (points2 != null) points2.ThrowIfDisposed();
  7551. if (mask != null) mask.ThrowIfDisposed();
  7552. Mat points1_mat = points1;
  7553. Mat points2_mat = points2;
  7554. return new Mat(DisposableObject.ThrowIfNullIntPtr(calib3d_Calib3d_findFundamentalMat_10(points1_mat.nativeObj, points2_mat.nativeObj, method, ransacReprojThreshold, confidence, maxIters, mask.nativeObj)));
  7555. }
  7556. /**
  7557. * Calculates a fundamental matrix from the corresponding points in two images.
  7558. *
  7559. * param points1 Array of N points from the first image. The point coordinates should be
  7560. * floating-point (single or double precision).
  7561. * param points2 Array of the second image points of the same size and format as points1 .
  7562. * param method Method for computing a fundamental matrix.
  7563. * <ul>
  7564. * <li>
  7565. * REF: FM_7POINT for a 7-point algorithm. \(N = 7\)
  7566. * </li>
  7567. * <li>
  7568. * REF: FM_8POINT for an 8-point algorithm. \(N \ge 8\)
  7569. * </li>
  7570. * <li>
  7571. * REF: FM_RANSAC for the RANSAC algorithm. \(N \ge 8\)
  7572. * </li>
  7573. * <li>
  7574. * REF: FM_LMEDS for the LMedS algorithm. \(N \ge 8\)
  7575. * </li>
  7576. * </ul>
  7577. * param ransacReprojThreshold Parameter used only for RANSAC. It is the maximum distance from a point to an epipolar
  7578. * line in pixels, beyond which the point is considered an outlier and is not used for computing the
  7579. * final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
  7580. * point localization, image resolution, and the image noise.
  7581. * param confidence Parameter used for the RANSAC and LMedS methods only. It specifies a desirable level
  7582. * of confidence (probability) that the estimated matrix is correct.
  7583. * param maxIters The maximum number of robust method iterations.
  7584. *
  7585. * The epipolar geometry is described by the following equation:
  7586. *
  7587. * \([p_2; 1]^T F [p_1; 1] = 0\)
  7588. *
  7589. * where \(F\) is a fundamental matrix, \(p_1\) and \(p_2\) are corresponding points in the first and the
  7590. * second images, respectively.
  7591. *
  7592. * The function calculates the fundamental matrix using one of four methods listed above and returns
  7593. * the found fundamental matrix. Normally just one matrix is found. But in case of the 7-point
  7594. * algorithm, the function may return up to 3 solutions ( \(9 \times 3\) matrix that stores all 3
  7595. * matrices sequentially).
  7596. *
  7597. * The calculated fundamental matrix may be passed further to #computeCorrespondEpilines that finds the
  7598. * epipolar lines corresponding to the specified points. It can also be passed to
  7599. * #stereoRectifyUncalibrated to compute the rectification transformation. :
  7600. * <code>
  7601. * // Example. Estimation of fundamental matrix using the RANSAC algorithm
  7602. * int point_count = 100;
  7603. * vector&lt;Point2f&gt; points1(point_count);
  7604. * vector&lt;Point2f&gt; points2(point_count);
  7605. *
  7606. * // initialize the points here ...
  7607. * for( int i = 0; i &lt; point_count; i++ )
  7608. * {
  7609. * points1[i] = ...;
  7610. * points2[i] = ...;
  7611. * }
  7612. *
  7613. * Mat fundamental_matrix =
  7614. * findFundamentalMat(points1, points2, FM_RANSAC, 3, 0.99);
  7615. * </code>
  7616. * return automatically generated
  7617. */
  7618. public static Mat findFundamentalMat(MatOfPoint2f points1, MatOfPoint2f points2, int method, double ransacReprojThreshold, double confidence, int maxIters)
  7619. {
  7620. if (points1 != null) points1.ThrowIfDisposed();
  7621. if (points2 != null) points2.ThrowIfDisposed();
  7622. Mat points1_mat = points1;
  7623. Mat points2_mat = points2;
  7624. return new Mat(DisposableObject.ThrowIfNullIntPtr(calib3d_Calib3d_findFundamentalMat_11(points1_mat.nativeObj, points2_mat.nativeObj, method, ransacReprojThreshold, confidence, maxIters)));
  7625. }
  7626. //
  7627. // C++: Mat cv::findFundamentalMat(vector_Point2f points1, vector_Point2f points2, int method = FM_RANSAC, double ransacReprojThreshold = 3., double confidence = 0.99, Mat& mask = Mat())
  7628. //
  7629. public static Mat findFundamentalMat(MatOfPoint2f points1, MatOfPoint2f points2, int method, double ransacReprojThreshold, double confidence, Mat mask)
  7630. {
  7631. if (points1 != null) points1.ThrowIfDisposed();
  7632. if (points2 != null) points2.ThrowIfDisposed();
  7633. if (mask != null) mask.ThrowIfDisposed();
  7634. Mat points1_mat = points1;
  7635. Mat points2_mat = points2;
  7636. return new Mat(DisposableObject.ThrowIfNullIntPtr(calib3d_Calib3d_findFundamentalMat_12(points1_mat.nativeObj, points2_mat.nativeObj, method, ransacReprojThreshold, confidence, mask.nativeObj)));
  7637. }
  7638. public static Mat findFundamentalMat(MatOfPoint2f points1, MatOfPoint2f points2, int method, double ransacReprojThreshold, double confidence)
  7639. {
  7640. if (points1 != null) points1.ThrowIfDisposed();
  7641. if (points2 != null) points2.ThrowIfDisposed();
  7642. Mat points1_mat = points1;
  7643. Mat points2_mat = points2;
  7644. return new Mat(DisposableObject.ThrowIfNullIntPtr(calib3d_Calib3d_findFundamentalMat_13(points1_mat.nativeObj, points2_mat.nativeObj, method, ransacReprojThreshold, confidence)));
  7645. }
  7646. public static Mat findFundamentalMat(MatOfPoint2f points1, MatOfPoint2f points2, int method, double ransacReprojThreshold)
  7647. {
  7648. if (points1 != null) points1.ThrowIfDisposed();
  7649. if (points2 != null) points2.ThrowIfDisposed();
  7650. Mat points1_mat = points1;
  7651. Mat points2_mat = points2;
  7652. return new Mat(DisposableObject.ThrowIfNullIntPtr(calib3d_Calib3d_findFundamentalMat_14(points1_mat.nativeObj, points2_mat.nativeObj, method, ransacReprojThreshold)));
  7653. }
  7654. public static Mat findFundamentalMat(MatOfPoint2f points1, MatOfPoint2f points2, int method)
  7655. {
  7656. if (points1 != null) points1.ThrowIfDisposed();
  7657. if (points2 != null) points2.ThrowIfDisposed();
  7658. Mat points1_mat = points1;
  7659. Mat points2_mat = points2;
  7660. return new Mat(DisposableObject.ThrowIfNullIntPtr(calib3d_Calib3d_findFundamentalMat_15(points1_mat.nativeObj, points2_mat.nativeObj, method)));
  7661. }
  7662. public static Mat findFundamentalMat(MatOfPoint2f points1, MatOfPoint2f points2)
  7663. {
  7664. if (points1 != null) points1.ThrowIfDisposed();
  7665. if (points2 != null) points2.ThrowIfDisposed();
  7666. Mat points1_mat = points1;
  7667. Mat points2_mat = points2;
  7668. return new Mat(DisposableObject.ThrowIfNullIntPtr(calib3d_Calib3d_findFundamentalMat_16(points1_mat.nativeObj, points2_mat.nativeObj)));
  7669. }
  7670. //
  7671. // C++: Mat cv::findFundamentalMat(vector_Point2f points1, vector_Point2f points2, Mat& mask, UsacParams _params)
  7672. //
  7673. public static Mat findFundamentalMat(MatOfPoint2f points1, MatOfPoint2f points2, Mat mask, UsacParams _params)
  7674. {
  7675. if (points1 != null) points1.ThrowIfDisposed();
  7676. if (points2 != null) points2.ThrowIfDisposed();
  7677. if (mask != null) mask.ThrowIfDisposed();
  7678. if (_params != null) _params.ThrowIfDisposed();
  7679. Mat points1_mat = points1;
  7680. Mat points2_mat = points2;
  7681. return new Mat(DisposableObject.ThrowIfNullIntPtr(calib3d_Calib3d_findFundamentalMat_17(points1_mat.nativeObj, points2_mat.nativeObj, mask.nativeObj, _params.nativeObj)));
  7682. }
  7683. //
  7684. // C++: Mat cv::findEssentialMat(Mat points1, Mat points2, Mat cameraMatrix, int method = RANSAC, double prob = 0.999, double threshold = 1.0, int maxIters = 1000, Mat& mask = Mat())
  7685. //
  7686. /**
  7687. * Calculates an essential matrix from the corresponding points in two images.
  7688. *
  7689. * param points1 Array of N (N &gt;= 5) 2D points from the first image. The point coordinates should
  7690. * be floating-point (single or double precision).
  7691. * param points2 Array of the second image points of the same size and format as points1 .
  7692. * param cameraMatrix Camera intrinsic matrix \(\cameramatrix{A}\) .
  7693. * Note that this function assumes that points1 and points2 are feature points from cameras with the
  7694. * same camera intrinsic matrix. If this assumption does not hold for your use case, use
  7695. * #undistortPoints with {code P = cv::NoArray()} for both cameras to transform image points
  7696. * to normalized image coordinates, which are valid for the identity camera intrinsic matrix. When
  7697. * passing these coordinates, pass the identity matrix for this parameter.
  7698. * param method Method for computing an essential matrix.
  7699. * <ul>
  7700. * <li>
  7701. * REF: RANSAC for the RANSAC algorithm.
  7702. * </li>
  7703. * <li>
  7704. * REF: LMEDS for the LMedS algorithm.
  7705. * </li>
  7706. * </ul>
  7707. * param prob Parameter used for the RANSAC or LMedS methods only. It specifies a desirable level of
  7708. * confidence (probability) that the estimated matrix is correct.
  7709. * param threshold Parameter used for RANSAC. It is the maximum distance from a point to an epipolar
  7710. * line in pixels, beyond which the point is considered an outlier and is not used for computing the
  7711. * final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
  7712. * point localization, image resolution, and the image noise.
  7713. * param mask Output array of N elements, every element of which is set to 0 for outliers and to 1
  7714. * for the other points. The array is computed only in the RANSAC and LMedS methods.
  7715. * param maxIters The maximum number of robust method iterations.
  7716. *
  7717. * This function estimates essential matrix based on the five-point algorithm solver in CITE: Nister03 .
  7718. * CITE: SteweniusCFS is also a related. The epipolar geometry is described by the following equation:
  7719. *
  7720. * \([p_2; 1]^T K^{-T} E K^{-1} [p_1; 1] = 0\)
  7721. *
  7722. * where \(E\) is an essential matrix, \(p_1\) and \(p_2\) are corresponding points in the first and the
  7723. * second images, respectively. The result of this function may be passed further to
  7724. * #decomposeEssentialMat or #recoverPose to recover the relative pose between cameras.
  7725. * return automatically generated
  7726. */
  7727. public static Mat findEssentialMat(Mat points1, Mat points2, Mat cameraMatrix, int method, double prob, double threshold, int maxIters, Mat mask)
  7728. {
  7729. if (points1 != null) points1.ThrowIfDisposed();
  7730. if (points2 != null) points2.ThrowIfDisposed();
  7731. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  7732. if (mask != null) mask.ThrowIfDisposed();
  7733. return new Mat(DisposableObject.ThrowIfNullIntPtr(calib3d_Calib3d_findEssentialMat_10(points1.nativeObj, points2.nativeObj, cameraMatrix.nativeObj, method, prob, threshold, maxIters, mask.nativeObj)));
  7734. }
  7735. /**
  7736. * Calculates an essential matrix from the corresponding points in two images.
  7737. *
  7738. * param points1 Array of N (N &gt;= 5) 2D points from the first image. The point coordinates should
  7739. * be floating-point (single or double precision).
  7740. * param points2 Array of the second image points of the same size and format as points1 .
  7741. * param cameraMatrix Camera intrinsic matrix \(\cameramatrix{A}\) .
  7742. * Note that this function assumes that points1 and points2 are feature points from cameras with the
  7743. * same camera intrinsic matrix. If this assumption does not hold for your use case, use
  7744. * #undistortPoints with {code P = cv::NoArray()} for both cameras to transform image points
  7745. * to normalized image coordinates, which are valid for the identity camera intrinsic matrix. When
  7746. * passing these coordinates, pass the identity matrix for this parameter.
  7747. * param method Method for computing an essential matrix.
  7748. * <ul>
  7749. * <li>
  7750. * REF: RANSAC for the RANSAC algorithm.
  7751. * </li>
  7752. * <li>
  7753. * REF: LMEDS for the LMedS algorithm.
  7754. * </li>
  7755. * </ul>
  7756. * param prob Parameter used for the RANSAC or LMedS methods only. It specifies a desirable level of
  7757. * confidence (probability) that the estimated matrix is correct.
  7758. * param threshold Parameter used for RANSAC. It is the maximum distance from a point to an epipolar
  7759. * line in pixels, beyond which the point is considered an outlier and is not used for computing the
  7760. * final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
  7761. * point localization, image resolution, and the image noise.
  7762. * for the other points. The array is computed only in the RANSAC and LMedS methods.
  7763. * param maxIters The maximum number of robust method iterations.
  7764. *
  7765. * This function estimates essential matrix based on the five-point algorithm solver in CITE: Nister03 .
  7766. * CITE: SteweniusCFS is also a related. The epipolar geometry is described by the following equation:
  7767. *
  7768. * \([p_2; 1]^T K^{-T} E K^{-1} [p_1; 1] = 0\)
  7769. *
  7770. * where \(E\) is an essential matrix, \(p_1\) and \(p_2\) are corresponding points in the first and the
  7771. * second images, respectively. The result of this function may be passed further to
  7772. * #decomposeEssentialMat or #recoverPose to recover the relative pose between cameras.
  7773. * return automatically generated
  7774. */
  7775. public static Mat findEssentialMat(Mat points1, Mat points2, Mat cameraMatrix, int method, double prob, double threshold, int maxIters)
  7776. {
  7777. if (points1 != null) points1.ThrowIfDisposed();
  7778. if (points2 != null) points2.ThrowIfDisposed();
  7779. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  7780. return new Mat(DisposableObject.ThrowIfNullIntPtr(calib3d_Calib3d_findEssentialMat_11(points1.nativeObj, points2.nativeObj, cameraMatrix.nativeObj, method, prob, threshold, maxIters)));
  7781. }
  7782. /**
  7783. * Calculates an essential matrix from the corresponding points in two images.
  7784. *
  7785. * param points1 Array of N (N &gt;= 5) 2D points from the first image. The point coordinates should
  7786. * be floating-point (single or double precision).
  7787. * param points2 Array of the second image points of the same size and format as points1 .
  7788. * param cameraMatrix Camera intrinsic matrix \(\cameramatrix{A}\) .
  7789. * Note that this function assumes that points1 and points2 are feature points from cameras with the
  7790. * same camera intrinsic matrix. If this assumption does not hold for your use case, use
  7791. * #undistortPoints with {code P = cv::NoArray()} for both cameras to transform image points
  7792. * to normalized image coordinates, which are valid for the identity camera intrinsic matrix. When
  7793. * passing these coordinates, pass the identity matrix for this parameter.
  7794. * param method Method for computing an essential matrix.
  7795. * <ul>
  7796. * <li>
  7797. * REF: RANSAC for the RANSAC algorithm.
  7798. * </li>
  7799. * <li>
  7800. * REF: LMEDS for the LMedS algorithm.
  7801. * </li>
  7802. * </ul>
  7803. * param prob Parameter used for the RANSAC or LMedS methods only. It specifies a desirable level of
  7804. * confidence (probability) that the estimated matrix is correct.
  7805. * param threshold Parameter used for RANSAC. It is the maximum distance from a point to an epipolar
  7806. * line in pixels, beyond which the point is considered an outlier and is not used for computing the
  7807. * final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
  7808. * point localization, image resolution, and the image noise.
  7809. * for the other points. The array is computed only in the RANSAC and LMedS methods.
  7810. *
  7811. * This function estimates essential matrix based on the five-point algorithm solver in CITE: Nister03 .
  7812. * CITE: SteweniusCFS is also a related. The epipolar geometry is described by the following equation:
  7813. *
  7814. * \([p_2; 1]^T K^{-T} E K^{-1} [p_1; 1] = 0\)
  7815. *
  7816. * where \(E\) is an essential matrix, \(p_1\) and \(p_2\) are corresponding points in the first and the
  7817. * second images, respectively. The result of this function may be passed further to
  7818. * #decomposeEssentialMat or #recoverPose to recover the relative pose between cameras.
  7819. * return automatically generated
  7820. */
  7821. public static Mat findEssentialMat(Mat points1, Mat points2, Mat cameraMatrix, int method, double prob, double threshold)
  7822. {
  7823. if (points1 != null) points1.ThrowIfDisposed();
  7824. if (points2 != null) points2.ThrowIfDisposed();
  7825. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  7826. return new Mat(DisposableObject.ThrowIfNullIntPtr(calib3d_Calib3d_findEssentialMat_12(points1.nativeObj, points2.nativeObj, cameraMatrix.nativeObj, method, prob, threshold)));
  7827. }
  7828. /**
  7829. * Calculates an essential matrix from the corresponding points in two images.
  7830. *
  7831. * param points1 Array of N (N &gt;= 5) 2D points from the first image. The point coordinates should
  7832. * be floating-point (single or double precision).
  7833. * param points2 Array of the second image points of the same size and format as points1 .
  7834. * param cameraMatrix Camera intrinsic matrix \(\cameramatrix{A}\) .
  7835. * Note that this function assumes that points1 and points2 are feature points from cameras with the
  7836. * same camera intrinsic matrix. If this assumption does not hold for your use case, use
  7837. * #undistortPoints with {code P = cv::NoArray()} for both cameras to transform image points
  7838. * to normalized image coordinates, which are valid for the identity camera intrinsic matrix. When
  7839. * passing these coordinates, pass the identity matrix for this parameter.
  7840. * param method Method for computing an essential matrix.
  7841. * <ul>
  7842. * <li>
  7843. * REF: RANSAC for the RANSAC algorithm.
  7844. * </li>
  7845. * <li>
  7846. * REF: LMEDS for the LMedS algorithm.
  7847. * </li>
  7848. * </ul>
  7849. * param prob Parameter used for the RANSAC or LMedS methods only. It specifies a desirable level of
  7850. * confidence (probability) that the estimated matrix is correct.
  7851. * line in pixels, beyond which the point is considered an outlier and is not used for computing the
  7852. * final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
  7853. * point localization, image resolution, and the image noise.
  7854. * for the other points. The array is computed only in the RANSAC and LMedS methods.
  7855. *
  7856. * This function estimates essential matrix based on the five-point algorithm solver in CITE: Nister03 .
  7857. * CITE: SteweniusCFS is also a related. The epipolar geometry is described by the following equation:
  7858. *
  7859. * \([p_2; 1]^T K^{-T} E K^{-1} [p_1; 1] = 0\)
  7860. *
  7861. * where \(E\) is an essential matrix, \(p_1\) and \(p_2\) are corresponding points in the first and the
  7862. * second images, respectively. The result of this function may be passed further to
  7863. * #decomposeEssentialMat or #recoverPose to recover the relative pose between cameras.
  7864. * return automatically generated
  7865. */
  7866. public static Mat findEssentialMat(Mat points1, Mat points2, Mat cameraMatrix, int method, double prob)
  7867. {
  7868. if (points1 != null) points1.ThrowIfDisposed();
  7869. if (points2 != null) points2.ThrowIfDisposed();
  7870. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  7871. return new Mat(DisposableObject.ThrowIfNullIntPtr(calib3d_Calib3d_findEssentialMat_13(points1.nativeObj, points2.nativeObj, cameraMatrix.nativeObj, method, prob)));
  7872. }
  7873. /**
  7874. * Calculates an essential matrix from the corresponding points in two images.
  7875. *
  7876. * param points1 Array of N (N &gt;= 5) 2D points from the first image. The point coordinates should
  7877. * be floating-point (single or double precision).
  7878. * param points2 Array of the second image points of the same size and format as points1 .
  7879. * param cameraMatrix Camera intrinsic matrix \(\cameramatrix{A}\) .
  7880. * Note that this function assumes that points1 and points2 are feature points from cameras with the
  7881. * same camera intrinsic matrix. If this assumption does not hold for your use case, use
  7882. * #undistortPoints with {code P = cv::NoArray()} for both cameras to transform image points
  7883. * to normalized image coordinates, which are valid for the identity camera intrinsic matrix. When
  7884. * passing these coordinates, pass the identity matrix for this parameter.
  7885. * param method Method for computing an essential matrix.
  7886. * <ul>
  7887. * <li>
  7888. * REF: RANSAC for the RANSAC algorithm.
  7889. * </li>
  7890. * <li>
  7891. * REF: LMEDS for the LMedS algorithm.
  7892. * </li>
  7893. * </ul>
  7894. * confidence (probability) that the estimated matrix is correct.
  7895. * line in pixels, beyond which the point is considered an outlier and is not used for computing the
  7896. * final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
  7897. * point localization, image resolution, and the image noise.
  7898. * for the other points. The array is computed only in the RANSAC and LMedS methods.
  7899. *
  7900. * This function estimates essential matrix based on the five-point algorithm solver in CITE: Nister03 .
  7901. * CITE: SteweniusCFS is also a related. The epipolar geometry is described by the following equation:
  7902. *
  7903. * \([p_2; 1]^T K^{-T} E K^{-1} [p_1; 1] = 0\)
  7904. *
  7905. * where \(E\) is an essential matrix, \(p_1\) and \(p_2\) are corresponding points in the first and the
  7906. * second images, respectively. The result of this function may be passed further to
  7907. * #decomposeEssentialMat or #recoverPose to recover the relative pose between cameras.
  7908. * return automatically generated
  7909. */
  7910. public static Mat findEssentialMat(Mat points1, Mat points2, Mat cameraMatrix, int method)
  7911. {
  7912. if (points1 != null) points1.ThrowIfDisposed();
  7913. if (points2 != null) points2.ThrowIfDisposed();
  7914. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  7915. return new Mat(DisposableObject.ThrowIfNullIntPtr(calib3d_Calib3d_findEssentialMat_14(points1.nativeObj, points2.nativeObj, cameraMatrix.nativeObj, method)));
  7916. }
  7917. /**
  7918. * Calculates an essential matrix from the corresponding points in two images.
  7919. *
  7920. * param points1 Array of N (N &gt;= 5) 2D points from the first image. The point coordinates should
  7921. * be floating-point (single or double precision).
  7922. * param points2 Array of the second image points of the same size and format as points1 .
  7923. * param cameraMatrix Camera intrinsic matrix \(\cameramatrix{A}\) .
  7924. * Note that this function assumes that points1 and points2 are feature points from cameras with the
  7925. * same camera intrinsic matrix. If this assumption does not hold for your use case, use
  7926. * #undistortPoints with {code P = cv::NoArray()} for both cameras to transform image points
  7927. * to normalized image coordinates, which are valid for the identity camera intrinsic matrix. When
  7928. * passing these coordinates, pass the identity matrix for this parameter.
  7929. * <ul>
  7930. * <li>
  7931. * REF: RANSAC for the RANSAC algorithm.
  7932. * </li>
  7933. * <li>
  7934. * REF: LMEDS for the LMedS algorithm.
  7935. * </li>
  7936. * </ul>
  7937. * confidence (probability) that the estimated matrix is correct.
  7938. * line in pixels, beyond which the point is considered an outlier and is not used for computing the
  7939. * final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
  7940. * point localization, image resolution, and the image noise.
  7941. * for the other points. The array is computed only in the RANSAC and LMedS methods.
  7942. *
  7943. * This function estimates essential matrix based on the five-point algorithm solver in CITE: Nister03 .
  7944. * CITE: SteweniusCFS is also a related. The epipolar geometry is described by the following equation:
  7945. *
  7946. * \([p_2; 1]^T K^{-T} E K^{-1} [p_1; 1] = 0\)
  7947. *
  7948. * where \(E\) is an essential matrix, \(p_1\) and \(p_2\) are corresponding points in the first and the
  7949. * second images, respectively. The result of this function may be passed further to
  7950. * #decomposeEssentialMat or #recoverPose to recover the relative pose between cameras.
  7951. * return automatically generated
  7952. */
  7953. public static Mat findEssentialMat(Mat points1, Mat points2, Mat cameraMatrix)
  7954. {
  7955. if (points1 != null) points1.ThrowIfDisposed();
  7956. if (points2 != null) points2.ThrowIfDisposed();
  7957. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  7958. return new Mat(DisposableObject.ThrowIfNullIntPtr(calib3d_Calib3d_findEssentialMat_15(points1.nativeObj, points2.nativeObj, cameraMatrix.nativeObj)));
  7959. }
  7960. //
  7961. // C++: Mat cv::findEssentialMat(Mat points1, Mat points2, double focal = 1.0, Point2d pp = Point2d(0, 0), int method = RANSAC, double prob = 0.999, double threshold = 1.0, int maxIters = 1000, Mat& mask = Mat())
  7962. //
  7963. /**
  7964. *
  7965. * param points1 Array of N (N &gt;= 5) 2D points from the first image. The point coordinates should
  7966. * be floating-point (single or double precision).
  7967. * param points2 Array of the second image points of the same size and format as points1 .
  7968. * param focal focal length of the camera. Note that this function assumes that points1 and points2
  7969. * are feature points from cameras with same focal length and principal point.
  7970. * param pp principal point of the camera.
  7971. * param method Method for computing a fundamental matrix.
  7972. * <ul>
  7973. * <li>
  7974. * REF: RANSAC for the RANSAC algorithm.
  7975. * </li>
  7976. * <li>
  7977. * REF: LMEDS for the LMedS algorithm.
  7978. * </li>
  7979. * </ul>
  7980. * param threshold Parameter used for RANSAC. It is the maximum distance from a point to an epipolar
  7981. * line in pixels, beyond which the point is considered an outlier and is not used for computing the
  7982. * final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
  7983. * point localization, image resolution, and the image noise.
  7984. * param prob Parameter used for the RANSAC or LMedS methods only. It specifies a desirable level of
  7985. * confidence (probability) that the estimated matrix is correct.
  7986. * param mask Output array of N elements, every element of which is set to 0 for outliers and to 1
  7987. * for the other points. The array is computed only in the RANSAC and LMedS methods.
  7988. * param maxIters The maximum number of robust method iterations.
  7989. *
  7990. * This function differs from the one above that it computes camera intrinsic matrix from focal length and
  7991. * principal point:
  7992. *
  7993. * \(A =
  7994. * \begin{bmatrix}
  7995. * f &amp; 0 &amp; x_{pp} \\
  7996. * 0 &amp; f &amp; y_{pp} \\
  7997. * 0 &amp; 0 &amp; 1
  7998. * \end{bmatrix}\)
  7999. * return automatically generated
  8000. */
  8001. public static Mat findEssentialMat(Mat points1, Mat points2, double focal, Point pp, int method, double prob, double threshold, int maxIters, Mat mask)
  8002. {
  8003. if (points1 != null) points1.ThrowIfDisposed();
  8004. if (points2 != null) points2.ThrowIfDisposed();
  8005. if (mask != null) mask.ThrowIfDisposed();
  8006. return new Mat(DisposableObject.ThrowIfNullIntPtr(calib3d_Calib3d_findEssentialMat_16(points1.nativeObj, points2.nativeObj, focal, pp.x, pp.y, method, prob, threshold, maxIters, mask.nativeObj)));
  8007. }
  8008. /**
  8009. *
  8010. * param points1 Array of N (N &gt;= 5) 2D points from the first image. The point coordinates should
  8011. * be floating-point (single or double precision).
  8012. * param points2 Array of the second image points of the same size and format as points1 .
  8013. * param focal focal length of the camera. Note that this function assumes that points1 and points2
  8014. * are feature points from cameras with same focal length and principal point.
  8015. * param pp principal point of the camera.
  8016. * param method Method for computing a fundamental matrix.
  8017. * <ul>
  8018. * <li>
  8019. * REF: RANSAC for the RANSAC algorithm.
  8020. * </li>
  8021. * <li>
  8022. * REF: LMEDS for the LMedS algorithm.
  8023. * </li>
  8024. * </ul>
  8025. * param threshold Parameter used for RANSAC. It is the maximum distance from a point to an epipolar
  8026. * line in pixels, beyond which the point is considered an outlier and is not used for computing the
  8027. * final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
  8028. * point localization, image resolution, and the image noise.
  8029. * param prob Parameter used for the RANSAC or LMedS methods only. It specifies a desirable level of
  8030. * confidence (probability) that the estimated matrix is correct.
  8031. * for the other points. The array is computed only in the RANSAC and LMedS methods.
  8032. * param maxIters The maximum number of robust method iterations.
  8033. *
  8034. * This function differs from the one above that it computes camera intrinsic matrix from focal length and
  8035. * principal point:
  8036. *
  8037. * \(A =
  8038. * \begin{bmatrix}
  8039. * f &amp; 0 &amp; x_{pp} \\
  8040. * 0 &amp; f &amp; y_{pp} \\
  8041. * 0 &amp; 0 &amp; 1
  8042. * \end{bmatrix}\)
  8043. * return automatically generated
  8044. */
  8045. public static Mat findEssentialMat(Mat points1, Mat points2, double focal, Point pp, int method, double prob, double threshold, int maxIters)
  8046. {
  8047. if (points1 != null) points1.ThrowIfDisposed();
  8048. if (points2 != null) points2.ThrowIfDisposed();
  8049. return new Mat(DisposableObject.ThrowIfNullIntPtr(calib3d_Calib3d_findEssentialMat_17(points1.nativeObj, points2.nativeObj, focal, pp.x, pp.y, method, prob, threshold, maxIters)));
  8050. }
  8051. /**
  8052. *
  8053. * param points1 Array of N (N &gt;= 5) 2D points from the first image. The point coordinates should
  8054. * be floating-point (single or double precision).
  8055. * param points2 Array of the second image points of the same size and format as points1 .
  8056. * param focal focal length of the camera. Note that this function assumes that points1 and points2
  8057. * are feature points from cameras with same focal length and principal point.
  8058. * param pp principal point of the camera.
  8059. * param method Method for computing a fundamental matrix.
  8060. * <ul>
  8061. * <li>
  8062. * REF: RANSAC for the RANSAC algorithm.
  8063. * </li>
  8064. * <li>
  8065. * REF: LMEDS for the LMedS algorithm.
  8066. * </li>
  8067. * </ul>
  8068. * param threshold Parameter used for RANSAC. It is the maximum distance from a point to an epipolar
  8069. * line in pixels, beyond which the point is considered an outlier and is not used for computing the
  8070. * final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
  8071. * point localization, image resolution, and the image noise.
  8072. * param prob Parameter used for the RANSAC or LMedS methods only. It specifies a desirable level of
  8073. * confidence (probability) that the estimated matrix is correct.
  8074. * for the other points. The array is computed only in the RANSAC and LMedS methods.
  8075. *
  8076. * This function differs from the one above that it computes camera intrinsic matrix from focal length and
  8077. * principal point:
  8078. *
  8079. * \(A =
  8080. * \begin{bmatrix}
  8081. * f &amp; 0 &amp; x_{pp} \\
  8082. * 0 &amp; f &amp; y_{pp} \\
  8083. * 0 &amp; 0 &amp; 1
  8084. * \end{bmatrix}\)
  8085. * return automatically generated
  8086. */
  8087. public static Mat findEssentialMat(Mat points1, Mat points2, double focal, Point pp, int method, double prob, double threshold)
  8088. {
  8089. if (points1 != null) points1.ThrowIfDisposed();
  8090. if (points2 != null) points2.ThrowIfDisposed();
  8091. return new Mat(DisposableObject.ThrowIfNullIntPtr(calib3d_Calib3d_findEssentialMat_18(points1.nativeObj, points2.nativeObj, focal, pp.x, pp.y, method, prob, threshold)));
  8092. }
  8093. /**
  8094. *
  8095. * param points1 Array of N (N &gt;= 5) 2D points from the first image. The point coordinates should
  8096. * be floating-point (single or double precision).
  8097. * param points2 Array of the second image points of the same size and format as points1 .
  8098. * param focal focal length of the camera. Note that this function assumes that points1 and points2
  8099. * are feature points from cameras with same focal length and principal point.
  8100. * param pp principal point of the camera.
  8101. * param method Method for computing a fundamental matrix.
  8102. * <ul>
  8103. * <li>
  8104. * REF: RANSAC for the RANSAC algorithm.
  8105. * </li>
  8106. * <li>
  8107. * REF: LMEDS for the LMedS algorithm.
  8108. * </li>
  8109. * </ul>
  8110. * line in pixels, beyond which the point is considered an outlier and is not used for computing the
  8111. * final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
  8112. * point localization, image resolution, and the image noise.
  8113. * param prob Parameter used for the RANSAC or LMedS methods only. It specifies a desirable level of
  8114. * confidence (probability) that the estimated matrix is correct.
  8115. * for the other points. The array is computed only in the RANSAC and LMedS methods.
  8116. *
  8117. * This function differs from the one above that it computes camera intrinsic matrix from focal length and
  8118. * principal point:
  8119. *
  8120. * \(A =
  8121. * \begin{bmatrix}
  8122. * f &amp; 0 &amp; x_{pp} \\
  8123. * 0 &amp; f &amp; y_{pp} \\
  8124. * 0 &amp; 0 &amp; 1
  8125. * \end{bmatrix}\)
  8126. * return automatically generated
  8127. */
  8128. public static Mat findEssentialMat(Mat points1, Mat points2, double focal, Point pp, int method, double prob)
  8129. {
  8130. if (points1 != null) points1.ThrowIfDisposed();
  8131. if (points2 != null) points2.ThrowIfDisposed();
  8132. return new Mat(DisposableObject.ThrowIfNullIntPtr(calib3d_Calib3d_findEssentialMat_19(points1.nativeObj, points2.nativeObj, focal, pp.x, pp.y, method, prob)));
  8133. }
  8134. /**
  8135. *
  8136. * param points1 Array of N (N &gt;= 5) 2D points from the first image. The point coordinates should
  8137. * be floating-point (single or double precision).
  8138. * param points2 Array of the second image points of the same size and format as points1 .
  8139. * param focal focal length of the camera. Note that this function assumes that points1 and points2
  8140. * are feature points from cameras with same focal length and principal point.
  8141. * param pp principal point of the camera.
  8142. * param method Method for computing a fundamental matrix.
  8143. * <ul>
  8144. * <li>
  8145. * REF: RANSAC for the RANSAC algorithm.
  8146. * </li>
  8147. * <li>
  8148. * REF: LMEDS for the LMedS algorithm.
  8149. * </li>
  8150. * </ul>
  8151. * line in pixels, beyond which the point is considered an outlier and is not used for computing the
  8152. * final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
  8153. * point localization, image resolution, and the image noise.
  8154. * confidence (probability) that the estimated matrix is correct.
  8155. * for the other points. The array is computed only in the RANSAC and LMedS methods.
  8156. *
  8157. * This function differs from the one above that it computes camera intrinsic matrix from focal length and
  8158. * principal point:
  8159. *
  8160. * \(A =
  8161. * \begin{bmatrix}
  8162. * f &amp; 0 &amp; x_{pp} \\
  8163. * 0 &amp; f &amp; y_{pp} \\
  8164. * 0 &amp; 0 &amp; 1
  8165. * \end{bmatrix}\)
  8166. * return automatically generated
  8167. */
  8168. public static Mat findEssentialMat(Mat points1, Mat points2, double focal, Point pp, int method)
  8169. {
  8170. if (points1 != null) points1.ThrowIfDisposed();
  8171. if (points2 != null) points2.ThrowIfDisposed();
  8172. return new Mat(DisposableObject.ThrowIfNullIntPtr(calib3d_Calib3d_findEssentialMat_110(points1.nativeObj, points2.nativeObj, focal, pp.x, pp.y, method)));
  8173. }
  8174. /**
  8175. *
  8176. * param points1 Array of N (N &gt;= 5) 2D points from the first image. The point coordinates should
  8177. * be floating-point (single or double precision).
  8178. * param points2 Array of the second image points of the same size and format as points1 .
  8179. * param focal focal length of the camera. Note that this function assumes that points1 and points2
  8180. * are feature points from cameras with same focal length and principal point.
  8181. * param pp principal point of the camera.
  8182. * <ul>
  8183. * <li>
  8184. * REF: RANSAC for the RANSAC algorithm.
  8185. * </li>
  8186. * <li>
  8187. * REF: LMEDS for the LMedS algorithm.
  8188. * </li>
  8189. * </ul>
  8190. * line in pixels, beyond which the point is considered an outlier and is not used for computing the
  8191. * final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
  8192. * point localization, image resolution, and the image noise.
  8193. * confidence (probability) that the estimated matrix is correct.
  8194. * for the other points. The array is computed only in the RANSAC and LMedS methods.
  8195. *
  8196. * This function differs from the one above that it computes camera intrinsic matrix from focal length and
  8197. * principal point:
  8198. *
  8199. * \(A =
  8200. * \begin{bmatrix}
  8201. * f &amp; 0 &amp; x_{pp} \\
  8202. * 0 &amp; f &amp; y_{pp} \\
  8203. * 0 &amp; 0 &amp; 1
  8204. * \end{bmatrix}\)
  8205. * return automatically generated
  8206. */
  8207. public static Mat findEssentialMat(Mat points1, Mat points2, double focal, Point pp)
  8208. {
  8209. if (points1 != null) points1.ThrowIfDisposed();
  8210. if (points2 != null) points2.ThrowIfDisposed();
  8211. return new Mat(DisposableObject.ThrowIfNullIntPtr(calib3d_Calib3d_findEssentialMat_111(points1.nativeObj, points2.nativeObj, focal, pp.x, pp.y)));
  8212. }
  8213. /**
  8214. *
  8215. * param points1 Array of N (N &gt;= 5) 2D points from the first image. The point coordinates should
  8216. * be floating-point (single or double precision).
  8217. * param points2 Array of the second image points of the same size and format as points1 .
  8218. * param focal focal length of the camera. Note that this function assumes that points1 and points2
  8219. * are feature points from cameras with same focal length and principal point.
  8220. * <ul>
  8221. * <li>
  8222. * REF: RANSAC for the RANSAC algorithm.
  8223. * </li>
  8224. * <li>
  8225. * REF: LMEDS for the LMedS algorithm.
  8226. * </li>
  8227. * </ul>
  8228. * line in pixels, beyond which the point is considered an outlier and is not used for computing the
  8229. * final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
  8230. * point localization, image resolution, and the image noise.
  8231. * confidence (probability) that the estimated matrix is correct.
  8232. * for the other points. The array is computed only in the RANSAC and LMedS methods.
  8233. *
  8234. * This function differs from the one above that it computes camera intrinsic matrix from focal length and
  8235. * principal point:
  8236. *
  8237. * \(A =
  8238. * \begin{bmatrix}
  8239. * f &amp; 0 &amp; x_{pp} \\
  8240. * 0 &amp; f &amp; y_{pp} \\
  8241. * 0 &amp; 0 &amp; 1
  8242. * \end{bmatrix}\)
  8243. * return automatically generated
  8244. */
  8245. public static Mat findEssentialMat(Mat points1, Mat points2, double focal)
  8246. {
  8247. if (points1 != null) points1.ThrowIfDisposed();
  8248. if (points2 != null) points2.ThrowIfDisposed();
  8249. return new Mat(DisposableObject.ThrowIfNullIntPtr(calib3d_Calib3d_findEssentialMat_112(points1.nativeObj, points2.nativeObj, focal)));
  8250. }
  8251. /**
  8252. *
  8253. * param points1 Array of N (N &gt;= 5) 2D points from the first image. The point coordinates should
  8254. * be floating-point (single or double precision).
  8255. * param points2 Array of the second image points of the same size and format as points1 .
  8256. * are feature points from cameras with same focal length and principal point.
  8257. * <ul>
  8258. * <li>
  8259. * REF: RANSAC for the RANSAC algorithm.
  8260. * </li>
  8261. * <li>
  8262. * REF: LMEDS for the LMedS algorithm.
  8263. * </li>
  8264. * </ul>
  8265. * line in pixels, beyond which the point is considered an outlier and is not used for computing the
  8266. * final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
  8267. * point localization, image resolution, and the image noise.
  8268. * confidence (probability) that the estimated matrix is correct.
  8269. * for the other points. The array is computed only in the RANSAC and LMedS methods.
  8270. *
  8271. * This function differs from the one above that it computes camera intrinsic matrix from focal length and
  8272. * principal point:
  8273. *
  8274. * \(A =
  8275. * \begin{bmatrix}
  8276. * f &amp; 0 &amp; x_{pp} \\
  8277. * 0 &amp; f &amp; y_{pp} \\
  8278. * 0 &amp; 0 &amp; 1
  8279. * \end{bmatrix}\)
  8280. * return automatically generated
  8281. */
  8282. public static Mat findEssentialMat(Mat points1, Mat points2)
  8283. {
  8284. if (points1 != null) points1.ThrowIfDisposed();
  8285. if (points2 != null) points2.ThrowIfDisposed();
  8286. return new Mat(DisposableObject.ThrowIfNullIntPtr(calib3d_Calib3d_findEssentialMat_113(points1.nativeObj, points2.nativeObj)));
  8287. }
  8288. //
  8289. // C++: Mat cv::findEssentialMat(Mat points1, Mat points2, Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, int method = RANSAC, double prob = 0.999, double threshold = 1.0, Mat& mask = Mat())
  8290. //
  8291. /**
  8292. * Calculates an essential matrix from the corresponding points in two images from potentially two different cameras.
  8293. *
  8294. * param points1 Array of N (N &gt;= 5) 2D points from the first image. The point coordinates should
  8295. * be floating-point (single or double precision).
  8296. * param points2 Array of the second image points of the same size and format as points1 .
  8297. * param cameraMatrix1 Camera matrix \(K = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\) .
  8298. * Note that this function assumes that points1 and points2 are feature points from cameras with the
  8299. * same camera matrix. If this assumption does not hold for your use case, use
  8300. * #undistortPoints with {code P = cv::NoArray()} for both cameras to transform image points
  8301. * to normalized image coordinates, which are valid for the identity camera matrix. When
  8302. * passing these coordinates, pass the identity matrix for this parameter.
  8303. * param cameraMatrix2 Camera matrix \(K = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\) .
  8304. * Note that this function assumes that points1 and points2 are feature points from cameras with the
  8305. * same camera matrix. If this assumption does not hold for your use case, use
  8306. * #undistortPoints with {code P = cv::NoArray()} for both cameras to transform image points
  8307. * to normalized image coordinates, which are valid for the identity camera matrix. When
  8308. * passing these coordinates, pass the identity matrix for this parameter.
  8309. * param distCoeffs1 Input vector of distortion coefficients
  8310. * \((k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6[, s_1, s_2, s_3, s_4[, \tau_x, \tau_y]]]])\)
  8311. * of 4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed.
  8312. * param distCoeffs2 Input vector of distortion coefficients
  8313. * \((k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6[, s_1, s_2, s_3, s_4[, \tau_x, \tau_y]]]])\)
  8314. * of 4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed.
  8315. * param method Method for computing an essential matrix.
  8316. * <ul>
  8317. * <li>
  8318. * REF: RANSAC for the RANSAC algorithm.
  8319. * </li>
  8320. * <li>
  8321. * REF: LMEDS for the LMedS algorithm.
  8322. * </li>
  8323. * </ul>
  8324. * param prob Parameter used for the RANSAC or LMedS methods only. It specifies a desirable level of
  8325. * confidence (probability) that the estimated matrix is correct.
  8326. * param threshold Parameter used for RANSAC. It is the maximum distance from a point to an epipolar
  8327. * line in pixels, beyond which the point is considered an outlier and is not used for computing the
  8328. * final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
  8329. * point localization, image resolution, and the image noise.
  8330. * param mask Output array of N elements, every element of which is set to 0 for outliers and to 1
  8331. * for the other points. The array is computed only in the RANSAC and LMedS methods.
  8332. *
  8333. * This function estimates essential matrix based on the five-point algorithm solver in CITE: Nister03 .
  8334. * CITE: SteweniusCFS is also a related. The epipolar geometry is described by the following equation:
  8335. *
  8336. * \([p_2; 1]^T K^{-T} E K^{-1} [p_1; 1] = 0\)
  8337. *
  8338. * where \(E\) is an essential matrix, \(p_1\) and \(p_2\) are corresponding points in the first and the
  8339. * second images, respectively. The result of this function may be passed further to
  8340. * #decomposeEssentialMat or #recoverPose to recover the relative pose between cameras.
  8341. * return automatically generated
  8342. */
  8343. public static Mat findEssentialMat(Mat points1, Mat points2, Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, int method, double prob, double threshold, Mat mask)
  8344. {
  8345. if (points1 != null) points1.ThrowIfDisposed();
  8346. if (points2 != null) points2.ThrowIfDisposed();
  8347. if (cameraMatrix1 != null) cameraMatrix1.ThrowIfDisposed();
  8348. if (distCoeffs1 != null) distCoeffs1.ThrowIfDisposed();
  8349. if (cameraMatrix2 != null) cameraMatrix2.ThrowIfDisposed();
  8350. if (distCoeffs2 != null) distCoeffs2.ThrowIfDisposed();
  8351. if (mask != null) mask.ThrowIfDisposed();
  8352. return new Mat(DisposableObject.ThrowIfNullIntPtr(calib3d_Calib3d_findEssentialMat_114(points1.nativeObj, points2.nativeObj, cameraMatrix1.nativeObj, distCoeffs1.nativeObj, cameraMatrix2.nativeObj, distCoeffs2.nativeObj, method, prob, threshold, mask.nativeObj)));
  8353. }
  8354. /**
  8355. * Calculates an essential matrix from the corresponding points in two images from potentially two different cameras.
  8356. *
  8357. * param points1 Array of N (N &gt;= 5) 2D points from the first image. The point coordinates should
  8358. * be floating-point (single or double precision).
  8359. * param points2 Array of the second image points of the same size and format as points1 .
  8360. * param cameraMatrix1 Camera matrix \(K = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\) .
  8361. * Note that this function assumes that points1 and points2 are feature points from cameras with the
  8362. * same camera matrix. If this assumption does not hold for your use case, use
  8363. * #undistortPoints with {code P = cv::NoArray()} for both cameras to transform image points
  8364. * to normalized image coordinates, which are valid for the identity camera matrix. When
  8365. * passing these coordinates, pass the identity matrix for this parameter.
  8366. * param cameraMatrix2 Camera matrix \(K = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\) .
  8367. * Note that this function assumes that points1 and points2 are feature points from cameras with the
  8368. * same camera matrix. If this assumption does not hold for your use case, use
  8369. * #undistortPoints with {code P = cv::NoArray()} for both cameras to transform image points
  8370. * to normalized image coordinates, which are valid for the identity camera matrix. When
  8371. * passing these coordinates, pass the identity matrix for this parameter.
  8372. * param distCoeffs1 Input vector of distortion coefficients
  8373. * \((k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6[, s_1, s_2, s_3, s_4[, \tau_x, \tau_y]]]])\)
  8374. * of 4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed.
  8375. * param distCoeffs2 Input vector of distortion coefficients
  8376. * \((k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6[, s_1, s_2, s_3, s_4[, \tau_x, \tau_y]]]])\)
  8377. * of 4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed.
  8378. * param method Method for computing an essential matrix.
  8379. * <ul>
  8380. * <li>
  8381. * REF: RANSAC for the RANSAC algorithm.
  8382. * </li>
  8383. * <li>
  8384. * REF: LMEDS for the LMedS algorithm.
  8385. * </li>
  8386. * </ul>
  8387. * param prob Parameter used for the RANSAC or LMedS methods only. It specifies a desirable level of
  8388. * confidence (probability) that the estimated matrix is correct.
  8389. * param threshold Parameter used for RANSAC. It is the maximum distance from a point to an epipolar
  8390. * line in pixels, beyond which the point is considered an outlier and is not used for computing the
  8391. * final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
  8392. * point localization, image resolution, and the image noise.
  8393. * for the other points. The array is computed only in the RANSAC and LMedS methods.
  8394. *
  8395. * This function estimates essential matrix based on the five-point algorithm solver in CITE: Nister03 .
  8396. * CITE: SteweniusCFS is also a related. The epipolar geometry is described by the following equation:
  8397. *
  8398. * \([p_2; 1]^T K^{-T} E K^{-1} [p_1; 1] = 0\)
  8399. *
  8400. * where \(E\) is an essential matrix, \(p_1\) and \(p_2\) are corresponding points in the first and the
  8401. * second images, respectively. The result of this function may be passed further to
  8402. * #decomposeEssentialMat or #recoverPose to recover the relative pose between cameras.
  8403. * return automatically generated
  8404. */
  8405. public static Mat findEssentialMat(Mat points1, Mat points2, Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, int method, double prob, double threshold)
  8406. {
  8407. if (points1 != null) points1.ThrowIfDisposed();
  8408. if (points2 != null) points2.ThrowIfDisposed();
  8409. if (cameraMatrix1 != null) cameraMatrix1.ThrowIfDisposed();
  8410. if (distCoeffs1 != null) distCoeffs1.ThrowIfDisposed();
  8411. if (cameraMatrix2 != null) cameraMatrix2.ThrowIfDisposed();
  8412. if (distCoeffs2 != null) distCoeffs2.ThrowIfDisposed();
  8413. return new Mat(DisposableObject.ThrowIfNullIntPtr(calib3d_Calib3d_findEssentialMat_115(points1.nativeObj, points2.nativeObj, cameraMatrix1.nativeObj, distCoeffs1.nativeObj, cameraMatrix2.nativeObj, distCoeffs2.nativeObj, method, prob, threshold)));
  8414. }
  8415. /**
  8416. * Calculates an essential matrix from the corresponding points in two images from potentially two different cameras.
  8417. *
  8418. * param points1 Array of N (N &gt;= 5) 2D points from the first image. The point coordinates should
  8419. * be floating-point (single or double precision).
  8420. * param points2 Array of the second image points of the same size and format as points1 .
  8421. * param cameraMatrix1 Camera matrix \(K = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\) .
  8422. * Note that this function assumes that points1 and points2 are feature points from cameras with the
  8423. * same camera matrix. If this assumption does not hold for your use case, use
  8424. * #undistortPoints with {code P = cv::NoArray()} for both cameras to transform image points
  8425. * to normalized image coordinates, which are valid for the identity camera matrix. When
  8426. * passing these coordinates, pass the identity matrix for this parameter.
  8427. * param cameraMatrix2 Camera matrix \(K = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\) .
  8428. * Note that this function assumes that points1 and points2 are feature points from cameras with the
  8429. * same camera matrix. If this assumption does not hold for your use case, use
  8430. * #undistortPoints with {code P = cv::NoArray()} for both cameras to transform image points
  8431. * to normalized image coordinates, which are valid for the identity camera matrix. When
  8432. * passing these coordinates, pass the identity matrix for this parameter.
  8433. * param distCoeffs1 Input vector of distortion coefficients
  8434. * \((k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6[, s_1, s_2, s_3, s_4[, \tau_x, \tau_y]]]])\)
  8435. * of 4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed.
  8436. * param distCoeffs2 Input vector of distortion coefficients
  8437. * \((k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6[, s_1, s_2, s_3, s_4[, \tau_x, \tau_y]]]])\)
  8438. * of 4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed.
  8439. * param method Method for computing an essential matrix.
  8440. * <ul>
  8441. * <li>
  8442. * REF: RANSAC for the RANSAC algorithm.
  8443. * </li>
  8444. * <li>
  8445. * REF: LMEDS for the LMedS algorithm.
  8446. * </li>
  8447. * </ul>
  8448. * param prob Parameter used for the RANSAC or LMedS methods only. It specifies a desirable level of
  8449. * confidence (probability) that the estimated matrix is correct.
  8450. * line in pixels, beyond which the point is considered an outlier and is not used for computing the
  8451. * final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
  8452. * point localization, image resolution, and the image noise.
  8453. * for the other points. The array is computed only in the RANSAC and LMedS methods.
  8454. *
  8455. * This function estimates essential matrix based on the five-point algorithm solver in CITE: Nister03 .
  8456. * CITE: SteweniusCFS is also a related. The epipolar geometry is described by the following equation:
  8457. *
  8458. * \([p_2; 1]^T K^{-T} E K^{-1} [p_1; 1] = 0\)
  8459. *
  8460. * where \(E\) is an essential matrix, \(p_1\) and \(p_2\) are corresponding points in the first and the
  8461. * second images, respectively. The result of this function may be passed further to
  8462. * #decomposeEssentialMat or #recoverPose to recover the relative pose between cameras.
  8463. * return automatically generated
  8464. */
  8465. public static Mat findEssentialMat(Mat points1, Mat points2, Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, int method, double prob)
  8466. {
  8467. if (points1 != null) points1.ThrowIfDisposed();
  8468. if (points2 != null) points2.ThrowIfDisposed();
  8469. if (cameraMatrix1 != null) cameraMatrix1.ThrowIfDisposed();
  8470. if (distCoeffs1 != null) distCoeffs1.ThrowIfDisposed();
  8471. if (cameraMatrix2 != null) cameraMatrix2.ThrowIfDisposed();
  8472. if (distCoeffs2 != null) distCoeffs2.ThrowIfDisposed();
  8473. return new Mat(DisposableObject.ThrowIfNullIntPtr(calib3d_Calib3d_findEssentialMat_116(points1.nativeObj, points2.nativeObj, cameraMatrix1.nativeObj, distCoeffs1.nativeObj, cameraMatrix2.nativeObj, distCoeffs2.nativeObj, method, prob)));
  8474. }
  8475. /**
  8476. * Calculates an essential matrix from the corresponding points in two images from potentially two different cameras.
  8477. *
  8478. * param points1 Array of N (N &gt;= 5) 2D points from the first image. The point coordinates should
  8479. * be floating-point (single or double precision).
  8480. * param points2 Array of the second image points of the same size and format as points1 .
  8481. * param cameraMatrix1 Camera matrix \(K = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\) .
  8482. * Note that this function assumes that points1 and points2 are feature points from cameras with the
  8483. * same camera matrix. If this assumption does not hold for your use case, use
  8484. * #undistortPoints with {code P = cv::NoArray()} for both cameras to transform image points
  8485. * to normalized image coordinates, which are valid for the identity camera matrix. When
  8486. * passing these coordinates, pass the identity matrix for this parameter.
  8487. * param cameraMatrix2 Camera matrix \(K = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\) .
  8488. * Note that this function assumes that points1 and points2 are feature points from cameras with the
  8489. * same camera matrix. If this assumption does not hold for your use case, use
  8490. * #undistortPoints with {code P = cv::NoArray()} for both cameras to transform image points
  8491. * to normalized image coordinates, which are valid for the identity camera matrix. When
  8492. * passing these coordinates, pass the identity matrix for this parameter.
  8493. * param distCoeffs1 Input vector of distortion coefficients
  8494. * \((k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6[, s_1, s_2, s_3, s_4[, \tau_x, \tau_y]]]])\)
  8495. * of 4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed.
  8496. * param distCoeffs2 Input vector of distortion coefficients
  8497. * \((k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6[, s_1, s_2, s_3, s_4[, \tau_x, \tau_y]]]])\)
  8498. * of 4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed.
  8499. * param method Method for computing an essential matrix.
  8500. * <ul>
  8501. * <li>
  8502. * REF: RANSAC for the RANSAC algorithm.
  8503. * </li>
  8504. * <li>
  8505. * REF: LMEDS for the LMedS algorithm.
  8506. * </li>
  8507. * </ul>
  8508. * confidence (probability) that the estimated matrix is correct.
  8509. * line in pixels, beyond which the point is considered an outlier and is not used for computing the
  8510. * final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
  8511. * point localization, image resolution, and the image noise.
  8512. * for the other points. The array is computed only in the RANSAC and LMedS methods.
  8513. *
  8514. * This function estimates essential matrix based on the five-point algorithm solver in CITE: Nister03 .
  8515. * CITE: SteweniusCFS is also a related. The epipolar geometry is described by the following equation:
  8516. *
  8517. * \([p_2; 1]^T K^{-T} E K^{-1} [p_1; 1] = 0\)
  8518. *
  8519. * where \(E\) is an essential matrix, \(p_1\) and \(p_2\) are corresponding points in the first and the
  8520. * second images, respectively. The result of this function may be passed further to
  8521. * #decomposeEssentialMat or #recoverPose to recover the relative pose between cameras.
  8522. * return automatically generated
  8523. */
  8524. public static Mat findEssentialMat(Mat points1, Mat points2, Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, int method)
  8525. {
  8526. if (points1 != null) points1.ThrowIfDisposed();
  8527. if (points2 != null) points2.ThrowIfDisposed();
  8528. if (cameraMatrix1 != null) cameraMatrix1.ThrowIfDisposed();
  8529. if (distCoeffs1 != null) distCoeffs1.ThrowIfDisposed();
  8530. if (cameraMatrix2 != null) cameraMatrix2.ThrowIfDisposed();
  8531. if (distCoeffs2 != null) distCoeffs2.ThrowIfDisposed();
  8532. return new Mat(DisposableObject.ThrowIfNullIntPtr(calib3d_Calib3d_findEssentialMat_117(points1.nativeObj, points2.nativeObj, cameraMatrix1.nativeObj, distCoeffs1.nativeObj, cameraMatrix2.nativeObj, distCoeffs2.nativeObj, method)));
  8533. }
  8534. /**
  8535. * Calculates an essential matrix from the corresponding points in two images from potentially two different cameras.
  8536. *
  8537. * param points1 Array of N (N &gt;= 5) 2D points from the first image. The point coordinates should
  8538. * be floating-point (single or double precision).
  8539. * param points2 Array of the second image points of the same size and format as points1 .
  8540. * param cameraMatrix1 Camera matrix \(K = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\) .
  8541. * Note that this function assumes that points1 and points2 are feature points from cameras with the
  8542. * same camera matrix. If this assumption does not hold for your use case, use
  8543. * #undistortPoints with {code P = cv::NoArray()} for both cameras to transform image points
  8544. * to normalized image coordinates, which are valid for the identity camera matrix. When
  8545. * passing these coordinates, pass the identity matrix for this parameter.
  8546. * param cameraMatrix2 Camera matrix \(K = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\) .
  8547. * Note that this function assumes that points1 and points2 are feature points from cameras with the
  8548. * same camera matrix. If this assumption does not hold for your use case, use
  8549. * #undistortPoints with {code P = cv::NoArray()} for both cameras to transform image points
  8550. * to normalized image coordinates, which are valid for the identity camera matrix. When
  8551. * passing these coordinates, pass the identity matrix for this parameter.
  8552. * param distCoeffs1 Input vector of distortion coefficients
  8553. * \((k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6[, s_1, s_2, s_3, s_4[, \tau_x, \tau_y]]]])\)
  8554. * of 4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed.
  8555. * param distCoeffs2 Input vector of distortion coefficients
  8556. * \((k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6[, s_1, s_2, s_3, s_4[, \tau_x, \tau_y]]]])\)
  8557. * of 4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed.
  8558. * <ul>
  8559. * <li>
  8560. * REF: RANSAC for the RANSAC algorithm.
  8561. * </li>
  8562. * <li>
  8563. * REF: LMEDS for the LMedS algorithm.
  8564. * </li>
  8565. * </ul>
  8566. * confidence (probability) that the estimated matrix is correct.
  8567. * line in pixels, beyond which the point is considered an outlier and is not used for computing the
  8568. * final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
  8569. * point localization, image resolution, and the image noise.
  8570. * for the other points. The array is computed only in the RANSAC and LMedS methods.
  8571. *
  8572. * This function estimates essential matrix based on the five-point algorithm solver in CITE: Nister03 .
  8573. * CITE: SteweniusCFS is also a related. The epipolar geometry is described by the following equation:
  8574. *
  8575. * \([p_2; 1]^T K^{-T} E K^{-1} [p_1; 1] = 0\)
  8576. *
  8577. * where \(E\) is an essential matrix, \(p_1\) and \(p_2\) are corresponding points in the first and the
  8578. * second images, respectively. The result of this function may be passed further to
  8579. * #decomposeEssentialMat or #recoverPose to recover the relative pose between cameras.
  8580. * return automatically generated
  8581. */
  8582. public static Mat findEssentialMat(Mat points1, Mat points2, Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2)
  8583. {
  8584. if (points1 != null) points1.ThrowIfDisposed();
  8585. if (points2 != null) points2.ThrowIfDisposed();
  8586. if (cameraMatrix1 != null) cameraMatrix1.ThrowIfDisposed();
  8587. if (distCoeffs1 != null) distCoeffs1.ThrowIfDisposed();
  8588. if (cameraMatrix2 != null) cameraMatrix2.ThrowIfDisposed();
  8589. if (distCoeffs2 != null) distCoeffs2.ThrowIfDisposed();
  8590. return new Mat(DisposableObject.ThrowIfNullIntPtr(calib3d_Calib3d_findEssentialMat_118(points1.nativeObj, points2.nativeObj, cameraMatrix1.nativeObj, distCoeffs1.nativeObj, cameraMatrix2.nativeObj, distCoeffs2.nativeObj)));
  8591. }
  8592. //
  8593. // C++: Mat cv::findEssentialMat(Mat points1, Mat points2, Mat cameraMatrix1, Mat cameraMatrix2, Mat dist_coeff1, Mat dist_coeff2, Mat& mask, UsacParams _params)
  8594. //
  8595. public static Mat findEssentialMat(Mat points1, Mat points2, Mat cameraMatrix1, Mat cameraMatrix2, Mat dist_coeff1, Mat dist_coeff2, Mat mask, UsacParams _params)
  8596. {
  8597. if (points1 != null) points1.ThrowIfDisposed();
  8598. if (points2 != null) points2.ThrowIfDisposed();
  8599. if (cameraMatrix1 != null) cameraMatrix1.ThrowIfDisposed();
  8600. if (cameraMatrix2 != null) cameraMatrix2.ThrowIfDisposed();
  8601. if (dist_coeff1 != null) dist_coeff1.ThrowIfDisposed();
  8602. if (dist_coeff2 != null) dist_coeff2.ThrowIfDisposed();
  8603. if (mask != null) mask.ThrowIfDisposed();
  8604. if (_params != null) _params.ThrowIfDisposed();
  8605. return new Mat(DisposableObject.ThrowIfNullIntPtr(calib3d_Calib3d_findEssentialMat_119(points1.nativeObj, points2.nativeObj, cameraMatrix1.nativeObj, cameraMatrix2.nativeObj, dist_coeff1.nativeObj, dist_coeff2.nativeObj, mask.nativeObj, _params.nativeObj)));
  8606. }
  8607. //
  8608. // C++: void cv::decomposeEssentialMat(Mat E, Mat& R1, Mat& R2, Mat& t)
  8609. //
  8610. /**
  8611. * Decompose an essential matrix to possible rotations and translation.
  8612. *
  8613. * param E The input essential matrix.
  8614. * param R1 One possible rotation matrix.
  8615. * param R2 Another possible rotation matrix.
  8616. * param t One possible translation.
  8617. *
  8618. * This function decomposes the essential matrix E using svd decomposition CITE: HartleyZ00. In
  8619. * general, four possible poses exist for the decomposition of E. They are \([R_1, t]\),
  8620. * \([R_1, -t]\), \([R_2, t]\), \([R_2, -t]\).
  8621. *
  8622. * If E gives the epipolar constraint \([p_2; 1]^T A^{-T} E A^{-1} [p_1; 1] = 0\) between the image
  8623. * points \(p_1\) in the first image and \(p_2\) in second image, then any of the tuples
  8624. * \([R_1, t]\), \([R_1, -t]\), \([R_2, t]\), \([R_2, -t]\) is a change of basis from the first
  8625. * camera's coordinate system to the second camera's coordinate system. However, by decomposing E, one
  8626. * can only get the direction of the translation. For this reason, the translation t is returned with
  8627. * unit length.
  8628. */
  8629. public static void decomposeEssentialMat(Mat E, Mat R1, Mat R2, Mat t)
  8630. {
  8631. if (E != null) E.ThrowIfDisposed();
  8632. if (R1 != null) R1.ThrowIfDisposed();
  8633. if (R2 != null) R2.ThrowIfDisposed();
  8634. if (t != null) t.ThrowIfDisposed();
  8635. calib3d_Calib3d_decomposeEssentialMat_10(E.nativeObj, R1.nativeObj, R2.nativeObj, t.nativeObj);
  8636. }
  8637. //
  8638. // C++: int cv::recoverPose(Mat points1, Mat points2, Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Mat& E, Mat& R, Mat& t, int method = cv::RANSAC, double prob = 0.999, double threshold = 1.0, Mat& mask = Mat())
  8639. //
  8640. /**
  8641. * Recovers the relative camera rotation and the translation from corresponding points in two images from two different cameras, using cheirality check. Returns the number of
  8642. * inliers that pass the check.
  8643. *
  8644. * param points1 Array of N 2D points from the first image. The point coordinates should be
  8645. * floating-point (single or double precision).
  8646. * param points2 Array of the second image points of the same size and format as points1 .
  8647. * param cameraMatrix1 Input/output camera matrix for the first camera, the same as in
  8648. * REF: calibrateCamera. Furthermore, for the stereo case, additional flags may be used, see below.
  8649. * param distCoeffs1 Input/output vector of distortion coefficients, the same as in
  8650. * REF: calibrateCamera.
  8651. * param cameraMatrix2 Input/output camera matrix for the first camera, the same as in
  8652. * REF: calibrateCamera. Furthermore, for the stereo case, additional flags may be used, see below.
  8653. * param distCoeffs2 Input/output vector of distortion coefficients, the same as in
  8654. * REF: calibrateCamera.
  8655. * param E The output essential matrix.
  8656. * param R Output rotation matrix. Together with the translation vector, this matrix makes up a tuple
  8657. * that performs a change of basis from the first camera's coordinate system to the second camera's
  8658. * coordinate system. Note that, in general, t can not be used for this tuple, see the parameter
  8659. * described below.
  8660. * param t Output translation vector. This vector is obtained by REF: decomposeEssentialMat and
  8661. * therefore is only known up to scale, i.e. t is the direction of the translation vector and has unit
  8662. * length.
  8663. * param method Method for computing an essential matrix.
  8664. * <ul>
  8665. * <li>
  8666. * REF: RANSAC for the RANSAC algorithm.
  8667. * </li>
  8668. * <li>
  8669. * REF: LMEDS for the LMedS algorithm.
  8670. * </li>
  8671. * </ul>
  8672. * param prob Parameter used for the RANSAC or LMedS methods only. It specifies a desirable level of
  8673. * confidence (probability) that the estimated matrix is correct.
  8674. * param threshold Parameter used for RANSAC. It is the maximum distance from a point to an epipolar
  8675. * line in pixels, beyond which the point is considered an outlier and is not used for computing the
  8676. * final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
  8677. * point localization, image resolution, and the image noise.
  8678. * param mask Input/output mask for inliers in points1 and points2. If it is not empty, then it marks
  8679. * inliers in points1 and points2 for then given essential matrix E. Only these inliers will be used to
  8680. * recover pose. In the output mask only inliers which pass the cheirality check.
  8681. *
  8682. * This function decomposes an essential matrix using REF: decomposeEssentialMat and then verifies
  8683. * possible pose hypotheses by doing cheirality check. The cheirality check means that the
  8684. * triangulated 3D points should have positive depth. Some details can be found in CITE: Nister03.
  8685. *
  8686. * This function can be used to process the output E and mask from REF: findEssentialMat. In this
  8687. * scenario, points1 and points2 are the same input for findEssentialMat.:
  8688. * <code>
  8689. * // Example. Estimation of fundamental matrix using the RANSAC algorithm
  8690. * int point_count = 100;
  8691. * vector&lt;Point2f&gt; points1(point_count);
  8692. * vector&lt;Point2f&gt; points2(point_count);
  8693. *
  8694. * // initialize the points here ...
  8695. * for( int i = 0; i &lt; point_count; i++ )
  8696. * {
  8697. * points1[i] = ...;
  8698. * points2[i] = ...;
  8699. * }
  8700. *
  8701. * // Input: camera calibration of both cameras, for example using intrinsic chessboard calibration.
  8702. * Mat cameraMatrix1, distCoeffs1, cameraMatrix2, distCoeffs2;
  8703. *
  8704. * // Output: Essential matrix, relative rotation and relative translation.
  8705. * Mat E, R, t, mask;
  8706. *
  8707. * recoverPose(points1, points2, cameraMatrix1, distCoeffs1, cameraMatrix2, distCoeffs2, E, R, t, mask);
  8708. * </code>
  8709. * return automatically generated
  8710. */
  8711. public static int recoverPose(Mat points1, Mat points2, Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Mat E, Mat R, Mat t, int method, double prob, double threshold, Mat mask)
  8712. {
  8713. if (points1 != null) points1.ThrowIfDisposed();
  8714. if (points2 != null) points2.ThrowIfDisposed();
  8715. if (cameraMatrix1 != null) cameraMatrix1.ThrowIfDisposed();
  8716. if (distCoeffs1 != null) distCoeffs1.ThrowIfDisposed();
  8717. if (cameraMatrix2 != null) cameraMatrix2.ThrowIfDisposed();
  8718. if (distCoeffs2 != null) distCoeffs2.ThrowIfDisposed();
  8719. if (E != null) E.ThrowIfDisposed();
  8720. if (R != null) R.ThrowIfDisposed();
  8721. if (t != null) t.ThrowIfDisposed();
  8722. if (mask != null) mask.ThrowIfDisposed();
  8723. return calib3d_Calib3d_recoverPose_10(points1.nativeObj, points2.nativeObj, cameraMatrix1.nativeObj, distCoeffs1.nativeObj, cameraMatrix2.nativeObj, distCoeffs2.nativeObj, E.nativeObj, R.nativeObj, t.nativeObj, method, prob, threshold, mask.nativeObj);
  8724. }
  8725. /**
  8726. * Recovers the relative camera rotation and the translation from corresponding points in two images from two different cameras, using cheirality check. Returns the number of
  8727. * inliers that pass the check.
  8728. *
  8729. * param points1 Array of N 2D points from the first image. The point coordinates should be
  8730. * floating-point (single or double precision).
  8731. * param points2 Array of the second image points of the same size and format as points1 .
  8732. * param cameraMatrix1 Input/output camera matrix for the first camera, the same as in
  8733. * REF: calibrateCamera. Furthermore, for the stereo case, additional flags may be used, see below.
  8734. * param distCoeffs1 Input/output vector of distortion coefficients, the same as in
  8735. * REF: calibrateCamera.
  8736. * param cameraMatrix2 Input/output camera matrix for the first camera, the same as in
  8737. * REF: calibrateCamera. Furthermore, for the stereo case, additional flags may be used, see below.
  8738. * param distCoeffs2 Input/output vector of distortion coefficients, the same as in
  8739. * REF: calibrateCamera.
  8740. * param E The output essential matrix.
  8741. * param R Output rotation matrix. Together with the translation vector, this matrix makes up a tuple
  8742. * that performs a change of basis from the first camera's coordinate system to the second camera's
  8743. * coordinate system. Note that, in general, t can not be used for this tuple, see the parameter
  8744. * described below.
  8745. * param t Output translation vector. This vector is obtained by REF: decomposeEssentialMat and
  8746. * therefore is only known up to scale, i.e. t is the direction of the translation vector and has unit
  8747. * length.
  8748. * param method Method for computing an essential matrix.
  8749. * <ul>
  8750. * <li>
  8751. * REF: RANSAC for the RANSAC algorithm.
  8752. * </li>
  8753. * <li>
  8754. * REF: LMEDS for the LMedS algorithm.
  8755. * </li>
  8756. * </ul>
  8757. * param prob Parameter used for the RANSAC or LMedS methods only. It specifies a desirable level of
  8758. * confidence (probability) that the estimated matrix is correct.
  8759. * param threshold Parameter used for RANSAC. It is the maximum distance from a point to an epipolar
  8760. * line in pixels, beyond which the point is considered an outlier and is not used for computing the
  8761. * final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
  8762. * point localization, image resolution, and the image noise.
  8763. * inliers in points1 and points2 for then given essential matrix E. Only these inliers will be used to
  8764. * recover pose. In the output mask only inliers which pass the cheirality check.
  8765. *
  8766. * This function decomposes an essential matrix using REF: decomposeEssentialMat and then verifies
  8767. * possible pose hypotheses by doing cheirality check. The cheirality check means that the
  8768. * triangulated 3D points should have positive depth. Some details can be found in CITE: Nister03.
  8769. *
  8770. * This function can be used to process the output E and mask from REF: findEssentialMat. In this
  8771. * scenario, points1 and points2 are the same input for findEssentialMat.:
  8772. * <code>
  8773. * // Example. Estimation of fundamental matrix using the RANSAC algorithm
  8774. * int point_count = 100;
  8775. * vector&lt;Point2f&gt; points1(point_count);
  8776. * vector&lt;Point2f&gt; points2(point_count);
  8777. *
  8778. * // initialize the points here ...
  8779. * for( int i = 0; i &lt; point_count; i++ )
  8780. * {
  8781. * points1[i] = ...;
  8782. * points2[i] = ...;
  8783. * }
  8784. *
  8785. * // Input: camera calibration of both cameras, for example using intrinsic chessboard calibration.
  8786. * Mat cameraMatrix1, distCoeffs1, cameraMatrix2, distCoeffs2;
  8787. *
  8788. * // Output: Essential matrix, relative rotation and relative translation.
  8789. * Mat E, R, t, mask;
  8790. *
  8791. * recoverPose(points1, points2, cameraMatrix1, distCoeffs1, cameraMatrix2, distCoeffs2, E, R, t, mask);
  8792. * </code>
  8793. * return automatically generated
  8794. */
  8795. public static int recoverPose(Mat points1, Mat points2, Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Mat E, Mat R, Mat t, int method, double prob, double threshold)
  8796. {
  8797. if (points1 != null) points1.ThrowIfDisposed();
  8798. if (points2 != null) points2.ThrowIfDisposed();
  8799. if (cameraMatrix1 != null) cameraMatrix1.ThrowIfDisposed();
  8800. if (distCoeffs1 != null) distCoeffs1.ThrowIfDisposed();
  8801. if (cameraMatrix2 != null) cameraMatrix2.ThrowIfDisposed();
  8802. if (distCoeffs2 != null) distCoeffs2.ThrowIfDisposed();
  8803. if (E != null) E.ThrowIfDisposed();
  8804. if (R != null) R.ThrowIfDisposed();
  8805. if (t != null) t.ThrowIfDisposed();
  8806. return calib3d_Calib3d_recoverPose_11(points1.nativeObj, points2.nativeObj, cameraMatrix1.nativeObj, distCoeffs1.nativeObj, cameraMatrix2.nativeObj, distCoeffs2.nativeObj, E.nativeObj, R.nativeObj, t.nativeObj, method, prob, threshold);
  8807. }
  8808. /**
  8809. * Recovers the relative camera rotation and the translation from corresponding points in two images from two different cameras, using cheirality check. Returns the number of
  8810. * inliers that pass the check.
  8811. *
  8812. * param points1 Array of N 2D points from the first image. The point coordinates should be
  8813. * floating-point (single or double precision).
  8814. * param points2 Array of the second image points of the same size and format as points1 .
  8815. * param cameraMatrix1 Input/output camera matrix for the first camera, the same as in
  8816. * REF: calibrateCamera. Furthermore, for the stereo case, additional flags may be used, see below.
  8817. * param distCoeffs1 Input/output vector of distortion coefficients, the same as in
  8818. * REF: calibrateCamera.
  8819. * param cameraMatrix2 Input/output camera matrix for the first camera, the same as in
  8820. * REF: calibrateCamera. Furthermore, for the stereo case, additional flags may be used, see below.
  8821. * param distCoeffs2 Input/output vector of distortion coefficients, the same as in
  8822. * REF: calibrateCamera.
  8823. * param E The output essential matrix.
  8824. * param R Output rotation matrix. Together with the translation vector, this matrix makes up a tuple
  8825. * that performs a change of basis from the first camera's coordinate system to the second camera's
  8826. * coordinate system. Note that, in general, t can not be used for this tuple, see the parameter
  8827. * described below.
  8828. * param t Output translation vector. This vector is obtained by REF: decomposeEssentialMat and
  8829. * therefore is only known up to scale, i.e. t is the direction of the translation vector and has unit
  8830. * length.
  8831. * param method Method for computing an essential matrix.
  8832. * <ul>
  8833. * <li>
  8834. * REF: RANSAC for the RANSAC algorithm.
  8835. * </li>
  8836. * <li>
  8837. * REF: LMEDS for the LMedS algorithm.
  8838. * </li>
  8839. * </ul>
  8840. * param prob Parameter used for the RANSAC or LMedS methods only. It specifies a desirable level of
  8841. * confidence (probability) that the estimated matrix is correct.
  8842. * line in pixels, beyond which the point is considered an outlier and is not used for computing the
  8843. * final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
  8844. * point localization, image resolution, and the image noise.
  8845. * inliers in points1 and points2 for then given essential matrix E. Only these inliers will be used to
  8846. * recover pose. In the output mask only inliers which pass the cheirality check.
  8847. *
  8848. * This function decomposes an essential matrix using REF: decomposeEssentialMat and then verifies
  8849. * possible pose hypotheses by doing cheirality check. The cheirality check means that the
  8850. * triangulated 3D points should have positive depth. Some details can be found in CITE: Nister03.
  8851. *
  8852. * This function can be used to process the output E and mask from REF: findEssentialMat. In this
  8853. * scenario, points1 and points2 are the same input for findEssentialMat.:
  8854. * <code>
  8855. * // Example. Estimation of fundamental matrix using the RANSAC algorithm
  8856. * int point_count = 100;
  8857. * vector&lt;Point2f&gt; points1(point_count);
  8858. * vector&lt;Point2f&gt; points2(point_count);
  8859. *
  8860. * // initialize the points here ...
  8861. * for( int i = 0; i &lt; point_count; i++ )
  8862. * {
  8863. * points1[i] = ...;
  8864. * points2[i] = ...;
  8865. * }
  8866. *
  8867. * // Input: camera calibration of both cameras, for example using intrinsic chessboard calibration.
  8868. * Mat cameraMatrix1, distCoeffs1, cameraMatrix2, distCoeffs2;
  8869. *
  8870. * // Output: Essential matrix, relative rotation and relative translation.
  8871. * Mat E, R, t, mask;
  8872. *
  8873. * recoverPose(points1, points2, cameraMatrix1, distCoeffs1, cameraMatrix2, distCoeffs2, E, R, t, mask);
  8874. * </code>
  8875. * return automatically generated
  8876. */
  8877. public static int recoverPose(Mat points1, Mat points2, Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Mat E, Mat R, Mat t, int method, double prob)
  8878. {
  8879. if (points1 != null) points1.ThrowIfDisposed();
  8880. if (points2 != null) points2.ThrowIfDisposed();
  8881. if (cameraMatrix1 != null) cameraMatrix1.ThrowIfDisposed();
  8882. if (distCoeffs1 != null) distCoeffs1.ThrowIfDisposed();
  8883. if (cameraMatrix2 != null) cameraMatrix2.ThrowIfDisposed();
  8884. if (distCoeffs2 != null) distCoeffs2.ThrowIfDisposed();
  8885. if (E != null) E.ThrowIfDisposed();
  8886. if (R != null) R.ThrowIfDisposed();
  8887. if (t != null) t.ThrowIfDisposed();
  8888. return calib3d_Calib3d_recoverPose_12(points1.nativeObj, points2.nativeObj, cameraMatrix1.nativeObj, distCoeffs1.nativeObj, cameraMatrix2.nativeObj, distCoeffs2.nativeObj, E.nativeObj, R.nativeObj, t.nativeObj, method, prob);
  8889. }
  8890. /**
  8891. * Recovers the relative camera rotation and the translation from corresponding points in two images from two different cameras, using cheirality check. Returns the number of
  8892. * inliers that pass the check.
  8893. *
  8894. * param points1 Array of N 2D points from the first image. The point coordinates should be
  8895. * floating-point (single or double precision).
  8896. * param points2 Array of the second image points of the same size and format as points1 .
  8897. * param cameraMatrix1 Input/output camera matrix for the first camera, the same as in
  8898. * REF: calibrateCamera. Furthermore, for the stereo case, additional flags may be used, see below.
  8899. * param distCoeffs1 Input/output vector of distortion coefficients, the same as in
  8900. * REF: calibrateCamera.
  8901. * param cameraMatrix2 Input/output camera matrix for the first camera, the same as in
  8902. * REF: calibrateCamera. Furthermore, for the stereo case, additional flags may be used, see below.
  8903. * param distCoeffs2 Input/output vector of distortion coefficients, the same as in
  8904. * REF: calibrateCamera.
  8905. * param E The output essential matrix.
  8906. * param R Output rotation matrix. Together with the translation vector, this matrix makes up a tuple
  8907. * that performs a change of basis from the first camera's coordinate system to the second camera's
  8908. * coordinate system. Note that, in general, t can not be used for this tuple, see the parameter
  8909. * described below.
  8910. * param t Output translation vector. This vector is obtained by REF: decomposeEssentialMat and
  8911. * therefore is only known up to scale, i.e. t is the direction of the translation vector and has unit
  8912. * length.
  8913. * param method Method for computing an essential matrix.
  8914. * <ul>
  8915. * <li>
  8916. * REF: RANSAC for the RANSAC algorithm.
  8917. * </li>
  8918. * <li>
  8919. * REF: LMEDS for the LMedS algorithm.
  8920. * </li>
  8921. * </ul>
  8922. * confidence (probability) that the estimated matrix is correct.
  8923. * line in pixels, beyond which the point is considered an outlier and is not used for computing the
  8924. * final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
  8925. * point localization, image resolution, and the image noise.
  8926. * inliers in points1 and points2 for then given essential matrix E. Only these inliers will be used to
  8927. * recover pose. In the output mask only inliers which pass the cheirality check.
  8928. *
  8929. * This function decomposes an essential matrix using REF: decomposeEssentialMat and then verifies
  8930. * possible pose hypotheses by doing cheirality check. The cheirality check means that the
  8931. * triangulated 3D points should have positive depth. Some details can be found in CITE: Nister03.
  8932. *
  8933. * This function can be used to process the output E and mask from REF: findEssentialMat. In this
  8934. * scenario, points1 and points2 are the same input for findEssentialMat.:
  8935. * <code>
  8936. * // Example. Estimation of fundamental matrix using the RANSAC algorithm
  8937. * int point_count = 100;
  8938. * vector&lt;Point2f&gt; points1(point_count);
  8939. * vector&lt;Point2f&gt; points2(point_count);
  8940. *
  8941. * // initialize the points here ...
  8942. * for( int i = 0; i &lt; point_count; i++ )
  8943. * {
  8944. * points1[i] = ...;
  8945. * points2[i] = ...;
  8946. * }
  8947. *
  8948. * // Input: camera calibration of both cameras, for example using intrinsic chessboard calibration.
  8949. * Mat cameraMatrix1, distCoeffs1, cameraMatrix2, distCoeffs2;
  8950. *
  8951. * // Output: Essential matrix, relative rotation and relative translation.
  8952. * Mat E, R, t, mask;
  8953. *
  8954. * recoverPose(points1, points2, cameraMatrix1, distCoeffs1, cameraMatrix2, distCoeffs2, E, R, t, mask);
  8955. * </code>
  8956. * return automatically generated
  8957. */
  8958. public static int recoverPose(Mat points1, Mat points2, Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Mat E, Mat R, Mat t, int method)
  8959. {
  8960. if (points1 != null) points1.ThrowIfDisposed();
  8961. if (points2 != null) points2.ThrowIfDisposed();
  8962. if (cameraMatrix1 != null) cameraMatrix1.ThrowIfDisposed();
  8963. if (distCoeffs1 != null) distCoeffs1.ThrowIfDisposed();
  8964. if (cameraMatrix2 != null) cameraMatrix2.ThrowIfDisposed();
  8965. if (distCoeffs2 != null) distCoeffs2.ThrowIfDisposed();
  8966. if (E != null) E.ThrowIfDisposed();
  8967. if (R != null) R.ThrowIfDisposed();
  8968. if (t != null) t.ThrowIfDisposed();
  8969. return calib3d_Calib3d_recoverPose_13(points1.nativeObj, points2.nativeObj, cameraMatrix1.nativeObj, distCoeffs1.nativeObj, cameraMatrix2.nativeObj, distCoeffs2.nativeObj, E.nativeObj, R.nativeObj, t.nativeObj, method);
  8970. }
  8971. /**
  8972. * Recovers the relative camera rotation and the translation from corresponding points in two images from two different cameras, using cheirality check. Returns the number of
  8973. * inliers that pass the check.
  8974. *
  8975. * param points1 Array of N 2D points from the first image. The point coordinates should be
  8976. * floating-point (single or double precision).
  8977. * param points2 Array of the second image points of the same size and format as points1 .
  8978. * param cameraMatrix1 Input/output camera matrix for the first camera, the same as in
  8979. * REF: calibrateCamera. Furthermore, for the stereo case, additional flags may be used, see below.
  8980. * param distCoeffs1 Input/output vector of distortion coefficients, the same as in
  8981. * REF: calibrateCamera.
  8982. * param cameraMatrix2 Input/output camera matrix for the first camera, the same as in
  8983. * REF: calibrateCamera. Furthermore, for the stereo case, additional flags may be used, see below.
  8984. * param distCoeffs2 Input/output vector of distortion coefficients, the same as in
  8985. * REF: calibrateCamera.
  8986. * param E The output essential matrix.
  8987. * param R Output rotation matrix. Together with the translation vector, this matrix makes up a tuple
  8988. * that performs a change of basis from the first camera's coordinate system to the second camera's
  8989. * coordinate system. Note that, in general, t can not be used for this tuple, see the parameter
  8990. * described below.
  8991. * param t Output translation vector. This vector is obtained by REF: decomposeEssentialMat and
  8992. * therefore is only known up to scale, i.e. t is the direction of the translation vector and has unit
  8993. * length.
  8994. * <ul>
  8995. * <li>
  8996. * REF: RANSAC for the RANSAC algorithm.
  8997. * </li>
  8998. * <li>
  8999. * REF: LMEDS for the LMedS algorithm.
  9000. * </li>
  9001. * </ul>
  9002. * confidence (probability) that the estimated matrix is correct.
  9003. * line in pixels, beyond which the point is considered an outlier and is not used for computing the
  9004. * final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
  9005. * point localization, image resolution, and the image noise.
  9006. * inliers in points1 and points2 for then given essential matrix E. Only these inliers will be used to
  9007. * recover pose. In the output mask only inliers which pass the cheirality check.
  9008. *
  9009. * This function decomposes an essential matrix using REF: decomposeEssentialMat and then verifies
  9010. * possible pose hypotheses by doing cheirality check. The cheirality check means that the
  9011. * triangulated 3D points should have positive depth. Some details can be found in CITE: Nister03.
  9012. *
  9013. * This function can be used to process the output E and mask from REF: findEssentialMat. In this
  9014. * scenario, points1 and points2 are the same input for findEssentialMat.:
  9015. * <code>
  9016. * // Example. Estimation of fundamental matrix using the RANSAC algorithm
  9017. * int point_count = 100;
  9018. * vector&lt;Point2f&gt; points1(point_count);
  9019. * vector&lt;Point2f&gt; points2(point_count);
  9020. *
  9021. * // initialize the points here ...
  9022. * for( int i = 0; i &lt; point_count; i++ )
  9023. * {
  9024. * points1[i] = ...;
  9025. * points2[i] = ...;
  9026. * }
  9027. *
  9028. * // Input: camera calibration of both cameras, for example using intrinsic chessboard calibration.
  9029. * Mat cameraMatrix1, distCoeffs1, cameraMatrix2, distCoeffs2;
  9030. *
  9031. * // Output: Essential matrix, relative rotation and relative translation.
  9032. * Mat E, R, t, mask;
  9033. *
  9034. * recoverPose(points1, points2, cameraMatrix1, distCoeffs1, cameraMatrix2, distCoeffs2, E, R, t, mask);
  9035. * </code>
  9036. * return automatically generated
  9037. */
  9038. public static int recoverPose(Mat points1, Mat points2, Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Mat E, Mat R, Mat t)
  9039. {
  9040. if (points1 != null) points1.ThrowIfDisposed();
  9041. if (points2 != null) points2.ThrowIfDisposed();
  9042. if (cameraMatrix1 != null) cameraMatrix1.ThrowIfDisposed();
  9043. if (distCoeffs1 != null) distCoeffs1.ThrowIfDisposed();
  9044. if (cameraMatrix2 != null) cameraMatrix2.ThrowIfDisposed();
  9045. if (distCoeffs2 != null) distCoeffs2.ThrowIfDisposed();
  9046. if (E != null) E.ThrowIfDisposed();
  9047. if (R != null) R.ThrowIfDisposed();
  9048. if (t != null) t.ThrowIfDisposed();
  9049. return calib3d_Calib3d_recoverPose_14(points1.nativeObj, points2.nativeObj, cameraMatrix1.nativeObj, distCoeffs1.nativeObj, cameraMatrix2.nativeObj, distCoeffs2.nativeObj, E.nativeObj, R.nativeObj, t.nativeObj);
  9050. }
  9051. //
  9052. // C++: int cv::recoverPose(Mat E, Mat points1, Mat points2, Mat cameraMatrix, Mat& R, Mat& t, Mat& mask = Mat())
  9053. //
  9054. /**
  9055. * Recovers the relative camera rotation and the translation from an estimated essential
  9056. * matrix and the corresponding points in two images, using chirality check. Returns the number of
  9057. * inliers that pass the check.
  9058. *
  9059. * param E The input essential matrix.
  9060. * param points1 Array of N 2D points from the first image. The point coordinates should be
  9061. * floating-point (single or double precision).
  9062. * param points2 Array of the second image points of the same size and format as points1 .
  9063. * param cameraMatrix Camera intrinsic matrix \(\cameramatrix{A}\) .
  9064. * Note that this function assumes that points1 and points2 are feature points from cameras with the
  9065. * same camera intrinsic matrix.
  9066. * param R Output rotation matrix. Together with the translation vector, this matrix makes up a tuple
  9067. * that performs a change of basis from the first camera's coordinate system to the second camera's
  9068. * coordinate system. Note that, in general, t can not be used for this tuple, see the parameter
  9069. * described below.
  9070. * param t Output translation vector. This vector is obtained by REF: decomposeEssentialMat and
  9071. * therefore is only known up to scale, i.e. t is the direction of the translation vector and has unit
  9072. * length.
  9073. * param mask Input/output mask for inliers in points1 and points2. If it is not empty, then it marks
  9074. * inliers in points1 and points2 for the given essential matrix E. Only these inliers will be used to
  9075. * recover pose. In the output mask only inliers which pass the chirality check.
  9076. *
  9077. * This function decomposes an essential matrix using REF: decomposeEssentialMat and then verifies
  9078. * possible pose hypotheses by doing chirality check. The chirality check means that the
  9079. * triangulated 3D points should have positive depth. Some details can be found in CITE: Nister03.
  9080. *
  9081. * This function can be used to process the output E and mask from REF: findEssentialMat. In this
  9082. * scenario, points1 and points2 are the same input for #findEssentialMat :
  9083. * <code>
  9084. * // Example. Estimation of fundamental matrix using the RANSAC algorithm
  9085. * int point_count = 100;
  9086. * vector&lt;Point2f&gt; points1(point_count);
  9087. * vector&lt;Point2f&gt; points2(point_count);
  9088. *
  9089. * // initialize the points here ...
  9090. * for( int i = 0; i &lt; point_count; i++ )
  9091. * {
  9092. * points1[i] = ...;
  9093. * points2[i] = ...;
  9094. * }
  9095. *
  9096. * // cametra matrix with both focal lengths = 1, and principal point = (0, 0)
  9097. * Mat cameraMatrix = Mat::eye(3, 3, CV_64F);
  9098. *
  9099. * Mat E, R, t, mask;
  9100. *
  9101. * E = findEssentialMat(points1, points2, cameraMatrix, RANSAC, 0.999, 1.0, mask);
  9102. * recoverPose(E, points1, points2, cameraMatrix, R, t, mask);
  9103. * </code>
  9104. * return automatically generated
  9105. */
  9106. public static int recoverPose(Mat E, Mat points1, Mat points2, Mat cameraMatrix, Mat R, Mat t, Mat mask)
  9107. {
  9108. if (E != null) E.ThrowIfDisposed();
  9109. if (points1 != null) points1.ThrowIfDisposed();
  9110. if (points2 != null) points2.ThrowIfDisposed();
  9111. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  9112. if (R != null) R.ThrowIfDisposed();
  9113. if (t != null) t.ThrowIfDisposed();
  9114. if (mask != null) mask.ThrowIfDisposed();
  9115. return calib3d_Calib3d_recoverPose_15(E.nativeObj, points1.nativeObj, points2.nativeObj, cameraMatrix.nativeObj, R.nativeObj, t.nativeObj, mask.nativeObj);
  9116. }
  9117. /**
  9118. * Recovers the relative camera rotation and the translation from an estimated essential
  9119. * matrix and the corresponding points in two images, using chirality check. Returns the number of
  9120. * inliers that pass the check.
  9121. *
  9122. * param E The input essential matrix.
  9123. * param points1 Array of N 2D points from the first image. The point coordinates should be
  9124. * floating-point (single or double precision).
  9125. * param points2 Array of the second image points of the same size and format as points1 .
  9126. * param cameraMatrix Camera intrinsic matrix \(\cameramatrix{A}\) .
  9127. * Note that this function assumes that points1 and points2 are feature points from cameras with the
  9128. * same camera intrinsic matrix.
  9129. * param R Output rotation matrix. Together with the translation vector, this matrix makes up a tuple
  9130. * that performs a change of basis from the first camera's coordinate system to the second camera's
  9131. * coordinate system. Note that, in general, t can not be used for this tuple, see the parameter
  9132. * described below.
  9133. * param t Output translation vector. This vector is obtained by REF: decomposeEssentialMat and
  9134. * therefore is only known up to scale, i.e. t is the direction of the translation vector and has unit
  9135. * length.
  9136. * inliers in points1 and points2 for the given essential matrix E. Only these inliers will be used to
  9137. * recover pose. In the output mask only inliers which pass the chirality check.
  9138. *
  9139. * This function decomposes an essential matrix using REF: decomposeEssentialMat and then verifies
  9140. * possible pose hypotheses by doing chirality check. The chirality check means that the
  9141. * triangulated 3D points should have positive depth. Some details can be found in CITE: Nister03.
  9142. *
  9143. * This function can be used to process the output E and mask from REF: findEssentialMat. In this
  9144. * scenario, points1 and points2 are the same input for #findEssentialMat :
  9145. * <code>
  9146. * // Example. Estimation of fundamental matrix using the RANSAC algorithm
  9147. * int point_count = 100;
  9148. * vector&lt;Point2f&gt; points1(point_count);
  9149. * vector&lt;Point2f&gt; points2(point_count);
  9150. *
  9151. * // initialize the points here ...
  9152. * for( int i = 0; i &lt; point_count; i++ )
  9153. * {
  9154. * points1[i] = ...;
  9155. * points2[i] = ...;
  9156. * }
  9157. *
  9158. * // cametra matrix with both focal lengths = 1, and principal point = (0, 0)
  9159. * Mat cameraMatrix = Mat::eye(3, 3, CV_64F);
  9160. *
  9161. * Mat E, R, t, mask;
  9162. *
  9163. * E = findEssentialMat(points1, points2, cameraMatrix, RANSAC, 0.999, 1.0, mask);
  9164. * recoverPose(E, points1, points2, cameraMatrix, R, t, mask);
  9165. * </code>
  9166. * return automatically generated
  9167. */
  9168. public static int recoverPose(Mat E, Mat points1, Mat points2, Mat cameraMatrix, Mat R, Mat t)
  9169. {
  9170. if (E != null) E.ThrowIfDisposed();
  9171. if (points1 != null) points1.ThrowIfDisposed();
  9172. if (points2 != null) points2.ThrowIfDisposed();
  9173. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  9174. if (R != null) R.ThrowIfDisposed();
  9175. if (t != null) t.ThrowIfDisposed();
  9176. return calib3d_Calib3d_recoverPose_16(E.nativeObj, points1.nativeObj, points2.nativeObj, cameraMatrix.nativeObj, R.nativeObj, t.nativeObj);
  9177. }
  9178. //
  9179. // C++: int cv::recoverPose(Mat E, Mat points1, Mat points2, Mat& R, Mat& t, double focal = 1.0, Point2d pp = Point2d(0, 0), Mat& mask = Mat())
  9180. //
  9181. /**
  9182. *
  9183. * param E The input essential matrix.
  9184. * param points1 Array of N 2D points from the first image. The point coordinates should be
  9185. * floating-point (single or double precision).
  9186. * param points2 Array of the second image points of the same size and format as points1 .
  9187. * param R Output rotation matrix. Together with the translation vector, this matrix makes up a tuple
  9188. * that performs a change of basis from the first camera's coordinate system to the second camera's
  9189. * coordinate system. Note that, in general, t can not be used for this tuple, see the parameter
  9190. * description below.
  9191. * param t Output translation vector. This vector is obtained by REF: decomposeEssentialMat and
  9192. * therefore is only known up to scale, i.e. t is the direction of the translation vector and has unit
  9193. * length.
  9194. * param focal Focal length of the camera. Note that this function assumes that points1 and points2
  9195. * are feature points from cameras with same focal length and principal point.
  9196. * param pp principal point of the camera.
  9197. * param mask Input/output mask for inliers in points1 and points2. If it is not empty, then it marks
  9198. * inliers in points1 and points2 for the given essential matrix E. Only these inliers will be used to
  9199. * recover pose. In the output mask only inliers which pass the chirality check.
  9200. *
  9201. * This function differs from the one above that it computes camera intrinsic matrix from focal length and
  9202. * principal point:
  9203. *
  9204. * \(A =
  9205. * \begin{bmatrix}
  9206. * f &amp; 0 &amp; x_{pp} \\
  9207. * 0 &amp; f &amp; y_{pp} \\
  9208. * 0 &amp; 0 &amp; 1
  9209. * \end{bmatrix}\)
  9210. * return automatically generated
  9211. */
  9212. public static int recoverPose(Mat E, Mat points1, Mat points2, Mat R, Mat t, double focal, Point pp, Mat mask)
  9213. {
  9214. if (E != null) E.ThrowIfDisposed();
  9215. if (points1 != null) points1.ThrowIfDisposed();
  9216. if (points2 != null) points2.ThrowIfDisposed();
  9217. if (R != null) R.ThrowIfDisposed();
  9218. if (t != null) t.ThrowIfDisposed();
  9219. if (mask != null) mask.ThrowIfDisposed();
  9220. return calib3d_Calib3d_recoverPose_17(E.nativeObj, points1.nativeObj, points2.nativeObj, R.nativeObj, t.nativeObj, focal, pp.x, pp.y, mask.nativeObj);
  9221. }
  9222. /**
  9223. *
  9224. * param E The input essential matrix.
  9225. * param points1 Array of N 2D points from the first image. The point coordinates should be
  9226. * floating-point (single or double precision).
  9227. * param points2 Array of the second image points of the same size and format as points1 .
  9228. * param R Output rotation matrix. Together with the translation vector, this matrix makes up a tuple
  9229. * that performs a change of basis from the first camera's coordinate system to the second camera's
  9230. * coordinate system. Note that, in general, t can not be used for this tuple, see the parameter
  9231. * description below.
  9232. * param t Output translation vector. This vector is obtained by REF: decomposeEssentialMat and
  9233. * therefore is only known up to scale, i.e. t is the direction of the translation vector and has unit
  9234. * length.
  9235. * param focal Focal length of the camera. Note that this function assumes that points1 and points2
  9236. * are feature points from cameras with same focal length and principal point.
  9237. * param pp principal point of the camera.
  9238. * inliers in points1 and points2 for the given essential matrix E. Only these inliers will be used to
  9239. * recover pose. In the output mask only inliers which pass the chirality check.
  9240. *
  9241. * This function differs from the one above that it computes camera intrinsic matrix from focal length and
  9242. * principal point:
  9243. *
  9244. * \(A =
  9245. * \begin{bmatrix}
  9246. * f &amp; 0 &amp; x_{pp} \\
  9247. * 0 &amp; f &amp; y_{pp} \\
  9248. * 0 &amp; 0 &amp; 1
  9249. * \end{bmatrix}\)
  9250. * return automatically generated
  9251. */
  9252. public static int recoverPose(Mat E, Mat points1, Mat points2, Mat R, Mat t, double focal, Point pp)
  9253. {
  9254. if (E != null) E.ThrowIfDisposed();
  9255. if (points1 != null) points1.ThrowIfDisposed();
  9256. if (points2 != null) points2.ThrowIfDisposed();
  9257. if (R != null) R.ThrowIfDisposed();
  9258. if (t != null) t.ThrowIfDisposed();
  9259. return calib3d_Calib3d_recoverPose_18(E.nativeObj, points1.nativeObj, points2.nativeObj, R.nativeObj, t.nativeObj, focal, pp.x, pp.y);
  9260. }
  9261. /**
  9262. *
  9263. * param E The input essential matrix.
  9264. * param points1 Array of N 2D points from the first image. The point coordinates should be
  9265. * floating-point (single or double precision).
  9266. * param points2 Array of the second image points of the same size and format as points1 .
  9267. * param R Output rotation matrix. Together with the translation vector, this matrix makes up a tuple
  9268. * that performs a change of basis from the first camera's coordinate system to the second camera's
  9269. * coordinate system. Note that, in general, t can not be used for this tuple, see the parameter
  9270. * description below.
  9271. * param t Output translation vector. This vector is obtained by REF: decomposeEssentialMat and
  9272. * therefore is only known up to scale, i.e. t is the direction of the translation vector and has unit
  9273. * length.
  9274. * param focal Focal length of the camera. Note that this function assumes that points1 and points2
  9275. * are feature points from cameras with same focal length and principal point.
  9276. * inliers in points1 and points2 for the given essential matrix E. Only these inliers will be used to
  9277. * recover pose. In the output mask only inliers which pass the chirality check.
  9278. *
  9279. * This function differs from the one above that it computes camera intrinsic matrix from focal length and
  9280. * principal point:
  9281. *
  9282. * \(A =
  9283. * \begin{bmatrix}
  9284. * f &amp; 0 &amp; x_{pp} \\
  9285. * 0 &amp; f &amp; y_{pp} \\
  9286. * 0 &amp; 0 &amp; 1
  9287. * \end{bmatrix}\)
  9288. * return automatically generated
  9289. */
  9290. public static int recoverPose(Mat E, Mat points1, Mat points2, Mat R, Mat t, double focal)
  9291. {
  9292. if (E != null) E.ThrowIfDisposed();
  9293. if (points1 != null) points1.ThrowIfDisposed();
  9294. if (points2 != null) points2.ThrowIfDisposed();
  9295. if (R != null) R.ThrowIfDisposed();
  9296. if (t != null) t.ThrowIfDisposed();
  9297. return calib3d_Calib3d_recoverPose_19(E.nativeObj, points1.nativeObj, points2.nativeObj, R.nativeObj, t.nativeObj, focal);
  9298. }
  9299. /**
  9300. *
  9301. * param E The input essential matrix.
  9302. * param points1 Array of N 2D points from the first image. The point coordinates should be
  9303. * floating-point (single or double precision).
  9304. * param points2 Array of the second image points of the same size and format as points1 .
  9305. * param R Output rotation matrix. Together with the translation vector, this matrix makes up a tuple
  9306. * that performs a change of basis from the first camera's coordinate system to the second camera's
  9307. * coordinate system. Note that, in general, t can not be used for this tuple, see the parameter
  9308. * description below.
  9309. * param t Output translation vector. This vector is obtained by REF: decomposeEssentialMat and
  9310. * therefore is only known up to scale, i.e. t is the direction of the translation vector and has unit
  9311. * length.
  9312. * are feature points from cameras with same focal length and principal point.
  9313. * inliers in points1 and points2 for the given essential matrix E. Only these inliers will be used to
  9314. * recover pose. In the output mask only inliers which pass the chirality check.
  9315. *
  9316. * This function differs from the one above that it computes camera intrinsic matrix from focal length and
  9317. * principal point:
  9318. *
  9319. * \(A =
  9320. * \begin{bmatrix}
  9321. * f &amp; 0 &amp; x_{pp} \\
  9322. * 0 &amp; f &amp; y_{pp} \\
  9323. * 0 &amp; 0 &amp; 1
  9324. * \end{bmatrix}\)
  9325. * return automatically generated
  9326. */
  9327. public static int recoverPose(Mat E, Mat points1, Mat points2, Mat R, Mat t)
  9328. {
  9329. if (E != null) E.ThrowIfDisposed();
  9330. if (points1 != null) points1.ThrowIfDisposed();
  9331. if (points2 != null) points2.ThrowIfDisposed();
  9332. if (R != null) R.ThrowIfDisposed();
  9333. if (t != null) t.ThrowIfDisposed();
  9334. return calib3d_Calib3d_recoverPose_110(E.nativeObj, points1.nativeObj, points2.nativeObj, R.nativeObj, t.nativeObj);
  9335. }
  9336. //
  9337. // C++: int cv::recoverPose(Mat E, Mat points1, Mat points2, Mat cameraMatrix, Mat& R, Mat& t, double distanceThresh, Mat& mask = Mat(), Mat& triangulatedPoints = Mat())
  9338. //
  9339. /**
  9340. *
  9341. * param E The input essential matrix.
  9342. * param points1 Array of N 2D points from the first image. The point coordinates should be
  9343. * floating-point (single or double precision).
  9344. * param points2 Array of the second image points of the same size and format as points1.
  9345. * param cameraMatrix Camera intrinsic matrix \(\cameramatrix{A}\) .
  9346. * Note that this function assumes that points1 and points2 are feature points from cameras with the
  9347. * same camera intrinsic matrix.
  9348. * param R Output rotation matrix. Together with the translation vector, this matrix makes up a tuple
  9349. * that performs a change of basis from the first camera's coordinate system to the second camera's
  9350. * coordinate system. Note that, in general, t can not be used for this tuple, see the parameter
  9351. * description below.
  9352. * param t Output translation vector. This vector is obtained by REF: decomposeEssentialMat and
  9353. * therefore is only known up to scale, i.e. t is the direction of the translation vector and has unit
  9354. * length.
  9355. * param distanceThresh threshold distance which is used to filter out far away points (i.e. infinite
  9356. * points).
  9357. * param mask Input/output mask for inliers in points1 and points2. If it is not empty, then it marks
  9358. * inliers in points1 and points2 for the given essential matrix E. Only these inliers will be used to
  9359. * recover pose. In the output mask only inliers which pass the chirality check.
  9360. * param triangulatedPoints 3D points which were reconstructed by triangulation.
  9361. *
  9362. * This function differs from the one above that it outputs the triangulated 3D point that are used for
  9363. * the chirality check.
  9364. * return automatically generated
  9365. */
  9366. public static int recoverPose(Mat E, Mat points1, Mat points2, Mat cameraMatrix, Mat R, Mat t, double distanceThresh, Mat mask, Mat triangulatedPoints)
  9367. {
  9368. if (E != null) E.ThrowIfDisposed();
  9369. if (points1 != null) points1.ThrowIfDisposed();
  9370. if (points2 != null) points2.ThrowIfDisposed();
  9371. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  9372. if (R != null) R.ThrowIfDisposed();
  9373. if (t != null) t.ThrowIfDisposed();
  9374. if (mask != null) mask.ThrowIfDisposed();
  9375. if (triangulatedPoints != null) triangulatedPoints.ThrowIfDisposed();
  9376. return calib3d_Calib3d_recoverPose_111(E.nativeObj, points1.nativeObj, points2.nativeObj, cameraMatrix.nativeObj, R.nativeObj, t.nativeObj, distanceThresh, mask.nativeObj, triangulatedPoints.nativeObj);
  9377. }
  9378. /**
  9379. *
  9380. * param E The input essential matrix.
  9381. * param points1 Array of N 2D points from the first image. The point coordinates should be
  9382. * floating-point (single or double precision).
  9383. * param points2 Array of the second image points of the same size and format as points1.
  9384. * param cameraMatrix Camera intrinsic matrix \(\cameramatrix{A}\) .
  9385. * Note that this function assumes that points1 and points2 are feature points from cameras with the
  9386. * same camera intrinsic matrix.
  9387. * param R Output rotation matrix. Together with the translation vector, this matrix makes up a tuple
  9388. * that performs a change of basis from the first camera's coordinate system to the second camera's
  9389. * coordinate system. Note that, in general, t can not be used for this tuple, see the parameter
  9390. * description below.
  9391. * param t Output translation vector. This vector is obtained by REF: decomposeEssentialMat and
  9392. * therefore is only known up to scale, i.e. t is the direction of the translation vector and has unit
  9393. * length.
  9394. * param distanceThresh threshold distance which is used to filter out far away points (i.e. infinite
  9395. * points).
  9396. * param mask Input/output mask for inliers in points1 and points2. If it is not empty, then it marks
  9397. * inliers in points1 and points2 for the given essential matrix E. Only these inliers will be used to
  9398. * recover pose. In the output mask only inliers which pass the chirality check.
  9399. *
  9400. * This function differs from the one above that it outputs the triangulated 3D point that are used for
  9401. * the chirality check.
  9402. * return automatically generated
  9403. */
  9404. public static int recoverPose(Mat E, Mat points1, Mat points2, Mat cameraMatrix, Mat R, Mat t, double distanceThresh, Mat mask)
  9405. {
  9406. if (E != null) E.ThrowIfDisposed();
  9407. if (points1 != null) points1.ThrowIfDisposed();
  9408. if (points2 != null) points2.ThrowIfDisposed();
  9409. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  9410. if (R != null) R.ThrowIfDisposed();
  9411. if (t != null) t.ThrowIfDisposed();
  9412. if (mask != null) mask.ThrowIfDisposed();
  9413. return calib3d_Calib3d_recoverPose_112(E.nativeObj, points1.nativeObj, points2.nativeObj, cameraMatrix.nativeObj, R.nativeObj, t.nativeObj, distanceThresh, mask.nativeObj);
  9414. }
  9415. /**
  9416. *
  9417. * param E The input essential matrix.
  9418. * param points1 Array of N 2D points from the first image. The point coordinates should be
  9419. * floating-point (single or double precision).
  9420. * param points2 Array of the second image points of the same size and format as points1.
  9421. * param cameraMatrix Camera intrinsic matrix \(\cameramatrix{A}\) .
  9422. * Note that this function assumes that points1 and points2 are feature points from cameras with the
  9423. * same camera intrinsic matrix.
  9424. * param R Output rotation matrix. Together with the translation vector, this matrix makes up a tuple
  9425. * that performs a change of basis from the first camera's coordinate system to the second camera's
  9426. * coordinate system. Note that, in general, t can not be used for this tuple, see the parameter
  9427. * description below.
  9428. * param t Output translation vector. This vector is obtained by REF: decomposeEssentialMat and
  9429. * therefore is only known up to scale, i.e. t is the direction of the translation vector and has unit
  9430. * length.
  9431. * param distanceThresh threshold distance which is used to filter out far away points (i.e. infinite
  9432. * points).
  9433. * inliers in points1 and points2 for the given essential matrix E. Only these inliers will be used to
  9434. * recover pose. In the output mask only inliers which pass the chirality check.
  9435. *
  9436. * This function differs from the one above that it outputs the triangulated 3D point that are used for
  9437. * the chirality check.
  9438. * return automatically generated
  9439. */
  9440. public static int recoverPose(Mat E, Mat points1, Mat points2, Mat cameraMatrix, Mat R, Mat t, double distanceThresh)
  9441. {
  9442. if (E != null) E.ThrowIfDisposed();
  9443. if (points1 != null) points1.ThrowIfDisposed();
  9444. if (points2 != null) points2.ThrowIfDisposed();
  9445. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  9446. if (R != null) R.ThrowIfDisposed();
  9447. if (t != null) t.ThrowIfDisposed();
  9448. return calib3d_Calib3d_recoverPose_113(E.nativeObj, points1.nativeObj, points2.nativeObj, cameraMatrix.nativeObj, R.nativeObj, t.nativeObj, distanceThresh);
  9449. }
  9450. //
  9451. // C++: void cv::computeCorrespondEpilines(Mat points, int whichImage, Mat F, Mat& lines)
  9452. //
  9453. /**
  9454. * For points in an image of a stereo pair, computes the corresponding epilines in the other image.
  9455. *
  9456. * param points Input points. \(N \times 1\) or \(1 \times N\) matrix of type CV_32FC2 or
  9457. * vector&lt;Point2f&gt; .
  9458. * param whichImage Index of the image (1 or 2) that contains the points .
  9459. * param F Fundamental matrix that can be estimated using #findFundamentalMat or #stereoRectify .
  9460. * param lines Output vector of the epipolar lines corresponding to the points in the other image.
  9461. * Each line \(ax + by + c=0\) is encoded by 3 numbers \((a, b, c)\) .
  9462. *
  9463. * For every point in one of the two images of a stereo pair, the function finds the equation of the
  9464. * corresponding epipolar line in the other image.
  9465. *
  9466. * From the fundamental matrix definition (see #findFundamentalMat ), line \(l^{(2)}_i\) in the second
  9467. * image for the point \(p^{(1)}_i\) in the first image (when whichImage=1 ) is computed as:
  9468. *
  9469. * \(l^{(2)}_i = F p^{(1)}_i\)
  9470. *
  9471. * And vice versa, when whichImage=2, \(l^{(1)}_i\) is computed from \(p^{(2)}_i\) as:
  9472. *
  9473. * \(l^{(1)}_i = F^T p^{(2)}_i\)
  9474. *
  9475. * Line coefficients are defined up to a scale. They are normalized so that \(a_i^2+b_i^2=1\) .
  9476. */
  9477. public static void computeCorrespondEpilines(Mat points, int whichImage, Mat F, Mat lines)
  9478. {
  9479. if (points != null) points.ThrowIfDisposed();
  9480. if (F != null) F.ThrowIfDisposed();
  9481. if (lines != null) lines.ThrowIfDisposed();
  9482. calib3d_Calib3d_computeCorrespondEpilines_10(points.nativeObj, whichImage, F.nativeObj, lines.nativeObj);
  9483. }
  9484. //
  9485. // C++: void cv::triangulatePoints(Mat projMatr1, Mat projMatr2, Mat projPoints1, Mat projPoints2, Mat& points4D)
  9486. //
  9487. /**
  9488. * This function reconstructs 3-dimensional points (in homogeneous coordinates) by using
  9489. * their observations with a stereo camera.
  9490. *
  9491. * param projMatr1 3x4 projection matrix of the first camera, i.e. this matrix projects 3D points
  9492. * given in the world's coordinate system into the first image.
  9493. * param projMatr2 3x4 projection matrix of the second camera, i.e. this matrix projects 3D points
  9494. * given in the world's coordinate system into the second image.
  9495. * param projPoints1 2xN array of feature points in the first image. In the case of the c++ version,
  9496. * it can be also a vector of feature points or two-channel matrix of size 1xN or Nx1.
  9497. * param projPoints2 2xN array of corresponding points in the second image. In the case of the c++
  9498. * version, it can be also a vector of feature points or two-channel matrix of size 1xN or Nx1.
  9499. * param points4D 4xN array of reconstructed points in homogeneous coordinates. These points are
  9500. * returned in the world's coordinate system.
  9501. *
  9502. * <b>Note:</b>
  9503. * Keep in mind that all input data should be of float type in order for this function to work.
  9504. *
  9505. * <b>Note:</b>
  9506. * If the projection matrices from REF: stereoRectify are used, then the returned points are
  9507. * represented in the first camera's rectified coordinate system.
  9508. *
  9509. * SEE:
  9510. * reprojectImageTo3D
  9511. */
  9512. public static void triangulatePoints(Mat projMatr1, Mat projMatr2, Mat projPoints1, Mat projPoints2, Mat points4D)
  9513. {
  9514. if (projMatr1 != null) projMatr1.ThrowIfDisposed();
  9515. if (projMatr2 != null) projMatr2.ThrowIfDisposed();
  9516. if (projPoints1 != null) projPoints1.ThrowIfDisposed();
  9517. if (projPoints2 != null) projPoints2.ThrowIfDisposed();
  9518. if (points4D != null) points4D.ThrowIfDisposed();
  9519. calib3d_Calib3d_triangulatePoints_10(projMatr1.nativeObj, projMatr2.nativeObj, projPoints1.nativeObj, projPoints2.nativeObj, points4D.nativeObj);
  9520. }
  9521. //
  9522. // C++: void cv::correctMatches(Mat F, Mat points1, Mat points2, Mat& newPoints1, Mat& newPoints2)
  9523. //
  9524. /**
  9525. * Refines coordinates of corresponding points.
  9526. *
  9527. * param F 3x3 fundamental matrix.
  9528. * param points1 1xN array containing the first set of points.
  9529. * param points2 1xN array containing the second set of points.
  9530. * param newPoints1 The optimized points1.
  9531. * param newPoints2 The optimized points2.
  9532. *
  9533. * The function implements the Optimal Triangulation Method (see Multiple View Geometry CITE: HartleyZ00 for details).
  9534. * For each given point correspondence points1[i] &lt;-&gt; points2[i], and a fundamental matrix F, it
  9535. * computes the corrected correspondences newPoints1[i] &lt;-&gt; newPoints2[i] that minimize the geometric
  9536. * error \(d(points1[i], newPoints1[i])^2 + d(points2[i],newPoints2[i])^2\) (where \(d(a,b)\) is the
  9537. * geometric distance between points \(a\) and \(b\) ) subject to the epipolar constraint
  9538. * \(newPoints2^T \cdot F \cdot newPoints1 = 0\) .
  9539. */
  9540. public static void correctMatches(Mat F, Mat points1, Mat points2, Mat newPoints1, Mat newPoints2)
  9541. {
  9542. if (F != null) F.ThrowIfDisposed();
  9543. if (points1 != null) points1.ThrowIfDisposed();
  9544. if (points2 != null) points2.ThrowIfDisposed();
  9545. if (newPoints1 != null) newPoints1.ThrowIfDisposed();
  9546. if (newPoints2 != null) newPoints2.ThrowIfDisposed();
  9547. calib3d_Calib3d_correctMatches_10(F.nativeObj, points1.nativeObj, points2.nativeObj, newPoints1.nativeObj, newPoints2.nativeObj);
  9548. }
  9549. //
  9550. // C++: void cv::filterSpeckles(Mat& img, double newVal, int maxSpeckleSize, double maxDiff, Mat& buf = Mat())
  9551. //
  9552. /**
  9553. * Filters off small noise blobs (speckles) in the disparity map
  9554. *
  9555. * param img The input 16-bit signed disparity image
  9556. * param newVal The disparity value used to paint-off the speckles
  9557. * param maxSpeckleSize The maximum speckle size to consider it a speckle. Larger blobs are not
  9558. * affected by the algorithm
  9559. * param maxDiff Maximum difference between neighbor disparity pixels to put them into the same
  9560. * blob. Note that since StereoBM, StereoSGBM and may be other algorithms return a fixed-point
  9561. * disparity map, where disparity values are multiplied by 16, this scale factor should be taken into
  9562. * account when specifying this parameter value.
  9563. * param buf The optional temporary buffer to avoid memory allocation within the function.
  9564. */
  9565. public static void filterSpeckles(Mat img, double newVal, int maxSpeckleSize, double maxDiff, Mat buf)
  9566. {
  9567. if (img != null) img.ThrowIfDisposed();
  9568. if (buf != null) buf.ThrowIfDisposed();
  9569. calib3d_Calib3d_filterSpeckles_10(img.nativeObj, newVal, maxSpeckleSize, maxDiff, buf.nativeObj);
  9570. }
  9571. /**
  9572. * Filters off small noise blobs (speckles) in the disparity map
  9573. *
  9574. * param img The input 16-bit signed disparity image
  9575. * param newVal The disparity value used to paint-off the speckles
  9576. * param maxSpeckleSize The maximum speckle size to consider it a speckle. Larger blobs are not
  9577. * affected by the algorithm
  9578. * param maxDiff Maximum difference between neighbor disparity pixels to put them into the same
  9579. * blob. Note that since StereoBM, StereoSGBM and may be other algorithms return a fixed-point
  9580. * disparity map, where disparity values are multiplied by 16, this scale factor should be taken into
  9581. * account when specifying this parameter value.
  9582. */
  9583. public static void filterSpeckles(Mat img, double newVal, int maxSpeckleSize, double maxDiff)
  9584. {
  9585. if (img != null) img.ThrowIfDisposed();
  9586. calib3d_Calib3d_filterSpeckles_11(img.nativeObj, newVal, maxSpeckleSize, maxDiff);
  9587. }
  9588. //
  9589. // C++: Rect cv::getValidDisparityROI(Rect roi1, Rect roi2, int minDisparity, int numberOfDisparities, int blockSize)
  9590. //
  9591. public static Rect getValidDisparityROI(Rect roi1, Rect roi2, int minDisparity, int numberOfDisparities, int blockSize)
  9592. {
  9593. double[] tmpArray = new double[4];
  9594. calib3d_Calib3d_getValidDisparityROI_10(roi1.x, roi1.y, roi1.width, roi1.height, roi2.x, roi2.y, roi2.width, roi2.height, minDisparity, numberOfDisparities, blockSize, tmpArray);
  9595. Rect retVal = new Rect(tmpArray);
  9596. return retVal;
  9597. }
  9598. //
  9599. // C++: void cv::validateDisparity(Mat& disparity, Mat cost, int minDisparity, int numberOfDisparities, int disp12MaxDisp = 1)
  9600. //
  9601. public static void validateDisparity(Mat disparity, Mat cost, int minDisparity, int numberOfDisparities, int disp12MaxDisp)
  9602. {
  9603. if (disparity != null) disparity.ThrowIfDisposed();
  9604. if (cost != null) cost.ThrowIfDisposed();
  9605. calib3d_Calib3d_validateDisparity_10(disparity.nativeObj, cost.nativeObj, minDisparity, numberOfDisparities, disp12MaxDisp);
  9606. }
  9607. public static void validateDisparity(Mat disparity, Mat cost, int minDisparity, int numberOfDisparities)
  9608. {
  9609. if (disparity != null) disparity.ThrowIfDisposed();
  9610. if (cost != null) cost.ThrowIfDisposed();
  9611. calib3d_Calib3d_validateDisparity_11(disparity.nativeObj, cost.nativeObj, minDisparity, numberOfDisparities);
  9612. }
  9613. //
  9614. // C++: void cv::reprojectImageTo3D(Mat disparity, Mat& _3dImage, Mat Q, bool handleMissingValues = false, int ddepth = -1)
  9615. //
  9616. /**
  9617. * Reprojects a disparity image to 3D space.
  9618. *
  9619. * param disparity Input single-channel 8-bit unsigned, 16-bit signed, 32-bit signed or 32-bit
  9620. * floating-point disparity image. The values of 8-bit / 16-bit signed formats are assumed to have no
  9621. * fractional bits. If the disparity is 16-bit signed format, as computed by REF: StereoBM or
  9622. * REF: StereoSGBM and maybe other algorithms, it should be divided by 16 (and scaled to float) before
  9623. * being used here.
  9624. * param _3dImage Output 3-channel floating-point image of the same size as disparity. Each element of
  9625. * _3dImage(x,y) contains 3D coordinates of the point (x,y) computed from the disparity map. If one
  9626. * uses Q obtained by REF: stereoRectify, then the returned points are represented in the first
  9627. * camera's rectified coordinate system.
  9628. * param Q \(4 \times 4\) perspective transformation matrix that can be obtained with
  9629. * REF: stereoRectify.
  9630. * param handleMissingValues Indicates, whether the function should handle missing values (i.e.
  9631. * points where the disparity was not computed). If handleMissingValues=true, then pixels with the
  9632. * minimal disparity that corresponds to the outliers (see StereoMatcher::compute ) are transformed
  9633. * to 3D points with a very large Z value (currently set to 10000).
  9634. * param ddepth The optional output array depth. If it is -1, the output image will have CV_32F
  9635. * depth. ddepth can also be set to CV_16S, CV_32S or CV_32F.
  9636. *
  9637. * The function transforms a single-channel disparity map to a 3-channel image representing a 3D
  9638. * surface. That is, for each pixel (x,y) and the corresponding disparity d=disparity(x,y) , it
  9639. * computes:
  9640. *
  9641. * \(\begin{bmatrix}
  9642. * X \\
  9643. * Y \\
  9644. * Z \\
  9645. * W
  9646. * \end{bmatrix} = Q \begin{bmatrix}
  9647. * x \\
  9648. * y \\
  9649. * \texttt{disparity} (x,y) \\
  9650. * z
  9651. * \end{bmatrix}.\)
  9652. *
  9653. * SEE:
  9654. * To reproject a sparse set of points {(x,y,d),...} to 3D space, use perspectiveTransform.
  9655. */
  9656. public static void reprojectImageTo3D(Mat disparity, Mat _3dImage, Mat Q, bool handleMissingValues, int ddepth)
  9657. {
  9658. if (disparity != null) disparity.ThrowIfDisposed();
  9659. if (_3dImage != null) _3dImage.ThrowIfDisposed();
  9660. if (Q != null) Q.ThrowIfDisposed();
  9661. calib3d_Calib3d_reprojectImageTo3D_10(disparity.nativeObj, _3dImage.nativeObj, Q.nativeObj, handleMissingValues, ddepth);
  9662. }
  9663. /**
  9664. * Reprojects a disparity image to 3D space.
  9665. *
  9666. * param disparity Input single-channel 8-bit unsigned, 16-bit signed, 32-bit signed or 32-bit
  9667. * floating-point disparity image. The values of 8-bit / 16-bit signed formats are assumed to have no
  9668. * fractional bits. If the disparity is 16-bit signed format, as computed by REF: StereoBM or
  9669. * REF: StereoSGBM and maybe other algorithms, it should be divided by 16 (and scaled to float) before
  9670. * being used here.
  9671. * param _3dImage Output 3-channel floating-point image of the same size as disparity. Each element of
  9672. * _3dImage(x,y) contains 3D coordinates of the point (x,y) computed from the disparity map. If one
  9673. * uses Q obtained by REF: stereoRectify, then the returned points are represented in the first
  9674. * camera's rectified coordinate system.
  9675. * param Q \(4 \times 4\) perspective transformation matrix that can be obtained with
  9676. * REF: stereoRectify.
  9677. * param handleMissingValues Indicates, whether the function should handle missing values (i.e.
  9678. * points where the disparity was not computed). If handleMissingValues=true, then pixels with the
  9679. * minimal disparity that corresponds to the outliers (see StereoMatcher::compute ) are transformed
  9680. * to 3D points with a very large Z value (currently set to 10000).
  9681. * depth. ddepth can also be set to CV_16S, CV_32S or CV_32F.
  9682. *
  9683. * The function transforms a single-channel disparity map to a 3-channel image representing a 3D
  9684. * surface. That is, for each pixel (x,y) and the corresponding disparity d=disparity(x,y) , it
  9685. * computes:
  9686. *
  9687. * \(\begin{bmatrix}
  9688. * X \\
  9689. * Y \\
  9690. * Z \\
  9691. * W
  9692. * \end{bmatrix} = Q \begin{bmatrix}
  9693. * x \\
  9694. * y \\
  9695. * \texttt{disparity} (x,y) \\
  9696. * z
  9697. * \end{bmatrix}.\)
  9698. *
  9699. * SEE:
  9700. * To reproject a sparse set of points {(x,y,d),...} to 3D space, use perspectiveTransform.
  9701. */
  9702. public static void reprojectImageTo3D(Mat disparity, Mat _3dImage, Mat Q, bool handleMissingValues)
  9703. {
  9704. if (disparity != null) disparity.ThrowIfDisposed();
  9705. if (_3dImage != null) _3dImage.ThrowIfDisposed();
  9706. if (Q != null) Q.ThrowIfDisposed();
  9707. calib3d_Calib3d_reprojectImageTo3D_11(disparity.nativeObj, _3dImage.nativeObj, Q.nativeObj, handleMissingValues);
  9708. }
  9709. /**
  9710. * Reprojects a disparity image to 3D space.
  9711. *
  9712. * param disparity Input single-channel 8-bit unsigned, 16-bit signed, 32-bit signed or 32-bit
  9713. * floating-point disparity image. The values of 8-bit / 16-bit signed formats are assumed to have no
  9714. * fractional bits. If the disparity is 16-bit signed format, as computed by REF: StereoBM or
  9715. * REF: StereoSGBM and maybe other algorithms, it should be divided by 16 (and scaled to float) before
  9716. * being used here.
  9717. * param _3dImage Output 3-channel floating-point image of the same size as disparity. Each element of
  9718. * _3dImage(x,y) contains 3D coordinates of the point (x,y) computed from the disparity map. If one
  9719. * uses Q obtained by REF: stereoRectify, then the returned points are represented in the first
  9720. * camera's rectified coordinate system.
  9721. * param Q \(4 \times 4\) perspective transformation matrix that can be obtained with
  9722. * REF: stereoRectify.
  9723. * points where the disparity was not computed). If handleMissingValues=true, then pixels with the
  9724. * minimal disparity that corresponds to the outliers (see StereoMatcher::compute ) are transformed
  9725. * to 3D points with a very large Z value (currently set to 10000).
  9726. * depth. ddepth can also be set to CV_16S, CV_32S or CV_32F.
  9727. *
  9728. * The function transforms a single-channel disparity map to a 3-channel image representing a 3D
  9729. * surface. That is, for each pixel (x,y) and the corresponding disparity d=disparity(x,y) , it
  9730. * computes:
  9731. *
  9732. * \(\begin{bmatrix}
  9733. * X \\
  9734. * Y \\
  9735. * Z \\
  9736. * W
  9737. * \end{bmatrix} = Q \begin{bmatrix}
  9738. * x \\
  9739. * y \\
  9740. * \texttt{disparity} (x,y) \\
  9741. * z
  9742. * \end{bmatrix}.\)
  9743. *
  9744. * SEE:
  9745. * To reproject a sparse set of points {(x,y,d),...} to 3D space, use perspectiveTransform.
  9746. */
  9747. public static void reprojectImageTo3D(Mat disparity, Mat _3dImage, Mat Q)
  9748. {
  9749. if (disparity != null) disparity.ThrowIfDisposed();
  9750. if (_3dImage != null) _3dImage.ThrowIfDisposed();
  9751. if (Q != null) Q.ThrowIfDisposed();
  9752. calib3d_Calib3d_reprojectImageTo3D_12(disparity.nativeObj, _3dImage.nativeObj, Q.nativeObj);
  9753. }
  9754. //
  9755. // C++: double cv::sampsonDistance(Mat pt1, Mat pt2, Mat F)
  9756. //
  9757. /**
  9758. * Calculates the Sampson Distance between two points.
  9759. *
  9760. * The function cv::sampsonDistance calculates and returns the first order approximation of the geometric error as:
  9761. * \(
  9762. * sd( \texttt{pt1} , \texttt{pt2} )=
  9763. * \frac{(\texttt{pt2}^t \cdot \texttt{F} \cdot \texttt{pt1})^2}
  9764. * {((\texttt{F} \cdot \texttt{pt1})(0))^2 +
  9765. * ((\texttt{F} \cdot \texttt{pt1})(1))^2 +
  9766. * ((\texttt{F}^t \cdot \texttt{pt2})(0))^2 +
  9767. * ((\texttt{F}^t \cdot \texttt{pt2})(1))^2}
  9768. * \)
  9769. * The fundamental matrix may be calculated using the #findFundamentalMat function. See CITE: HartleyZ00 11.4.3 for details.
  9770. * param pt1 first homogeneous 2d point
  9771. * param pt2 second homogeneous 2d point
  9772. * param F fundamental matrix
  9773. * return The computed Sampson distance.
  9774. */
  9775. public static double sampsonDistance(Mat pt1, Mat pt2, Mat F)
  9776. {
  9777. if (pt1 != null) pt1.ThrowIfDisposed();
  9778. if (pt2 != null) pt2.ThrowIfDisposed();
  9779. if (F != null) F.ThrowIfDisposed();
  9780. return calib3d_Calib3d_sampsonDistance_10(pt1.nativeObj, pt2.nativeObj, F.nativeObj);
  9781. }
  9782. //
  9783. // C++: int cv::estimateAffine3D(Mat src, Mat dst, Mat& _out, Mat& inliers, double ransacThreshold = 3, double confidence = 0.99)
  9784. //
  9785. /**
  9786. * Computes an optimal affine transformation between two 3D point sets.
  9787. *
  9788. * It computes
  9789. * \(
  9790. * \begin{bmatrix}
  9791. * x\\
  9792. * y\\
  9793. * z\\
  9794. * \end{bmatrix}
  9795. * =
  9796. * \begin{bmatrix}
  9797. * a_{11} &amp; a_{12} &amp; a_{13}\\
  9798. * a_{21} &amp; a_{22} &amp; a_{23}\\
  9799. * a_{31} &amp; a_{32} &amp; a_{33}\\
  9800. * \end{bmatrix}
  9801. * \begin{bmatrix}
  9802. * X\\
  9803. * Y\\
  9804. * Z\\
  9805. * \end{bmatrix}
  9806. * +
  9807. * \begin{bmatrix}
  9808. * b_1\\
  9809. * b_2\\
  9810. * b_3\\
  9811. * \end{bmatrix}
  9812. * \)
  9813. *
  9814. * param src First input 3D point set containing \((X,Y,Z)\).
  9815. * param dst Second input 3D point set containing \((x,y,z)\).
  9816. * \(
  9817. * \begin{bmatrix}
  9818. * a_{11} &amp; a_{12} &amp; a_{13} &amp; b_1\\
  9819. * a_{21} &amp; a_{22} &amp; a_{23} &amp; b_2\\
  9820. * a_{31} &amp; a_{32} &amp; a_{33} &amp; b_3\\
  9821. * \end{bmatrix}
  9822. * \)
  9823. * param inliers Output vector indicating which points are inliers (1-inlier, 0-outlier).
  9824. * param ransacThreshold Maximum reprojection error in the RANSAC algorithm to consider a point as
  9825. * an inlier.
  9826. * param confidence Confidence level, between 0 and 1, for the estimated transformation. Anything
  9827. * between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation
  9828. * significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation.
  9829. *
  9830. * The function estimates an optimal 3D affine transformation between two 3D point sets using the
  9831. * RANSAC algorithm.
  9832. * param _out automatically generated
  9833. * return automatically generated
  9834. */
  9835. public static int estimateAffine3D(Mat src, Mat dst, Mat _out, Mat inliers, double ransacThreshold, double confidence)
  9836. {
  9837. if (src != null) src.ThrowIfDisposed();
  9838. if (dst != null) dst.ThrowIfDisposed();
  9839. if (_out != null) _out.ThrowIfDisposed();
  9840. if (inliers != null) inliers.ThrowIfDisposed();
  9841. return calib3d_Calib3d_estimateAffine3D_10(src.nativeObj, dst.nativeObj, _out.nativeObj, inliers.nativeObj, ransacThreshold, confidence);
  9842. }
  9843. /**
  9844. * Computes an optimal affine transformation between two 3D point sets.
  9845. *
  9846. * It computes
  9847. * \(
  9848. * \begin{bmatrix}
  9849. * x\\
  9850. * y\\
  9851. * z\\
  9852. * \end{bmatrix}
  9853. * =
  9854. * \begin{bmatrix}
  9855. * a_{11} &amp; a_{12} &amp; a_{13}\\
  9856. * a_{21} &amp; a_{22} &amp; a_{23}\\
  9857. * a_{31} &amp; a_{32} &amp; a_{33}\\
  9858. * \end{bmatrix}
  9859. * \begin{bmatrix}
  9860. * X\\
  9861. * Y\\
  9862. * Z\\
  9863. * \end{bmatrix}
  9864. * +
  9865. * \begin{bmatrix}
  9866. * b_1\\
  9867. * b_2\\
  9868. * b_3\\
  9869. * \end{bmatrix}
  9870. * \)
  9871. *
  9872. * param src First input 3D point set containing \((X,Y,Z)\).
  9873. * param dst Second input 3D point set containing \((x,y,z)\).
  9874. * \(
  9875. * \begin{bmatrix}
  9876. * a_{11} &amp; a_{12} &amp; a_{13} &amp; b_1\\
  9877. * a_{21} &amp; a_{22} &amp; a_{23} &amp; b_2\\
  9878. * a_{31} &amp; a_{32} &amp; a_{33} &amp; b_3\\
  9879. * \end{bmatrix}
  9880. * \)
  9881. * param inliers Output vector indicating which points are inliers (1-inlier, 0-outlier).
  9882. * param ransacThreshold Maximum reprojection error in the RANSAC algorithm to consider a point as
  9883. * an inlier.
  9884. * between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation
  9885. * significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation.
  9886. *
  9887. * The function estimates an optimal 3D affine transformation between two 3D point sets using the
  9888. * RANSAC algorithm.
  9889. * param _out automatically generated
  9890. * return automatically generated
  9891. */
  9892. public static int estimateAffine3D(Mat src, Mat dst, Mat _out, Mat inliers, double ransacThreshold)
  9893. {
  9894. if (src != null) src.ThrowIfDisposed();
  9895. if (dst != null) dst.ThrowIfDisposed();
  9896. if (_out != null) _out.ThrowIfDisposed();
  9897. if (inliers != null) inliers.ThrowIfDisposed();
  9898. return calib3d_Calib3d_estimateAffine3D_11(src.nativeObj, dst.nativeObj, _out.nativeObj, inliers.nativeObj, ransacThreshold);
  9899. }
  9900. /**
  9901. * Computes an optimal affine transformation between two 3D point sets.
  9902. *
  9903. * It computes
  9904. * \(
  9905. * \begin{bmatrix}
  9906. * x\\
  9907. * y\\
  9908. * z\\
  9909. * \end{bmatrix}
  9910. * =
  9911. * \begin{bmatrix}
  9912. * a_{11} &amp; a_{12} &amp; a_{13}\\
  9913. * a_{21} &amp; a_{22} &amp; a_{23}\\
  9914. * a_{31} &amp; a_{32} &amp; a_{33}\\
  9915. * \end{bmatrix}
  9916. * \begin{bmatrix}
  9917. * X\\
  9918. * Y\\
  9919. * Z\\
  9920. * \end{bmatrix}
  9921. * +
  9922. * \begin{bmatrix}
  9923. * b_1\\
  9924. * b_2\\
  9925. * b_3\\
  9926. * \end{bmatrix}
  9927. * \)
  9928. *
  9929. * param src First input 3D point set containing \((X,Y,Z)\).
  9930. * param dst Second input 3D point set containing \((x,y,z)\).
  9931. * \(
  9932. * \begin{bmatrix}
  9933. * a_{11} &amp; a_{12} &amp; a_{13} &amp; b_1\\
  9934. * a_{21} &amp; a_{22} &amp; a_{23} &amp; b_2\\
  9935. * a_{31} &amp; a_{32} &amp; a_{33} &amp; b_3\\
  9936. * \end{bmatrix}
  9937. * \)
  9938. * param inliers Output vector indicating which points are inliers (1-inlier, 0-outlier).
  9939. * an inlier.
  9940. * between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation
  9941. * significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation.
  9942. *
  9943. * The function estimates an optimal 3D affine transformation between two 3D point sets using the
  9944. * RANSAC algorithm.
  9945. * param _out automatically generated
  9946. * return automatically generated
  9947. */
  9948. public static int estimateAffine3D(Mat src, Mat dst, Mat _out, Mat inliers)
  9949. {
  9950. if (src != null) src.ThrowIfDisposed();
  9951. if (dst != null) dst.ThrowIfDisposed();
  9952. if (_out != null) _out.ThrowIfDisposed();
  9953. if (inliers != null) inliers.ThrowIfDisposed();
  9954. return calib3d_Calib3d_estimateAffine3D_12(src.nativeObj, dst.nativeObj, _out.nativeObj, inliers.nativeObj);
  9955. }
  9956. //
  9957. // C++: Mat cv::estimateAffine3D(Mat src, Mat dst, double* scale = nullptr, bool force_rotation = true)
  9958. //
  9959. /**
  9960. * Computes an optimal affine transformation between two 3D point sets.
  9961. *
  9962. * It computes \(R,s,t\) minimizing \(\sum{i} dst_i - c \cdot R \cdot src_i \)
  9963. * where \(R\) is a 3x3 rotation matrix, \(t\) is a 3x1 translation vector and \(s\) is a
  9964. * scalar size value. This is an implementation of the algorithm by Umeyama \cite umeyama1991least .
  9965. * The estimated affine transform has a homogeneous scale which is a subclass of affine
  9966. * transformations with 7 degrees of freedom. The paired point sets need to comprise at least 3
  9967. * points each.
  9968. *
  9969. * param src First input 3D point set.
  9970. * param dst Second input 3D point set.
  9971. * param scale If null is passed, the scale parameter c will be assumed to be 1.0.
  9972. * Else the pointed-to variable will be set to the optimal scale.
  9973. * param force_rotation If true, the returned rotation will never be a reflection.
  9974. * This might be unwanted, e.g. when optimizing a transform between a right- and a
  9975. * left-handed coordinate system.
  9976. * return 3D affine transformation matrix \(3 \times 4\) of the form
  9977. * \(T =
  9978. * \begin{bmatrix}
  9979. * R &amp; t\\
  9980. * \end{bmatrix}
  9981. * \)
  9982. */
  9983. public static Mat estimateAffine3D(Mat src, Mat dst, double[] scale, bool force_rotation)
  9984. {
  9985. if (src != null) src.ThrowIfDisposed();
  9986. if (dst != null) dst.ThrowIfDisposed();
  9987. double[] scale_out = new double[1];
  9988. Mat retVal = new Mat(DisposableObject.ThrowIfNullIntPtr(calib3d_Calib3d_estimateAffine3D_13(src.nativeObj, dst.nativeObj, scale_out, force_rotation)));
  9989. if (scale != null) scale[0] = (double)scale_out[0];
  9990. return retVal;
  9991. }
  9992. /**
  9993. * Computes an optimal affine transformation between two 3D point sets.
  9994. *
  9995. * It computes \(R,s,t\) minimizing \(\sum{i} dst_i - c \cdot R \cdot src_i \)
  9996. * where \(R\) is a 3x3 rotation matrix, \(t\) is a 3x1 translation vector and \(s\) is a
  9997. * scalar size value. This is an implementation of the algorithm by Umeyama \cite umeyama1991least .
  9998. * The estimated affine transform has a homogeneous scale which is a subclass of affine
  9999. * transformations with 7 degrees of freedom. The paired point sets need to comprise at least 3
  10000. * points each.
  10001. *
  10002. * param src First input 3D point set.
  10003. * param dst Second input 3D point set.
  10004. * param scale If null is passed, the scale parameter c will be assumed to be 1.0.
  10005. * Else the pointed-to variable will be set to the optimal scale.
  10006. * This might be unwanted, e.g. when optimizing a transform between a right- and a
  10007. * left-handed coordinate system.
  10008. * return 3D affine transformation matrix \(3 \times 4\) of the form
  10009. * \(T =
  10010. * \begin{bmatrix}
  10011. * R &amp; t\\
  10012. * \end{bmatrix}
  10013. * \)
  10014. */
  10015. public static Mat estimateAffine3D(Mat src, Mat dst, double[] scale)
  10016. {
  10017. if (src != null) src.ThrowIfDisposed();
  10018. if (dst != null) dst.ThrowIfDisposed();
  10019. double[] scale_out = new double[1];
  10020. Mat retVal = new Mat(DisposableObject.ThrowIfNullIntPtr(calib3d_Calib3d_estimateAffine3D_14(src.nativeObj, dst.nativeObj, scale_out)));
  10021. if (scale != null) scale[0] = (double)scale_out[0];
  10022. return retVal;
  10023. }
  10024. /**
  10025. * Computes an optimal affine transformation between two 3D point sets.
  10026. *
  10027. * It computes \(R,s,t\) minimizing \(\sum{i} dst_i - c \cdot R \cdot src_i \)
  10028. * where \(R\) is a 3x3 rotation matrix, \(t\) is a 3x1 translation vector and \(s\) is a
  10029. * scalar size value. This is an implementation of the algorithm by Umeyama \cite umeyama1991least .
  10030. * The estimated affine transform has a homogeneous scale which is a subclass of affine
  10031. * transformations with 7 degrees of freedom. The paired point sets need to comprise at least 3
  10032. * points each.
  10033. *
  10034. * param src First input 3D point set.
  10035. * param dst Second input 3D point set.
  10036. * Else the pointed-to variable will be set to the optimal scale.
  10037. * This might be unwanted, e.g. when optimizing a transform between a right- and a
  10038. * left-handed coordinate system.
  10039. * return 3D affine transformation matrix \(3 \times 4\) of the form
  10040. * \(T =
  10041. * \begin{bmatrix}
  10042. * R &amp; t\\
  10043. * \end{bmatrix}
  10044. * \)
  10045. */
  10046. public static Mat estimateAffine3D(Mat src, Mat dst)
  10047. {
  10048. if (src != null) src.ThrowIfDisposed();
  10049. if (dst != null) dst.ThrowIfDisposed();
  10050. return new Mat(DisposableObject.ThrowIfNullIntPtr(calib3d_Calib3d_estimateAffine3D_15(src.nativeObj, dst.nativeObj)));
  10051. }
  10052. //
  10053. // C++: int cv::estimateTranslation3D(Mat src, Mat dst, Mat& _out, Mat& inliers, double ransacThreshold = 3, double confidence = 0.99)
  10054. //
  10055. /**
  10056. * Computes an optimal translation between two 3D point sets.
  10057. *
  10058. * It computes
  10059. * \(
  10060. * \begin{bmatrix}
  10061. * x\\
  10062. * y\\
  10063. * z\\
  10064. * \end{bmatrix}
  10065. * =
  10066. * \begin{bmatrix}
  10067. * X\\
  10068. * Y\\
  10069. * Z\\
  10070. * \end{bmatrix}
  10071. * +
  10072. * \begin{bmatrix}
  10073. * b_1\\
  10074. * b_2\\
  10075. * b_3\\
  10076. * \end{bmatrix}
  10077. * \)
  10078. *
  10079. * param src First input 3D point set containing \((X,Y,Z)\).
  10080. * param dst Second input 3D point set containing \((x,y,z)\).
  10081. * \(
  10082. * \begin{bmatrix}
  10083. * b_1 \\
  10084. * b_2 \\
  10085. * b_3 \\
  10086. * \end{bmatrix}
  10087. * \)
  10088. * param inliers Output vector indicating which points are inliers (1-inlier, 0-outlier).
  10089. * param ransacThreshold Maximum reprojection error in the RANSAC algorithm to consider a point as
  10090. * an inlier.
  10091. * param confidence Confidence level, between 0 and 1, for the estimated transformation. Anything
  10092. * between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation
  10093. * significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation.
  10094. *
  10095. * The function estimates an optimal 3D translation between two 3D point sets using the
  10096. * RANSAC algorithm.
  10097. *
  10098. * param _out automatically generated
  10099. * return automatically generated
  10100. */
  10101. public static int estimateTranslation3D(Mat src, Mat dst, Mat _out, Mat inliers, double ransacThreshold, double confidence)
  10102. {
  10103. if (src != null) src.ThrowIfDisposed();
  10104. if (dst != null) dst.ThrowIfDisposed();
  10105. if (_out != null) _out.ThrowIfDisposed();
  10106. if (inliers != null) inliers.ThrowIfDisposed();
  10107. return calib3d_Calib3d_estimateTranslation3D_10(src.nativeObj, dst.nativeObj, _out.nativeObj, inliers.nativeObj, ransacThreshold, confidence);
  10108. }
  10109. /**
  10110. * Computes an optimal translation between two 3D point sets.
  10111. *
  10112. * It computes
  10113. * \(
  10114. * \begin{bmatrix}
  10115. * x\\
  10116. * y\\
  10117. * z\\
  10118. * \end{bmatrix}
  10119. * =
  10120. * \begin{bmatrix}
  10121. * X\\
  10122. * Y\\
  10123. * Z\\
  10124. * \end{bmatrix}
  10125. * +
  10126. * \begin{bmatrix}
  10127. * b_1\\
  10128. * b_2\\
  10129. * b_3\\
  10130. * \end{bmatrix}
  10131. * \)
  10132. *
  10133. * param src First input 3D point set containing \((X,Y,Z)\).
  10134. * param dst Second input 3D point set containing \((x,y,z)\).
  10135. * \(
  10136. * \begin{bmatrix}
  10137. * b_1 \\
  10138. * b_2 \\
  10139. * b_3 \\
  10140. * \end{bmatrix}
  10141. * \)
  10142. * param inliers Output vector indicating which points are inliers (1-inlier, 0-outlier).
  10143. * param ransacThreshold Maximum reprojection error in the RANSAC algorithm to consider a point as
  10144. * an inlier.
  10145. * between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation
  10146. * significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation.
  10147. *
  10148. * The function estimates an optimal 3D translation between two 3D point sets using the
  10149. * RANSAC algorithm.
  10150. *
  10151. * param _out automatically generated
  10152. * return automatically generated
  10153. */
  10154. public static int estimateTranslation3D(Mat src, Mat dst, Mat _out, Mat inliers, double ransacThreshold)
  10155. {
  10156. if (src != null) src.ThrowIfDisposed();
  10157. if (dst != null) dst.ThrowIfDisposed();
  10158. if (_out != null) _out.ThrowIfDisposed();
  10159. if (inliers != null) inliers.ThrowIfDisposed();
  10160. return calib3d_Calib3d_estimateTranslation3D_11(src.nativeObj, dst.nativeObj, _out.nativeObj, inliers.nativeObj, ransacThreshold);
  10161. }
  10162. /**
  10163. * Computes an optimal translation between two 3D point sets.
  10164. *
  10165. * It computes
  10166. * \(
  10167. * \begin{bmatrix}
  10168. * x\\
  10169. * y\\
  10170. * z\\
  10171. * \end{bmatrix}
  10172. * =
  10173. * \begin{bmatrix}
  10174. * X\\
  10175. * Y\\
  10176. * Z\\
  10177. * \end{bmatrix}
  10178. * +
  10179. * \begin{bmatrix}
  10180. * b_1\\
  10181. * b_2\\
  10182. * b_3\\
  10183. * \end{bmatrix}
  10184. * \)
  10185. *
  10186. * param src First input 3D point set containing \((X,Y,Z)\).
  10187. * param dst Second input 3D point set containing \((x,y,z)\).
  10188. * \(
  10189. * \begin{bmatrix}
  10190. * b_1 \\
  10191. * b_2 \\
  10192. * b_3 \\
  10193. * \end{bmatrix}
  10194. * \)
  10195. * param inliers Output vector indicating which points are inliers (1-inlier, 0-outlier).
  10196. * an inlier.
  10197. * between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation
  10198. * significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation.
  10199. *
  10200. * The function estimates an optimal 3D translation between two 3D point sets using the
  10201. * RANSAC algorithm.
  10202. *
  10203. * param _out automatically generated
  10204. * return automatically generated
  10205. */
  10206. public static int estimateTranslation3D(Mat src, Mat dst, Mat _out, Mat inliers)
  10207. {
  10208. if (src != null) src.ThrowIfDisposed();
  10209. if (dst != null) dst.ThrowIfDisposed();
  10210. if (_out != null) _out.ThrowIfDisposed();
  10211. if (inliers != null) inliers.ThrowIfDisposed();
  10212. return calib3d_Calib3d_estimateTranslation3D_12(src.nativeObj, dst.nativeObj, _out.nativeObj, inliers.nativeObj);
  10213. }
  10214. //
  10215. // C++: Mat cv::estimateAffine2D(Mat from, Mat to, Mat& inliers = Mat(), int method = RANSAC, double ransacReprojThreshold = 3, size_t maxIters = 2000, double confidence = 0.99, size_t refineIters = 10)
  10216. //
  10217. /**
  10218. * Computes an optimal affine transformation between two 2D point sets.
  10219. *
  10220. * It computes
  10221. * \(
  10222. * \begin{bmatrix}
  10223. * x\\
  10224. * y\\
  10225. * \end{bmatrix}
  10226. * =
  10227. * \begin{bmatrix}
  10228. * a_{11} &amp; a_{12}\\
  10229. * a_{21} &amp; a_{22}\\
  10230. * \end{bmatrix}
  10231. * \begin{bmatrix}
  10232. * X\\
  10233. * Y\\
  10234. * \end{bmatrix}
  10235. * +
  10236. * \begin{bmatrix}
  10237. * b_1\\
  10238. * b_2\\
  10239. * \end{bmatrix}
  10240. * \)
  10241. *
  10242. * param from First input 2D point set containing \((X,Y)\).
  10243. * param to Second input 2D point set containing \((x,y)\).
  10244. * param inliers Output vector indicating which points are inliers (1-inlier, 0-outlier).
  10245. * param method Robust method used to compute transformation. The following methods are possible:
  10246. * <ul>
  10247. * <li>
  10248. * REF: RANSAC - RANSAC-based robust method
  10249. * </li>
  10250. * <li>
  10251. * REF: LMEDS - Least-Median robust method
  10252. * RANSAC is the default method.
  10253. * </li>
  10254. * </ul>
  10255. * param ransacReprojThreshold Maximum reprojection error in the RANSAC algorithm to consider
  10256. * a point as an inlier. Applies only to RANSAC.
  10257. * param maxIters The maximum number of robust method iterations.
  10258. * param confidence Confidence level, between 0 and 1, for the estimated transformation. Anything
  10259. * between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation
  10260. * significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation.
  10261. * param refineIters Maximum number of iterations of refining algorithm (Levenberg-Marquardt).
  10262. * Passing 0 will disable refining, so the output matrix will be output of robust method.
  10263. *
  10264. * return Output 2D affine transformation matrix \(2 \times 3\) or empty matrix if transformation
  10265. * could not be estimated. The returned matrix has the following form:
  10266. * \(
  10267. * \begin{bmatrix}
  10268. * a_{11} &amp; a_{12} &amp; b_1\\
  10269. * a_{21} &amp; a_{22} &amp; b_2\\
  10270. * \end{bmatrix}
  10271. * \)
  10272. *
  10273. * The function estimates an optimal 2D affine transformation between two 2D point sets using the
  10274. * selected robust algorithm.
  10275. *
  10276. * The computed transformation is then refined further (using only inliers) with the
  10277. * Levenberg-Marquardt method to reduce the re-projection error even more.
  10278. *
  10279. * <b>Note:</b>
  10280. * The RANSAC method can handle practically any ratio of outliers but needs a threshold to
  10281. * distinguish inliers from outliers. The method LMeDS does not need any threshold but it works
  10282. * correctly only when there are more than 50% of inliers.
  10283. *
  10284. * SEE: estimateAffinePartial2D, getAffineTransform
  10285. */
  10286. public static Mat estimateAffine2D(Mat from, Mat to, Mat inliers, int method, double ransacReprojThreshold, long maxIters, double confidence, long refineIters)
  10287. {
  10288. if (from != null) from.ThrowIfDisposed();
  10289. if (to != null) to.ThrowIfDisposed();
  10290. if (inliers != null) inliers.ThrowIfDisposed();
  10291. return new Mat(DisposableObject.ThrowIfNullIntPtr(calib3d_Calib3d_estimateAffine2D_10(from.nativeObj, to.nativeObj, inliers.nativeObj, method, ransacReprojThreshold, maxIters, confidence, refineIters)));
  10292. }
  10293. /**
  10294. * Computes an optimal affine transformation between two 2D point sets.
  10295. *
  10296. * It computes
  10297. * \(
  10298. * \begin{bmatrix}
  10299. * x\\
  10300. * y\\
  10301. * \end{bmatrix}
  10302. * =
  10303. * \begin{bmatrix}
  10304. * a_{11} &amp; a_{12}\\
  10305. * a_{21} &amp; a_{22}\\
  10306. * \end{bmatrix}
  10307. * \begin{bmatrix}
  10308. * X\\
  10309. * Y\\
  10310. * \end{bmatrix}
  10311. * +
  10312. * \begin{bmatrix}
  10313. * b_1\\
  10314. * b_2\\
  10315. * \end{bmatrix}
  10316. * \)
  10317. *
  10318. * param from First input 2D point set containing \((X,Y)\).
  10319. * param to Second input 2D point set containing \((x,y)\).
  10320. * param inliers Output vector indicating which points are inliers (1-inlier, 0-outlier).
  10321. * param method Robust method used to compute transformation. The following methods are possible:
  10322. * <ul>
  10323. * <li>
  10324. * REF: RANSAC - RANSAC-based robust method
  10325. * </li>
  10326. * <li>
  10327. * REF: LMEDS - Least-Median robust method
  10328. * RANSAC is the default method.
  10329. * </li>
  10330. * </ul>
  10331. * param ransacReprojThreshold Maximum reprojection error in the RANSAC algorithm to consider
  10332. * a point as an inlier. Applies only to RANSAC.
  10333. * param maxIters The maximum number of robust method iterations.
  10334. * param confidence Confidence level, between 0 and 1, for the estimated transformation. Anything
  10335. * between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation
  10336. * significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation.
  10337. * Passing 0 will disable refining, so the output matrix will be output of robust method.
  10338. *
  10339. * return Output 2D affine transformation matrix \(2 \times 3\) or empty matrix if transformation
  10340. * could not be estimated. The returned matrix has the following form:
  10341. * \(
  10342. * \begin{bmatrix}
  10343. * a_{11} &amp; a_{12} &amp; b_1\\
  10344. * a_{21} &amp; a_{22} &amp; b_2\\
  10345. * \end{bmatrix}
  10346. * \)
  10347. *
  10348. * The function estimates an optimal 2D affine transformation between two 2D point sets using the
  10349. * selected robust algorithm.
  10350. *
  10351. * The computed transformation is then refined further (using only inliers) with the
  10352. * Levenberg-Marquardt method to reduce the re-projection error even more.
  10353. *
  10354. * <b>Note:</b>
  10355. * The RANSAC method can handle practically any ratio of outliers but needs a threshold to
  10356. * distinguish inliers from outliers. The method LMeDS does not need any threshold but it works
  10357. * correctly only when there are more than 50% of inliers.
  10358. *
  10359. * SEE: estimateAffinePartial2D, getAffineTransform
  10360. */
  10361. public static Mat estimateAffine2D(Mat from, Mat to, Mat inliers, int method, double ransacReprojThreshold, long maxIters, double confidence)
  10362. {
  10363. if (from != null) from.ThrowIfDisposed();
  10364. if (to != null) to.ThrowIfDisposed();
  10365. if (inliers != null) inliers.ThrowIfDisposed();
  10366. return new Mat(DisposableObject.ThrowIfNullIntPtr(calib3d_Calib3d_estimateAffine2D_11(from.nativeObj, to.nativeObj, inliers.nativeObj, method, ransacReprojThreshold, maxIters, confidence)));
  10367. }
  10368. /**
  10369. * Computes an optimal affine transformation between two 2D point sets.
  10370. *
  10371. * It computes
  10372. * \(
  10373. * \begin{bmatrix}
  10374. * x\\
  10375. * y\\
  10376. * \end{bmatrix}
  10377. * =
  10378. * \begin{bmatrix}
  10379. * a_{11} &amp; a_{12}\\
  10380. * a_{21} &amp; a_{22}\\
  10381. * \end{bmatrix}
  10382. * \begin{bmatrix}
  10383. * X\\
  10384. * Y\\
  10385. * \end{bmatrix}
  10386. * +
  10387. * \begin{bmatrix}
  10388. * b_1\\
  10389. * b_2\\
  10390. * \end{bmatrix}
  10391. * \)
  10392. *
  10393. * param from First input 2D point set containing \((X,Y)\).
  10394. * param to Second input 2D point set containing \((x,y)\).
  10395. * param inliers Output vector indicating which points are inliers (1-inlier, 0-outlier).
  10396. * param method Robust method used to compute transformation. The following methods are possible:
  10397. * <ul>
  10398. * <li>
  10399. * REF: RANSAC - RANSAC-based robust method
  10400. * </li>
  10401. * <li>
  10402. * REF: LMEDS - Least-Median robust method
  10403. * RANSAC is the default method.
  10404. * </li>
  10405. * </ul>
  10406. * param ransacReprojThreshold Maximum reprojection error in the RANSAC algorithm to consider
  10407. * a point as an inlier. Applies only to RANSAC.
  10408. * param maxIters The maximum number of robust method iterations.
  10409. * between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation
  10410. * significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation.
  10411. * Passing 0 will disable refining, so the output matrix will be output of robust method.
  10412. *
  10413. * return Output 2D affine transformation matrix \(2 \times 3\) or empty matrix if transformation
  10414. * could not be estimated. The returned matrix has the following form:
  10415. * \(
  10416. * \begin{bmatrix}
  10417. * a_{11} &amp; a_{12} &amp; b_1\\
  10418. * a_{21} &amp; a_{22} &amp; b_2\\
  10419. * \end{bmatrix}
  10420. * \)
  10421. *
  10422. * The function estimates an optimal 2D affine transformation between two 2D point sets using the
  10423. * selected robust algorithm.
  10424. *
  10425. * The computed transformation is then refined further (using only inliers) with the
  10426. * Levenberg-Marquardt method to reduce the re-projection error even more.
  10427. *
  10428. * <b>Note:</b>
  10429. * The RANSAC method can handle practically any ratio of outliers but needs a threshold to
  10430. * distinguish inliers from outliers. The method LMeDS does not need any threshold but it works
  10431. * correctly only when there are more than 50% of inliers.
  10432. *
  10433. * SEE: estimateAffinePartial2D, getAffineTransform
  10434. */
  10435. public static Mat estimateAffine2D(Mat from, Mat to, Mat inliers, int method, double ransacReprojThreshold, long maxIters)
  10436. {
  10437. if (from != null) from.ThrowIfDisposed();
  10438. if (to != null) to.ThrowIfDisposed();
  10439. if (inliers != null) inliers.ThrowIfDisposed();
  10440. return new Mat(DisposableObject.ThrowIfNullIntPtr(calib3d_Calib3d_estimateAffine2D_12(from.nativeObj, to.nativeObj, inliers.nativeObj, method, ransacReprojThreshold, maxIters)));
  10441. }
  10442. /**
  10443. * Computes an optimal affine transformation between two 2D point sets.
  10444. *
  10445. * It computes
  10446. * \(
  10447. * \begin{bmatrix}
  10448. * x\\
  10449. * y\\
  10450. * \end{bmatrix}
  10451. * =
  10452. * \begin{bmatrix}
  10453. * a_{11} &amp; a_{12}\\
  10454. * a_{21} &amp; a_{22}\\
  10455. * \end{bmatrix}
  10456. * \begin{bmatrix}
  10457. * X\\
  10458. * Y\\
  10459. * \end{bmatrix}
  10460. * +
  10461. * \begin{bmatrix}
  10462. * b_1\\
  10463. * b_2\\
  10464. * \end{bmatrix}
  10465. * \)
  10466. *
  10467. * param from First input 2D point set containing \((X,Y)\).
  10468. * param to Second input 2D point set containing \((x,y)\).
  10469. * param inliers Output vector indicating which points are inliers (1-inlier, 0-outlier).
  10470. * param method Robust method used to compute transformation. The following methods are possible:
  10471. * <ul>
  10472. * <li>
  10473. * REF: RANSAC - RANSAC-based robust method
  10474. * </li>
  10475. * <li>
  10476. * REF: LMEDS - Least-Median robust method
  10477. * RANSAC is the default method.
  10478. * </li>
  10479. * </ul>
  10480. * param ransacReprojThreshold Maximum reprojection error in the RANSAC algorithm to consider
  10481. * a point as an inlier. Applies only to RANSAC.
  10482. * between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation
  10483. * significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation.
  10484. * Passing 0 will disable refining, so the output matrix will be output of robust method.
  10485. *
  10486. * return Output 2D affine transformation matrix \(2 \times 3\) or empty matrix if transformation
  10487. * could not be estimated. The returned matrix has the following form:
  10488. * \(
  10489. * \begin{bmatrix}
  10490. * a_{11} &amp; a_{12} &amp; b_1\\
  10491. * a_{21} &amp; a_{22} &amp; b_2\\
  10492. * \end{bmatrix}
  10493. * \)
  10494. *
  10495. * The function estimates an optimal 2D affine transformation between two 2D point sets using the
  10496. * selected robust algorithm.
  10497. *
  10498. * The computed transformation is then refined further (using only inliers) with the
  10499. * Levenberg-Marquardt method to reduce the re-projection error even more.
  10500. *
  10501. * <b>Note:</b>
  10502. * The RANSAC method can handle practically any ratio of outliers but needs a threshold to
  10503. * distinguish inliers from outliers. The method LMeDS does not need any threshold but it works
  10504. * correctly only when there are more than 50% of inliers.
  10505. *
  10506. * SEE: estimateAffinePartial2D, getAffineTransform
  10507. */
  10508. public static Mat estimateAffine2D(Mat from, Mat to, Mat inliers, int method, double ransacReprojThreshold)
  10509. {
  10510. if (from != null) from.ThrowIfDisposed();
  10511. if (to != null) to.ThrowIfDisposed();
  10512. if (inliers != null) inliers.ThrowIfDisposed();
  10513. return new Mat(DisposableObject.ThrowIfNullIntPtr(calib3d_Calib3d_estimateAffine2D_13(from.nativeObj, to.nativeObj, inliers.nativeObj, method, ransacReprojThreshold)));
  10514. }
  10515. /**
  10516. * Computes an optimal affine transformation between two 2D point sets.
  10517. *
  10518. * It computes
  10519. * \(
  10520. * \begin{bmatrix}
  10521. * x\\
  10522. * y\\
  10523. * \end{bmatrix}
  10524. * =
  10525. * \begin{bmatrix}
  10526. * a_{11} &amp; a_{12}\\
  10527. * a_{21} &amp; a_{22}\\
  10528. * \end{bmatrix}
  10529. * \begin{bmatrix}
  10530. * X\\
  10531. * Y\\
  10532. * \end{bmatrix}
  10533. * +
  10534. * \begin{bmatrix}
  10535. * b_1\\
  10536. * b_2\\
  10537. * \end{bmatrix}
  10538. * \)
  10539. *
  10540. * param from First input 2D point set containing \((X,Y)\).
  10541. * param to Second input 2D point set containing \((x,y)\).
  10542. * param inliers Output vector indicating which points are inliers (1-inlier, 0-outlier).
  10543. * param method Robust method used to compute transformation. The following methods are possible:
  10544. * <ul>
  10545. * <li>
  10546. * REF: RANSAC - RANSAC-based robust method
  10547. * </li>
  10548. * <li>
  10549. * REF: LMEDS - Least-Median robust method
  10550. * RANSAC is the default method.
  10551. * </li>
  10552. * </ul>
  10553. * a point as an inlier. Applies only to RANSAC.
  10554. * between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation
  10555. * significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation.
  10556. * Passing 0 will disable refining, so the output matrix will be output of robust method.
  10557. *
  10558. * return Output 2D affine transformation matrix \(2 \times 3\) or empty matrix if transformation
  10559. * could not be estimated. The returned matrix has the following form:
  10560. * \(
  10561. * \begin{bmatrix}
  10562. * a_{11} &amp; a_{12} &amp; b_1\\
  10563. * a_{21} &amp; a_{22} &amp; b_2\\
  10564. * \end{bmatrix}
  10565. * \)
  10566. *
  10567. * The function estimates an optimal 2D affine transformation between two 2D point sets using the
  10568. * selected robust algorithm.
  10569. *
  10570. * The computed transformation is then refined further (using only inliers) with the
  10571. * Levenberg-Marquardt method to reduce the re-projection error even more.
  10572. *
  10573. * <b>Note:</b>
  10574. * The RANSAC method can handle practically any ratio of outliers but needs a threshold to
  10575. * distinguish inliers from outliers. The method LMeDS does not need any threshold but it works
  10576. * correctly only when there are more than 50% of inliers.
  10577. *
  10578. * SEE: estimateAffinePartial2D, getAffineTransform
  10579. */
  10580. public static Mat estimateAffine2D(Mat from, Mat to, Mat inliers, int method)
  10581. {
  10582. if (from != null) from.ThrowIfDisposed();
  10583. if (to != null) to.ThrowIfDisposed();
  10584. if (inliers != null) inliers.ThrowIfDisposed();
  10585. return new Mat(DisposableObject.ThrowIfNullIntPtr(calib3d_Calib3d_estimateAffine2D_14(from.nativeObj, to.nativeObj, inliers.nativeObj, method)));
  10586. }
  10587. /**
  10588. * Computes an optimal affine transformation between two 2D point sets.
  10589. *
  10590. * It computes
  10591. * \(
  10592. * \begin{bmatrix}
  10593. * x\\
  10594. * y\\
  10595. * \end{bmatrix}
  10596. * =
  10597. * \begin{bmatrix}
  10598. * a_{11} &amp; a_{12}\\
  10599. * a_{21} &amp; a_{22}\\
  10600. * \end{bmatrix}
  10601. * \begin{bmatrix}
  10602. * X\\
  10603. * Y\\
  10604. * \end{bmatrix}
  10605. * +
  10606. * \begin{bmatrix}
  10607. * b_1\\
  10608. * b_2\\
  10609. * \end{bmatrix}
  10610. * \)
  10611. *
  10612. * param from First input 2D point set containing \((X,Y)\).
  10613. * param to Second input 2D point set containing \((x,y)\).
  10614. * param inliers Output vector indicating which points are inliers (1-inlier, 0-outlier).
  10615. * <ul>
  10616. * <li>
  10617. * REF: RANSAC - RANSAC-based robust method
  10618. * </li>
  10619. * <li>
  10620. * REF: LMEDS - Least-Median robust method
  10621. * RANSAC is the default method.
  10622. * </li>
  10623. * </ul>
  10624. * a point as an inlier. Applies only to RANSAC.
  10625. * between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation
  10626. * significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation.
  10627. * Passing 0 will disable refining, so the output matrix will be output of robust method.
  10628. *
  10629. * return Output 2D affine transformation matrix \(2 \times 3\) or empty matrix if transformation
  10630. * could not be estimated. The returned matrix has the following form:
  10631. * \(
  10632. * \begin{bmatrix}
  10633. * a_{11} &amp; a_{12} &amp; b_1\\
  10634. * a_{21} &amp; a_{22} &amp; b_2\\
  10635. * \end{bmatrix}
  10636. * \)
  10637. *
  10638. * The function estimates an optimal 2D affine transformation between two 2D point sets using the
  10639. * selected robust algorithm.
  10640. *
  10641. * The computed transformation is then refined further (using only inliers) with the
  10642. * Levenberg-Marquardt method to reduce the re-projection error even more.
  10643. *
  10644. * <b>Note:</b>
  10645. * The RANSAC method can handle practically any ratio of outliers but needs a threshold to
  10646. * distinguish inliers from outliers. The method LMeDS does not need any threshold but it works
  10647. * correctly only when there are more than 50% of inliers.
  10648. *
  10649. * SEE: estimateAffinePartial2D, getAffineTransform
  10650. */
  10651. public static Mat estimateAffine2D(Mat from, Mat to, Mat inliers)
  10652. {
  10653. if (from != null) from.ThrowIfDisposed();
  10654. if (to != null) to.ThrowIfDisposed();
  10655. if (inliers != null) inliers.ThrowIfDisposed();
  10656. return new Mat(DisposableObject.ThrowIfNullIntPtr(calib3d_Calib3d_estimateAffine2D_15(from.nativeObj, to.nativeObj, inliers.nativeObj)));
  10657. }
  10658. /**
  10659. * Computes an optimal affine transformation between two 2D point sets.
  10660. *
  10661. * It computes
  10662. * \(
  10663. * \begin{bmatrix}
  10664. * x\\
  10665. * y\\
  10666. * \end{bmatrix}
  10667. * =
  10668. * \begin{bmatrix}
  10669. * a_{11} &amp; a_{12}\\
  10670. * a_{21} &amp; a_{22}\\
  10671. * \end{bmatrix}
  10672. * \begin{bmatrix}
  10673. * X\\
  10674. * Y\\
  10675. * \end{bmatrix}
  10676. * +
  10677. * \begin{bmatrix}
  10678. * b_1\\
  10679. * b_2\\
  10680. * \end{bmatrix}
  10681. * \)
  10682. *
  10683. * param from First input 2D point set containing \((X,Y)\).
  10684. * param to Second input 2D point set containing \((x,y)\).
  10685. * <ul>
  10686. * <li>
  10687. * REF: RANSAC - RANSAC-based robust method
  10688. * </li>
  10689. * <li>
  10690. * REF: LMEDS - Least-Median robust method
  10691. * RANSAC is the default method.
  10692. * </li>
  10693. * </ul>
  10694. * a point as an inlier. Applies only to RANSAC.
  10695. * between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation
  10696. * significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation.
  10697. * Passing 0 will disable refining, so the output matrix will be output of robust method.
  10698. *
  10699. * return Output 2D affine transformation matrix \(2 \times 3\) or empty matrix if transformation
  10700. * could not be estimated. The returned matrix has the following form:
  10701. * \(
  10702. * \begin{bmatrix}
  10703. * a_{11} &amp; a_{12} &amp; b_1\\
  10704. * a_{21} &amp; a_{22} &amp; b_2\\
  10705. * \end{bmatrix}
  10706. * \)
  10707. *
  10708. * The function estimates an optimal 2D affine transformation between two 2D point sets using the
  10709. * selected robust algorithm.
  10710. *
  10711. * The computed transformation is then refined further (using only inliers) with the
  10712. * Levenberg-Marquardt method to reduce the re-projection error even more.
  10713. *
  10714. * <b>Note:</b>
  10715. * The RANSAC method can handle practically any ratio of outliers but needs a threshold to
  10716. * distinguish inliers from outliers. The method LMeDS does not need any threshold but it works
  10717. * correctly only when there are more than 50% of inliers.
  10718. *
  10719. * SEE: estimateAffinePartial2D, getAffineTransform
  10720. */
  10721. public static Mat estimateAffine2D(Mat from, Mat to)
  10722. {
  10723. if (from != null) from.ThrowIfDisposed();
  10724. if (to != null) to.ThrowIfDisposed();
  10725. return new Mat(DisposableObject.ThrowIfNullIntPtr(calib3d_Calib3d_estimateAffine2D_16(from.nativeObj, to.nativeObj)));
  10726. }
  10727. //
  10728. // C++: Mat cv::estimateAffine2D(Mat pts1, Mat pts2, Mat& inliers, UsacParams _params)
  10729. //
  10730. public static Mat estimateAffine2D(Mat pts1, Mat pts2, Mat inliers, UsacParams _params)
  10731. {
  10732. if (pts1 != null) pts1.ThrowIfDisposed();
  10733. if (pts2 != null) pts2.ThrowIfDisposed();
  10734. if (inliers != null) inliers.ThrowIfDisposed();
  10735. if (_params != null) _params.ThrowIfDisposed();
  10736. return new Mat(DisposableObject.ThrowIfNullIntPtr(calib3d_Calib3d_estimateAffine2D_17(pts1.nativeObj, pts2.nativeObj, inliers.nativeObj, _params.nativeObj)));
  10737. }
  10738. //
  10739. // C++: Mat cv::estimateAffinePartial2D(Mat from, Mat to, Mat& inliers = Mat(), int method = RANSAC, double ransacReprojThreshold = 3, size_t maxIters = 2000, double confidence = 0.99, size_t refineIters = 10)
  10740. //
  10741. /**
  10742. * Computes an optimal limited affine transformation with 4 degrees of freedom between
  10743. * two 2D point sets.
  10744. *
  10745. * param from First input 2D point set.
  10746. * param to Second input 2D point set.
  10747. * param inliers Output vector indicating which points are inliers.
  10748. * param method Robust method used to compute transformation. The following methods are possible:
  10749. * <ul>
  10750. * <li>
  10751. * REF: RANSAC - RANSAC-based robust method
  10752. * </li>
  10753. * <li>
  10754. * REF: LMEDS - Least-Median robust method
  10755. * RANSAC is the default method.
  10756. * </li>
  10757. * </ul>
  10758. * param ransacReprojThreshold Maximum reprojection error in the RANSAC algorithm to consider
  10759. * a point as an inlier. Applies only to RANSAC.
  10760. * param maxIters The maximum number of robust method iterations.
  10761. * param confidence Confidence level, between 0 and 1, for the estimated transformation. Anything
  10762. * between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation
  10763. * significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation.
  10764. * param refineIters Maximum number of iterations of refining algorithm (Levenberg-Marquardt).
  10765. * Passing 0 will disable refining, so the output matrix will be output of robust method.
  10766. *
  10767. * return Output 2D affine transformation (4 degrees of freedom) matrix \(2 \times 3\) or
  10768. * empty matrix if transformation could not be estimated.
  10769. *
  10770. * The function estimates an optimal 2D affine transformation with 4 degrees of freedom limited to
  10771. * combinations of translation, rotation, and uniform scaling. Uses the selected algorithm for robust
  10772. * estimation.
  10773. *
  10774. * The computed transformation is then refined further (using only inliers) with the
  10775. * Levenberg-Marquardt method to reduce the re-projection error even more.
  10776. *
  10777. * Estimated transformation matrix is:
  10778. * \( \begin{bmatrix} \cos(\theta) \cdot s &amp; -\sin(\theta) \cdot s &amp; t_x \\
  10779. * \sin(\theta) \cdot s &amp; \cos(\theta) \cdot s &amp; t_y
  10780. * \end{bmatrix} \)
  10781. * Where \( \theta \) is the rotation angle, \( s \) the scaling factor and \( t_x, t_y \) are
  10782. * translations in \( x, y \) axes respectively.
  10783. *
  10784. * <b>Note:</b>
  10785. * The RANSAC method can handle practically any ratio of outliers but need a threshold to
  10786. * distinguish inliers from outliers. The method LMeDS does not need any threshold but it works
  10787. * correctly only when there are more than 50% of inliers.
  10788. *
  10789. * SEE: estimateAffine2D, getAffineTransform
  10790. */
  10791. public static Mat estimateAffinePartial2D(Mat from, Mat to, Mat inliers, int method, double ransacReprojThreshold, long maxIters, double confidence, long refineIters)
  10792. {
  10793. if (from != null) from.ThrowIfDisposed();
  10794. if (to != null) to.ThrowIfDisposed();
  10795. if (inliers != null) inliers.ThrowIfDisposed();
  10796. return new Mat(DisposableObject.ThrowIfNullIntPtr(calib3d_Calib3d_estimateAffinePartial2D_10(from.nativeObj, to.nativeObj, inliers.nativeObj, method, ransacReprojThreshold, maxIters, confidence, refineIters)));
  10797. }
  10798. /**
  10799. * Computes an optimal limited affine transformation with 4 degrees of freedom between
  10800. * two 2D point sets.
  10801. *
  10802. * param from First input 2D point set.
  10803. * param to Second input 2D point set.
  10804. * param inliers Output vector indicating which points are inliers.
  10805. * param method Robust method used to compute transformation. The following methods are possible:
  10806. * <ul>
  10807. * <li>
  10808. * REF: RANSAC - RANSAC-based robust method
  10809. * </li>
  10810. * <li>
  10811. * REF: LMEDS - Least-Median robust method
  10812. * RANSAC is the default method.
  10813. * </li>
  10814. * </ul>
  10815. * param ransacReprojThreshold Maximum reprojection error in the RANSAC algorithm to consider
  10816. * a point as an inlier. Applies only to RANSAC.
  10817. * param maxIters The maximum number of robust method iterations.
  10818. * param confidence Confidence level, between 0 and 1, for the estimated transformation. Anything
  10819. * between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation
  10820. * significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation.
  10821. * Passing 0 will disable refining, so the output matrix will be output of robust method.
  10822. *
  10823. * return Output 2D affine transformation (4 degrees of freedom) matrix \(2 \times 3\) or
  10824. * empty matrix if transformation could not be estimated.
  10825. *
  10826. * The function estimates an optimal 2D affine transformation with 4 degrees of freedom limited to
  10827. * combinations of translation, rotation, and uniform scaling. Uses the selected algorithm for robust
  10828. * estimation.
  10829. *
  10830. * The computed transformation is then refined further (using only inliers) with the
  10831. * Levenberg-Marquardt method to reduce the re-projection error even more.
  10832. *
  10833. * Estimated transformation matrix is:
  10834. * \( \begin{bmatrix} \cos(\theta) \cdot s &amp; -\sin(\theta) \cdot s &amp; t_x \\
  10835. * \sin(\theta) \cdot s &amp; \cos(\theta) \cdot s &amp; t_y
  10836. * \end{bmatrix} \)
  10837. * Where \( \theta \) is the rotation angle, \( s \) the scaling factor and \( t_x, t_y \) are
  10838. * translations in \( x, y \) axes respectively.
  10839. *
  10840. * <b>Note:</b>
  10841. * The RANSAC method can handle practically any ratio of outliers but need a threshold to
  10842. * distinguish inliers from outliers. The method LMeDS does not need any threshold but it works
  10843. * correctly only when there are more than 50% of inliers.
  10844. *
  10845. * SEE: estimateAffine2D, getAffineTransform
  10846. */
  10847. public static Mat estimateAffinePartial2D(Mat from, Mat to, Mat inliers, int method, double ransacReprojThreshold, long maxIters, double confidence)
  10848. {
  10849. if (from != null) from.ThrowIfDisposed();
  10850. if (to != null) to.ThrowIfDisposed();
  10851. if (inliers != null) inliers.ThrowIfDisposed();
  10852. return new Mat(DisposableObject.ThrowIfNullIntPtr(calib3d_Calib3d_estimateAffinePartial2D_11(from.nativeObj, to.nativeObj, inliers.nativeObj, method, ransacReprojThreshold, maxIters, confidence)));
  10853. }
  10854. /**
  10855. * Computes an optimal limited affine transformation with 4 degrees of freedom between
  10856. * two 2D point sets.
  10857. *
  10858. * param from First input 2D point set.
  10859. * param to Second input 2D point set.
  10860. * param inliers Output vector indicating which points are inliers.
  10861. * param method Robust method used to compute transformation. The following methods are possible:
  10862. * <ul>
  10863. * <li>
  10864. * REF: RANSAC - RANSAC-based robust method
  10865. * </li>
  10866. * <li>
  10867. * REF: LMEDS - Least-Median robust method
  10868. * RANSAC is the default method.
  10869. * </li>
  10870. * </ul>
  10871. * param ransacReprojThreshold Maximum reprojection error in the RANSAC algorithm to consider
  10872. * a point as an inlier. Applies only to RANSAC.
  10873. * param maxIters The maximum number of robust method iterations.
  10874. * between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation
  10875. * significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation.
  10876. * Passing 0 will disable refining, so the output matrix will be output of robust method.
  10877. *
  10878. * return Output 2D affine transformation (4 degrees of freedom) matrix \(2 \times 3\) or
  10879. * empty matrix if transformation could not be estimated.
  10880. *
  10881. * The function estimates an optimal 2D affine transformation with 4 degrees of freedom limited to
  10882. * combinations of translation, rotation, and uniform scaling. Uses the selected algorithm for robust
  10883. * estimation.
  10884. *
  10885. * The computed transformation is then refined further (using only inliers) with the
  10886. * Levenberg-Marquardt method to reduce the re-projection error even more.
  10887. *
  10888. * Estimated transformation matrix is:
  10889. * \( \begin{bmatrix} \cos(\theta) \cdot s &amp; -\sin(\theta) \cdot s &amp; t_x \\
  10890. * \sin(\theta) \cdot s &amp; \cos(\theta) \cdot s &amp; t_y
  10891. * \end{bmatrix} \)
  10892. * Where \( \theta \) is the rotation angle, \( s \) the scaling factor and \( t_x, t_y \) are
  10893. * translations in \( x, y \) axes respectively.
  10894. *
  10895. * <b>Note:</b>
  10896. * The RANSAC method can handle practically any ratio of outliers but need a threshold to
  10897. * distinguish inliers from outliers. The method LMeDS does not need any threshold but it works
  10898. * correctly only when there are more than 50% of inliers.
  10899. *
  10900. * SEE: estimateAffine2D, getAffineTransform
  10901. */
  10902. public static Mat estimateAffinePartial2D(Mat from, Mat to, Mat inliers, int method, double ransacReprojThreshold, long maxIters)
  10903. {
  10904. if (from != null) from.ThrowIfDisposed();
  10905. if (to != null) to.ThrowIfDisposed();
  10906. if (inliers != null) inliers.ThrowIfDisposed();
  10907. return new Mat(DisposableObject.ThrowIfNullIntPtr(calib3d_Calib3d_estimateAffinePartial2D_12(from.nativeObj, to.nativeObj, inliers.nativeObj, method, ransacReprojThreshold, maxIters)));
  10908. }
  10909. /**
  10910. * Computes an optimal limited affine transformation with 4 degrees of freedom between
  10911. * two 2D point sets.
  10912. *
  10913. * param from First input 2D point set.
  10914. * param to Second input 2D point set.
  10915. * param inliers Output vector indicating which points are inliers.
  10916. * param method Robust method used to compute transformation. The following methods are possible:
  10917. * <ul>
  10918. * <li>
  10919. * REF: RANSAC - RANSAC-based robust method
  10920. * </li>
  10921. * <li>
  10922. * REF: LMEDS - Least-Median robust method
  10923. * RANSAC is the default method.
  10924. * </li>
  10925. * </ul>
  10926. * param ransacReprojThreshold Maximum reprojection error in the RANSAC algorithm to consider
  10927. * a point as an inlier. Applies only to RANSAC.
  10928. * between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation
  10929. * significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation.
  10930. * Passing 0 will disable refining, so the output matrix will be output of robust method.
  10931. *
  10932. * return Output 2D affine transformation (4 degrees of freedom) matrix \(2 \times 3\) or
  10933. * empty matrix if transformation could not be estimated.
  10934. *
  10935. * The function estimates an optimal 2D affine transformation with 4 degrees of freedom limited to
  10936. * combinations of translation, rotation, and uniform scaling. Uses the selected algorithm for robust
  10937. * estimation.
  10938. *
  10939. * The computed transformation is then refined further (using only inliers) with the
  10940. * Levenberg-Marquardt method to reduce the re-projection error even more.
  10941. *
  10942. * Estimated transformation matrix is:
  10943. * \( \begin{bmatrix} \cos(\theta) \cdot s &amp; -\sin(\theta) \cdot s &amp; t_x \\
  10944. * \sin(\theta) \cdot s &amp; \cos(\theta) \cdot s &amp; t_y
  10945. * \end{bmatrix} \)
  10946. * Where \( \theta \) is the rotation angle, \( s \) the scaling factor and \( t_x, t_y \) are
  10947. * translations in \( x, y \) axes respectively.
  10948. *
  10949. * <b>Note:</b>
  10950. * The RANSAC method can handle practically any ratio of outliers but need a threshold to
  10951. * distinguish inliers from outliers. The method LMeDS does not need any threshold but it works
  10952. * correctly only when there are more than 50% of inliers.
  10953. *
  10954. * SEE: estimateAffine2D, getAffineTransform
  10955. */
  10956. public static Mat estimateAffinePartial2D(Mat from, Mat to, Mat inliers, int method, double ransacReprojThreshold)
  10957. {
  10958. if (from != null) from.ThrowIfDisposed();
  10959. if (to != null) to.ThrowIfDisposed();
  10960. if (inliers != null) inliers.ThrowIfDisposed();
  10961. return new Mat(DisposableObject.ThrowIfNullIntPtr(calib3d_Calib3d_estimateAffinePartial2D_13(from.nativeObj, to.nativeObj, inliers.nativeObj, method, ransacReprojThreshold)));
  10962. }
  10963. /**
  10964. * Computes an optimal limited affine transformation with 4 degrees of freedom between
  10965. * two 2D point sets.
  10966. *
  10967. * param from First input 2D point set.
  10968. * param to Second input 2D point set.
  10969. * param inliers Output vector indicating which points are inliers.
  10970. * param method Robust method used to compute transformation. The following methods are possible:
  10971. * <ul>
  10972. * <li>
  10973. * REF: RANSAC - RANSAC-based robust method
  10974. * </li>
  10975. * <li>
  10976. * REF: LMEDS - Least-Median robust method
  10977. * RANSAC is the default method.
  10978. * </li>
  10979. * </ul>
  10980. * a point as an inlier. Applies only to RANSAC.
  10981. * between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation
  10982. * significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation.
  10983. * Passing 0 will disable refining, so the output matrix will be output of robust method.
  10984. *
  10985. * return Output 2D affine transformation (4 degrees of freedom) matrix \(2 \times 3\) or
  10986. * empty matrix if transformation could not be estimated.
  10987. *
  10988. * The function estimates an optimal 2D affine transformation with 4 degrees of freedom limited to
  10989. * combinations of translation, rotation, and uniform scaling. Uses the selected algorithm for robust
  10990. * estimation.
  10991. *
  10992. * The computed transformation is then refined further (using only inliers) with the
  10993. * Levenberg-Marquardt method to reduce the re-projection error even more.
  10994. *
  10995. * Estimated transformation matrix is:
  10996. * \( \begin{bmatrix} \cos(\theta) \cdot s &amp; -\sin(\theta) \cdot s &amp; t_x \\
  10997. * \sin(\theta) \cdot s &amp; \cos(\theta) \cdot s &amp; t_y
  10998. * \end{bmatrix} \)
  10999. * Where \( \theta \) is the rotation angle, \( s \) the scaling factor and \( t_x, t_y \) are
  11000. * translations in \( x, y \) axes respectively.
  11001. *
  11002. * <b>Note:</b>
  11003. * The RANSAC method can handle practically any ratio of outliers but need a threshold to
  11004. * distinguish inliers from outliers. The method LMeDS does not need any threshold but it works
  11005. * correctly only when there are more than 50% of inliers.
  11006. *
  11007. * SEE: estimateAffine2D, getAffineTransform
  11008. */
  11009. public static Mat estimateAffinePartial2D(Mat from, Mat to, Mat inliers, int method)
  11010. {
  11011. if (from != null) from.ThrowIfDisposed();
  11012. if (to != null) to.ThrowIfDisposed();
  11013. if (inliers != null) inliers.ThrowIfDisposed();
  11014. return new Mat(DisposableObject.ThrowIfNullIntPtr(calib3d_Calib3d_estimateAffinePartial2D_14(from.nativeObj, to.nativeObj, inliers.nativeObj, method)));
  11015. }
  11016. /**
  11017. * Computes an optimal limited affine transformation with 4 degrees of freedom between
  11018. * two 2D point sets.
  11019. *
  11020. * param from First input 2D point set.
  11021. * param to Second input 2D point set.
  11022. * param inliers Output vector indicating which points are inliers.
  11023. * <ul>
  11024. * <li>
  11025. * REF: RANSAC - RANSAC-based robust method
  11026. * </li>
  11027. * <li>
  11028. * REF: LMEDS - Least-Median robust method
  11029. * RANSAC is the default method.
  11030. * </li>
  11031. * </ul>
  11032. * a point as an inlier. Applies only to RANSAC.
  11033. * between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation
  11034. * significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation.
  11035. * Passing 0 will disable refining, so the output matrix will be output of robust method.
  11036. *
  11037. * return Output 2D affine transformation (4 degrees of freedom) matrix \(2 \times 3\) or
  11038. * empty matrix if transformation could not be estimated.
  11039. *
  11040. * The function estimates an optimal 2D affine transformation with 4 degrees of freedom limited to
  11041. * combinations of translation, rotation, and uniform scaling. Uses the selected algorithm for robust
  11042. * estimation.
  11043. *
  11044. * The computed transformation is then refined further (using only inliers) with the
  11045. * Levenberg-Marquardt method to reduce the re-projection error even more.
  11046. *
  11047. * Estimated transformation matrix is:
  11048. * \( \begin{bmatrix} \cos(\theta) \cdot s &amp; -\sin(\theta) \cdot s &amp; t_x \\
  11049. * \sin(\theta) \cdot s &amp; \cos(\theta) \cdot s &amp; t_y
  11050. * \end{bmatrix} \)
  11051. * Where \( \theta \) is the rotation angle, \( s \) the scaling factor and \( t_x, t_y \) are
  11052. * translations in \( x, y \) axes respectively.
  11053. *
  11054. * <b>Note:</b>
  11055. * The RANSAC method can handle practically any ratio of outliers but need a threshold to
  11056. * distinguish inliers from outliers. The method LMeDS does not need any threshold but it works
  11057. * correctly only when there are more than 50% of inliers.
  11058. *
  11059. * SEE: estimateAffine2D, getAffineTransform
  11060. */
  11061. public static Mat estimateAffinePartial2D(Mat from, Mat to, Mat inliers)
  11062. {
  11063. if (from != null) from.ThrowIfDisposed();
  11064. if (to != null) to.ThrowIfDisposed();
  11065. if (inliers != null) inliers.ThrowIfDisposed();
  11066. return new Mat(DisposableObject.ThrowIfNullIntPtr(calib3d_Calib3d_estimateAffinePartial2D_15(from.nativeObj, to.nativeObj, inliers.nativeObj)));
  11067. }
  11068. /**
  11069. * Computes an optimal limited affine transformation with 4 degrees of freedom between
  11070. * two 2D point sets.
  11071. *
  11072. * param from First input 2D point set.
  11073. * param to Second input 2D point set.
  11074. * <ul>
  11075. * <li>
  11076. * REF: RANSAC - RANSAC-based robust method
  11077. * </li>
  11078. * <li>
  11079. * REF: LMEDS - Least-Median robust method
  11080. * RANSAC is the default method.
  11081. * </li>
  11082. * </ul>
  11083. * a point as an inlier. Applies only to RANSAC.
  11084. * between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation
  11085. * significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation.
  11086. * Passing 0 will disable refining, so the output matrix will be output of robust method.
  11087. *
  11088. * return Output 2D affine transformation (4 degrees of freedom) matrix \(2 \times 3\) or
  11089. * empty matrix if transformation could not be estimated.
  11090. *
  11091. * The function estimates an optimal 2D affine transformation with 4 degrees of freedom limited to
  11092. * combinations of translation, rotation, and uniform scaling. Uses the selected algorithm for robust
  11093. * estimation.
  11094. *
  11095. * The computed transformation is then refined further (using only inliers) with the
  11096. * Levenberg-Marquardt method to reduce the re-projection error even more.
  11097. *
  11098. * Estimated transformation matrix is:
  11099. * \( \begin{bmatrix} \cos(\theta) \cdot s &amp; -\sin(\theta) \cdot s &amp; t_x \\
  11100. * \sin(\theta) \cdot s &amp; \cos(\theta) \cdot s &amp; t_y
  11101. * \end{bmatrix} \)
  11102. * Where \( \theta \) is the rotation angle, \( s \) the scaling factor and \( t_x, t_y \) are
  11103. * translations in \( x, y \) axes respectively.
  11104. *
  11105. * <b>Note:</b>
  11106. * The RANSAC method can handle practically any ratio of outliers but need a threshold to
  11107. * distinguish inliers from outliers. The method LMeDS does not need any threshold but it works
  11108. * correctly only when there are more than 50% of inliers.
  11109. *
  11110. * SEE: estimateAffine2D, getAffineTransform
  11111. */
  11112. public static Mat estimateAffinePartial2D(Mat from, Mat to)
  11113. {
  11114. if (from != null) from.ThrowIfDisposed();
  11115. if (to != null) to.ThrowIfDisposed();
  11116. return new Mat(DisposableObject.ThrowIfNullIntPtr(calib3d_Calib3d_estimateAffinePartial2D_16(from.nativeObj, to.nativeObj)));
  11117. }
  11118. //
  11119. // C++: int cv::decomposeHomographyMat(Mat H, Mat K, vector_Mat& rotations, vector_Mat& translations, vector_Mat& normals)
  11120. //
  11121. /**
  11122. * Decompose a homography matrix to rotation(s), translation(s) and plane normal(s).
  11123. *
  11124. * param H The input homography matrix between two images.
  11125. * param K The input camera intrinsic matrix.
  11126. * param rotations Array of rotation matrices.
  11127. * param translations Array of translation matrices.
  11128. * param normals Array of plane normal matrices.
  11129. *
  11130. * This function extracts relative camera motion between two views of a planar object and returns up to
  11131. * four mathematical solution tuples of rotation, translation, and plane normal. The decomposition of
  11132. * the homography matrix H is described in detail in CITE: Malis2007.
  11133. *
  11134. * If the homography H, induced by the plane, gives the constraint
  11135. * \(s_i \vecthree{x'_i}{y'_i}{1} \sim H \vecthree{x_i}{y_i}{1}\) on the source image points
  11136. * \(p_i\) and the destination image points \(p'_i\), then the tuple of rotations[k] and
  11137. * translations[k] is a change of basis from the source camera's coordinate system to the destination
  11138. * camera's coordinate system. However, by decomposing H, one can only get the translation normalized
  11139. * by the (typically unknown) depth of the scene, i.e. its direction but with normalized length.
  11140. *
  11141. * If point correspondences are available, at least two solutions may further be invalidated, by
  11142. * applying positive depth constraint, i.e. all points must be in front of the camera.
  11143. * return automatically generated
  11144. */
  11145. public static int decomposeHomographyMat(Mat H, Mat K, List<Mat> rotations, List<Mat> translations, List<Mat> normals)
  11146. {
  11147. if (H != null) H.ThrowIfDisposed();
  11148. if (K != null) K.ThrowIfDisposed();
  11149. Mat rotations_mat = new Mat();
  11150. Mat translations_mat = new Mat();
  11151. Mat normals_mat = new Mat();
  11152. int retVal = calib3d_Calib3d_decomposeHomographyMat_10(H.nativeObj, K.nativeObj, rotations_mat.nativeObj, translations_mat.nativeObj, normals_mat.nativeObj);
  11153. Converters.Mat_to_vector_Mat(rotations_mat, rotations);
  11154. rotations_mat.release();
  11155. Converters.Mat_to_vector_Mat(translations_mat, translations);
  11156. translations_mat.release();
  11157. Converters.Mat_to_vector_Mat(normals_mat, normals);
  11158. normals_mat.release();
  11159. return retVal;
  11160. }
  11161. //
  11162. // C++: void cv::filterHomographyDecompByVisibleRefpoints(vector_Mat rotations, vector_Mat normals, Mat beforePoints, Mat afterPoints, Mat& possibleSolutions, Mat pointsMask = Mat())
  11163. //
  11164. /**
  11165. * Filters homography decompositions based on additional information.
  11166. *
  11167. * param rotations Vector of rotation matrices.
  11168. * param normals Vector of plane normal matrices.
  11169. * param beforePoints Vector of (rectified) visible reference points before the homography is applied
  11170. * param afterPoints Vector of (rectified) visible reference points after the homography is applied
  11171. * param possibleSolutions Vector of int indices representing the viable solution set after filtering
  11172. * param pointsMask optional Mat/Vector of 8u type representing the mask for the inliers as given by the #findHomography function
  11173. *
  11174. * This function is intended to filter the output of the #decomposeHomographyMat based on additional
  11175. * information as described in CITE: Malis2007 . The summary of the method: the #decomposeHomographyMat function
  11176. * returns 2 unique solutions and their "opposites" for a total of 4 solutions. If we have access to the
  11177. * sets of points visible in the camera frame before and after the homography transformation is applied,
  11178. * we can determine which are the true potential solutions and which are the opposites by verifying which
  11179. * homographies are consistent with all visible reference points being in front of the camera. The inputs
  11180. * are left unchanged; the filtered solution set is returned as indices into the existing one.
  11181. */
  11182. public static void filterHomographyDecompByVisibleRefpoints(List<Mat> rotations, List<Mat> normals, Mat beforePoints, Mat afterPoints, Mat possibleSolutions, Mat pointsMask)
  11183. {
  11184. if (beforePoints != null) beforePoints.ThrowIfDisposed();
  11185. if (afterPoints != null) afterPoints.ThrowIfDisposed();
  11186. if (possibleSolutions != null) possibleSolutions.ThrowIfDisposed();
  11187. if (pointsMask != null) pointsMask.ThrowIfDisposed();
  11188. Mat rotations_mat = Converters.vector_Mat_to_Mat(rotations);
  11189. Mat normals_mat = Converters.vector_Mat_to_Mat(normals);
  11190. calib3d_Calib3d_filterHomographyDecompByVisibleRefpoints_10(rotations_mat.nativeObj, normals_mat.nativeObj, beforePoints.nativeObj, afterPoints.nativeObj, possibleSolutions.nativeObj, pointsMask.nativeObj);
  11191. }
  11192. /**
  11193. * Filters homography decompositions based on additional information.
  11194. *
  11195. * param rotations Vector of rotation matrices.
  11196. * param normals Vector of plane normal matrices.
  11197. * param beforePoints Vector of (rectified) visible reference points before the homography is applied
  11198. * param afterPoints Vector of (rectified) visible reference points after the homography is applied
  11199. * param possibleSolutions Vector of int indices representing the viable solution set after filtering
  11200. *
  11201. * This function is intended to filter the output of the #decomposeHomographyMat based on additional
  11202. * information as described in CITE: Malis2007 . The summary of the method: the #decomposeHomographyMat function
  11203. * returns 2 unique solutions and their "opposites" for a total of 4 solutions. If we have access to the
  11204. * sets of points visible in the camera frame before and after the homography transformation is applied,
  11205. * we can determine which are the true potential solutions and which are the opposites by verifying which
  11206. * homographies are consistent with all visible reference points being in front of the camera. The inputs
  11207. * are left unchanged; the filtered solution set is returned as indices into the existing one.
  11208. */
  11209. public static void filterHomographyDecompByVisibleRefpoints(List<Mat> rotations, List<Mat> normals, Mat beforePoints, Mat afterPoints, Mat possibleSolutions)
  11210. {
  11211. if (beforePoints != null) beforePoints.ThrowIfDisposed();
  11212. if (afterPoints != null) afterPoints.ThrowIfDisposed();
  11213. if (possibleSolutions != null) possibleSolutions.ThrowIfDisposed();
  11214. Mat rotations_mat = Converters.vector_Mat_to_Mat(rotations);
  11215. Mat normals_mat = Converters.vector_Mat_to_Mat(normals);
  11216. calib3d_Calib3d_filterHomographyDecompByVisibleRefpoints_11(rotations_mat.nativeObj, normals_mat.nativeObj, beforePoints.nativeObj, afterPoints.nativeObj, possibleSolutions.nativeObj);
  11217. }
  11218. //
  11219. // C++: void cv::undistort(Mat src, Mat& dst, Mat cameraMatrix, Mat distCoeffs, Mat newCameraMatrix = Mat())
  11220. //
  11221. /**
  11222. * Transforms an image to compensate for lens distortion.
  11223. *
  11224. * The function transforms an image to compensate radial and tangential lens distortion.
  11225. *
  11226. * The function is simply a combination of #initUndistortRectifyMap (with unity R ) and #remap
  11227. * (with bilinear interpolation). See the former function for details of the transformation being
  11228. * performed.
  11229. *
  11230. * Those pixels in the destination image, for which there is no correspondent pixels in the source
  11231. * image, are filled with zeros (black color).
  11232. *
  11233. * A particular subset of the source image that will be visible in the corrected image can be regulated
  11234. * by newCameraMatrix. You can use #getOptimalNewCameraMatrix to compute the appropriate
  11235. * newCameraMatrix depending on your requirements.
  11236. *
  11237. * The camera matrix and the distortion parameters can be determined using #calibrateCamera. If
  11238. * the resolution of images is different from the resolution used at the calibration stage, \(f_x,
  11239. * f_y, c_x\) and \(c_y\) need to be scaled accordingly, while the distortion coefficients remain
  11240. * the same.
  11241. *
  11242. * param src Input (distorted) image.
  11243. * param dst Output (corrected) image that has the same size and type as src .
  11244. * param cameraMatrix Input camera matrix \(A = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\) .
  11245. * param distCoeffs Input vector of distortion coefficients
  11246. * \((k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6[, s_1, s_2, s_3, s_4[, \tau_x, \tau_y]]]])\)
  11247. * of 4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed.
  11248. * param newCameraMatrix Camera matrix of the distorted image. By default, it is the same as
  11249. * cameraMatrix but you may additionally scale and shift the result by using a different matrix.
  11250. */
  11251. public static void undistort(Mat src, Mat dst, Mat cameraMatrix, Mat distCoeffs, Mat newCameraMatrix)
  11252. {
  11253. if (src != null) src.ThrowIfDisposed();
  11254. if (dst != null) dst.ThrowIfDisposed();
  11255. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  11256. if (distCoeffs != null) distCoeffs.ThrowIfDisposed();
  11257. if (newCameraMatrix != null) newCameraMatrix.ThrowIfDisposed();
  11258. calib3d_Calib3d_undistort_10(src.nativeObj, dst.nativeObj, cameraMatrix.nativeObj, distCoeffs.nativeObj, newCameraMatrix.nativeObj);
  11259. }
  11260. /**
  11261. * Transforms an image to compensate for lens distortion.
  11262. *
  11263. * The function transforms an image to compensate radial and tangential lens distortion.
  11264. *
  11265. * The function is simply a combination of #initUndistortRectifyMap (with unity R ) and #remap
  11266. * (with bilinear interpolation). See the former function for details of the transformation being
  11267. * performed.
  11268. *
  11269. * Those pixels in the destination image, for which there is no correspondent pixels in the source
  11270. * image, are filled with zeros (black color).
  11271. *
  11272. * A particular subset of the source image that will be visible in the corrected image can be regulated
  11273. * by newCameraMatrix. You can use #getOptimalNewCameraMatrix to compute the appropriate
  11274. * newCameraMatrix depending on your requirements.
  11275. *
  11276. * The camera matrix and the distortion parameters can be determined using #calibrateCamera. If
  11277. * the resolution of images is different from the resolution used at the calibration stage, \(f_x,
  11278. * f_y, c_x\) and \(c_y\) need to be scaled accordingly, while the distortion coefficients remain
  11279. * the same.
  11280. *
  11281. * param src Input (distorted) image.
  11282. * param dst Output (corrected) image that has the same size and type as src .
  11283. * param cameraMatrix Input camera matrix \(A = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\) .
  11284. * param distCoeffs Input vector of distortion coefficients
  11285. * \((k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6[, s_1, s_2, s_3, s_4[, \tau_x, \tau_y]]]])\)
  11286. * of 4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed.
  11287. * cameraMatrix but you may additionally scale and shift the result by using a different matrix.
  11288. */
  11289. public static void undistort(Mat src, Mat dst, Mat cameraMatrix, Mat distCoeffs)
  11290. {
  11291. if (src != null) src.ThrowIfDisposed();
  11292. if (dst != null) dst.ThrowIfDisposed();
  11293. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  11294. if (distCoeffs != null) distCoeffs.ThrowIfDisposed();
  11295. calib3d_Calib3d_undistort_11(src.nativeObj, dst.nativeObj, cameraMatrix.nativeObj, distCoeffs.nativeObj);
  11296. }
  11297. //
  11298. // C++: void cv::initUndistortRectifyMap(Mat cameraMatrix, Mat distCoeffs, Mat R, Mat newCameraMatrix, Size size, int m1type, Mat& map1, Mat& map2)
  11299. //
  11300. /**
  11301. * Computes the undistortion and rectification transformation map.
  11302. *
  11303. * The function computes the joint undistortion and rectification transformation and represents the
  11304. * result in the form of maps for #remap. The undistorted image looks like original, as if it is
  11305. * captured with a camera using the camera matrix =newCameraMatrix and zero distortion. In case of a
  11306. * monocular camera, newCameraMatrix is usually equal to cameraMatrix, or it can be computed by
  11307. * #getOptimalNewCameraMatrix for a better control over scaling. In case of a stereo camera,
  11308. * newCameraMatrix is normally set to P1 or P2 computed by #stereoRectify .
  11309. *
  11310. * Also, this new camera is oriented differently in the coordinate space, according to R. That, for
  11311. * example, helps to align two heads of a stereo camera so that the epipolar lines on both images
  11312. * become horizontal and have the same y- coordinate (in case of a horizontally aligned stereo camera).
  11313. *
  11314. * The function actually builds the maps for the inverse mapping algorithm that is used by #remap. That
  11315. * is, for each pixel \((u, v)\) in the destination (corrected and rectified) image, the function
  11316. * computes the corresponding coordinates in the source image (that is, in the original image from
  11317. * camera). The following process is applied:
  11318. * \(
  11319. * \begin{array}{l}
  11320. * x \leftarrow (u - {c'}_x)/{f'}_x \\
  11321. * y \leftarrow (v - {c'}_y)/{f'}_y \\
  11322. * {[X\,Y\,W]} ^T \leftarrow R^{-1}*[x \, y \, 1]^T \\
  11323. * x' \leftarrow X/W \\
  11324. * y' \leftarrow Y/W \\
  11325. * r^2 \leftarrow x'^2 + y'^2 \\
  11326. * x'' \leftarrow x' \frac{1 + k_1 r^2 + k_2 r^4 + k_3 r^6}{1 + k_4 r^2 + k_5 r^4 + k_6 r^6}
  11327. * + 2p_1 x' y' + p_2(r^2 + 2 x'^2) + s_1 r^2 + s_2 r^4\\
  11328. * y'' \leftarrow y' \frac{1 + k_1 r^2 + k_2 r^4 + k_3 r^6}{1 + k_4 r^2 + k_5 r^4 + k_6 r^6}
  11329. * + p_1 (r^2 + 2 y'^2) + 2 p_2 x' y' + s_3 r^2 + s_4 r^4 \\
  11330. * s\vecthree{x'''}{y'''}{1} =
  11331. * \vecthreethree{R_{33}(\tau_x, \tau_y)}{0}{-R_{13}((\tau_x, \tau_y)}
  11332. * {0}{R_{33}(\tau_x, \tau_y)}{-R_{23}(\tau_x, \tau_y)}
  11333. * {0}{0}{1} R(\tau_x, \tau_y) \vecthree{x''}{y''}{1}\\
  11334. * map_x(u,v) \leftarrow x''' f_x + c_x \\
  11335. * map_y(u,v) \leftarrow y''' f_y + c_y
  11336. * \end{array}
  11337. * \)
  11338. * where \((k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6[, s_1, s_2, s_3, s_4[, \tau_x, \tau_y]]]])\)
  11339. * are the distortion coefficients.
  11340. *
  11341. * In case of a stereo camera, this function is called twice: once for each camera head, after
  11342. * #stereoRectify, which in its turn is called after #stereoCalibrate. But if the stereo camera
  11343. * was not calibrated, it is still possible to compute the rectification transformations directly from
  11344. * the fundamental matrix using #stereoRectifyUncalibrated. For each camera, the function computes
  11345. * homography H as the rectification transformation in a pixel domain, not a rotation matrix R in 3D
  11346. * space. R can be computed from H as
  11347. * \(\texttt{R} = \texttt{cameraMatrix} ^{-1} \cdot \texttt{H} \cdot \texttt{cameraMatrix}\)
  11348. * where cameraMatrix can be chosen arbitrarily.
  11349. *
  11350. * param cameraMatrix Input camera matrix \(A=\vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\) .
  11351. * param distCoeffs Input vector of distortion coefficients
  11352. * \((k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6[, s_1, s_2, s_3, s_4[, \tau_x, \tau_y]]]])\)
  11353. * of 4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed.
  11354. * param R Optional rectification transformation in the object space (3x3 matrix). R1 or R2 ,
  11355. * computed by #stereoRectify can be passed here. If the matrix is empty, the identity transformation
  11356. * is assumed. In #initUndistortRectifyMap R assumed to be an identity matrix.
  11357. * param newCameraMatrix New camera matrix \(A'=\vecthreethree{f_x'}{0}{c_x'}{0}{f_y'}{c_y'}{0}{0}{1}\).
  11358. * param size Undistorted image size.
  11359. * param m1type Type of the first output map that can be CV_32FC1, CV_32FC2 or CV_16SC2, see #convertMaps
  11360. * param map1 The first output map.
  11361. * param map2 The second output map.
  11362. */
  11363. public static void initUndistortRectifyMap(Mat cameraMatrix, Mat distCoeffs, Mat R, Mat newCameraMatrix, Size size, int m1type, Mat map1, Mat map2)
  11364. {
  11365. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  11366. if (distCoeffs != null) distCoeffs.ThrowIfDisposed();
  11367. if (R != null) R.ThrowIfDisposed();
  11368. if (newCameraMatrix != null) newCameraMatrix.ThrowIfDisposed();
  11369. if (map1 != null) map1.ThrowIfDisposed();
  11370. if (map2 != null) map2.ThrowIfDisposed();
  11371. calib3d_Calib3d_initUndistortRectifyMap_10(cameraMatrix.nativeObj, distCoeffs.nativeObj, R.nativeObj, newCameraMatrix.nativeObj, size.width, size.height, m1type, map1.nativeObj, map2.nativeObj);
  11372. }
  11373. //
  11374. // C++: void cv::initInverseRectificationMap(Mat cameraMatrix, Mat distCoeffs, Mat R, Mat newCameraMatrix, Size size, int m1type, Mat& map1, Mat& map2)
  11375. //
  11376. /**
  11377. * Computes the projection and inverse-rectification transformation map. In essense, this is the inverse of
  11378. * #initUndistortRectifyMap to accomodate stereo-rectification of projectors ('inverse-cameras') in projector-camera pairs.
  11379. *
  11380. * The function computes the joint projection and inverse rectification transformation and represents the
  11381. * result in the form of maps for #remap. The projected image looks like a distorted version of the original which,
  11382. * once projected by a projector, should visually match the original. In case of a monocular camera, newCameraMatrix
  11383. * is usually equal to cameraMatrix, or it can be computed by
  11384. * #getOptimalNewCameraMatrix for a better control over scaling. In case of a projector-camera pair,
  11385. * newCameraMatrix is normally set to P1 or P2 computed by #stereoRectify .
  11386. *
  11387. * The projector is oriented differently in the coordinate space, according to R. In case of projector-camera pairs,
  11388. * this helps align the projector (in the same manner as #initUndistortRectifyMap for the camera) to create a stereo-rectified pair. This
  11389. * allows epipolar lines on both images to become horizontal and have the same y-coordinate (in case of a horizontally aligned projector-camera pair).
  11390. *
  11391. * The function builds the maps for the inverse mapping algorithm that is used by #remap. That
  11392. * is, for each pixel \((u, v)\) in the destination (projected and inverse-rectified) image, the function
  11393. * computes the corresponding coordinates in the source image (that is, in the original digital image). The following process is applied:
  11394. *
  11395. * \(
  11396. * \begin{array}{l}
  11397. * \text{newCameraMatrix}\\
  11398. * x \leftarrow (u - {c'}_x)/{f'}_x \\
  11399. * y \leftarrow (v - {c'}_y)/{f'}_y \\
  11400. *
  11401. * \\\text{Undistortion}
  11402. * \\\scriptsize{\textit{though equation shown is for radial undistortion, function implements cv::undistortPoints()}}\\
  11403. * r^2 \leftarrow x^2 + y^2 \\
  11404. * \theta \leftarrow \frac{1 + k_1 r^2 + k_2 r^4 + k_3 r^6}{1 + k_4 r^2 + k_5 r^4 + k_6 r^6}\\
  11405. * x' \leftarrow \frac{x}{\theta} \\
  11406. * y' \leftarrow \frac{y}{\theta} \\
  11407. *
  11408. * \\\text{Rectification}\\
  11409. * {[X\,Y\,W]} ^T \leftarrow R*[x' \, y' \, 1]^T \\
  11410. * x'' \leftarrow X/W \\
  11411. * y'' \leftarrow Y/W \\
  11412. *
  11413. * \\\text{cameraMatrix}\\
  11414. * map_x(u,v) \leftarrow x'' f_x + c_x \\
  11415. * map_y(u,v) \leftarrow y'' f_y + c_y
  11416. * \end{array}
  11417. * \)
  11418. * where \((k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6[, s_1, s_2, s_3, s_4[, \tau_x, \tau_y]]]])\)
  11419. * are the distortion coefficients vector distCoeffs.
  11420. *
  11421. * In case of a stereo-rectified projector-camera pair, this function is called for the projector while #initUndistortRectifyMap is called for the camera head.
  11422. * This is done after #stereoRectify, which in turn is called after #stereoCalibrate. If the projector-camera pair
  11423. * is not calibrated, it is still possible to compute the rectification transformations directly from
  11424. * the fundamental matrix using #stereoRectifyUncalibrated. For the projector and camera, the function computes
  11425. * homography H as the rectification transformation in a pixel domain, not a rotation matrix R in 3D
  11426. * space. R can be computed from H as
  11427. * \(\texttt{R} = \texttt{cameraMatrix} ^{-1} \cdot \texttt{H} \cdot \texttt{cameraMatrix}\)
  11428. * where cameraMatrix can be chosen arbitrarily.
  11429. *
  11430. * param cameraMatrix Input camera matrix \(A=\vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\) .
  11431. * param distCoeffs Input vector of distortion coefficients
  11432. * \((k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6[, s_1, s_2, s_3, s_4[, \tau_x, \tau_y]]]])\)
  11433. * of 4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed.
  11434. * param R Optional rectification transformation in the object space (3x3 matrix). R1 or R2,
  11435. * computed by #stereoRectify can be passed here. If the matrix is empty, the identity transformation
  11436. * is assumed.
  11437. * param newCameraMatrix New camera matrix \(A'=\vecthreethree{f_x'}{0}{c_x'}{0}{f_y'}{c_y'}{0}{0}{1}\).
  11438. * param size Distorted image size.
  11439. * param m1type Type of the first output map. Can be CV_32FC1, CV_32FC2 or CV_16SC2, see #convertMaps
  11440. * param map1 The first output map for #remap.
  11441. * param map2 The second output map for #remap.
  11442. */
  11443. public static void initInverseRectificationMap(Mat cameraMatrix, Mat distCoeffs, Mat R, Mat newCameraMatrix, Size size, int m1type, Mat map1, Mat map2)
  11444. {
  11445. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  11446. if (distCoeffs != null) distCoeffs.ThrowIfDisposed();
  11447. if (R != null) R.ThrowIfDisposed();
  11448. if (newCameraMatrix != null) newCameraMatrix.ThrowIfDisposed();
  11449. if (map1 != null) map1.ThrowIfDisposed();
  11450. if (map2 != null) map2.ThrowIfDisposed();
  11451. calib3d_Calib3d_initInverseRectificationMap_10(cameraMatrix.nativeObj, distCoeffs.nativeObj, R.nativeObj, newCameraMatrix.nativeObj, size.width, size.height, m1type, map1.nativeObj, map2.nativeObj);
  11452. }
  11453. //
  11454. // C++: Mat cv::getDefaultNewCameraMatrix(Mat cameraMatrix, Size imgsize = Size(), bool centerPrincipalPoint = false)
  11455. //
  11456. /**
  11457. * Returns the default new camera matrix.
  11458. *
  11459. * The function returns the camera matrix that is either an exact copy of the input cameraMatrix (when
  11460. * centerPrinicipalPoint=false ), or the modified one (when centerPrincipalPoint=true).
  11461. *
  11462. * In the latter case, the new camera matrix will be:
  11463. *
  11464. * \(\begin{bmatrix} f_x &amp;&amp; 0 &amp;&amp; ( \texttt{imgSize.width} -1)*0.5 \\ 0 &amp;&amp; f_y &amp;&amp; ( \texttt{imgSize.height} -1)*0.5 \\ 0 &amp;&amp; 0 &amp;&amp; 1 \end{bmatrix} ,\)
  11465. *
  11466. * where \(f_x\) and \(f_y\) are \((0,0)\) and \((1,1)\) elements of cameraMatrix, respectively.
  11467. *
  11468. * By default, the undistortion functions in OpenCV (see #initUndistortRectifyMap, #undistort) do not
  11469. * move the principal point. However, when you work with stereo, it is important to move the principal
  11470. * points in both views to the same y-coordinate (which is required by most of stereo correspondence
  11471. * algorithms), and may be to the same x-coordinate too. So, you can form the new camera matrix for
  11472. * each view where the principal points are located at the center.
  11473. *
  11474. * param cameraMatrix Input camera matrix.
  11475. * param imgsize Camera view image size in pixels.
  11476. * param centerPrincipalPoint Location of the principal point in the new camera matrix. The
  11477. * parameter indicates whether this location should be at the image center or not.
  11478. * return automatically generated
  11479. */
  11480. public static Mat getDefaultNewCameraMatrix(Mat cameraMatrix, Size imgsize, bool centerPrincipalPoint)
  11481. {
  11482. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  11483. return new Mat(DisposableObject.ThrowIfNullIntPtr(calib3d_Calib3d_getDefaultNewCameraMatrix_10(cameraMatrix.nativeObj, imgsize.width, imgsize.height, centerPrincipalPoint)));
  11484. }
  11485. /**
  11486. * Returns the default new camera matrix.
  11487. *
  11488. * The function returns the camera matrix that is either an exact copy of the input cameraMatrix (when
  11489. * centerPrinicipalPoint=false ), or the modified one (when centerPrincipalPoint=true).
  11490. *
  11491. * In the latter case, the new camera matrix will be:
  11492. *
  11493. * \(\begin{bmatrix} f_x &amp;&amp; 0 &amp;&amp; ( \texttt{imgSize.width} -1)*0.5 \\ 0 &amp;&amp; f_y &amp;&amp; ( \texttt{imgSize.height} -1)*0.5 \\ 0 &amp;&amp; 0 &amp;&amp; 1 \end{bmatrix} ,\)
  11494. *
  11495. * where \(f_x\) and \(f_y\) are \((0,0)\) and \((1,1)\) elements of cameraMatrix, respectively.
  11496. *
  11497. * By default, the undistortion functions in OpenCV (see #initUndistortRectifyMap, #undistort) do not
  11498. * move the principal point. However, when you work with stereo, it is important to move the principal
  11499. * points in both views to the same y-coordinate (which is required by most of stereo correspondence
  11500. * algorithms), and may be to the same x-coordinate too. So, you can form the new camera matrix for
  11501. * each view where the principal points are located at the center.
  11502. *
  11503. * param cameraMatrix Input camera matrix.
  11504. * param imgsize Camera view image size in pixels.
  11505. * parameter indicates whether this location should be at the image center or not.
  11506. * return automatically generated
  11507. */
  11508. public static Mat getDefaultNewCameraMatrix(Mat cameraMatrix, Size imgsize)
  11509. {
  11510. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  11511. return new Mat(DisposableObject.ThrowIfNullIntPtr(calib3d_Calib3d_getDefaultNewCameraMatrix_11(cameraMatrix.nativeObj, imgsize.width, imgsize.height)));
  11512. }
  11513. /**
  11514. * Returns the default new camera matrix.
  11515. *
  11516. * The function returns the camera matrix that is either an exact copy of the input cameraMatrix (when
  11517. * centerPrinicipalPoint=false ), or the modified one (when centerPrincipalPoint=true).
  11518. *
  11519. * In the latter case, the new camera matrix will be:
  11520. *
  11521. * \(\begin{bmatrix} f_x &amp;&amp; 0 &amp;&amp; ( \texttt{imgSize.width} -1)*0.5 \\ 0 &amp;&amp; f_y &amp;&amp; ( \texttt{imgSize.height} -1)*0.5 \\ 0 &amp;&amp; 0 &amp;&amp; 1 \end{bmatrix} ,\)
  11522. *
  11523. * where \(f_x\) and \(f_y\) are \((0,0)\) and \((1,1)\) elements of cameraMatrix, respectively.
  11524. *
  11525. * By default, the undistortion functions in OpenCV (see #initUndistortRectifyMap, #undistort) do not
  11526. * move the principal point. However, when you work with stereo, it is important to move the principal
  11527. * points in both views to the same y-coordinate (which is required by most of stereo correspondence
  11528. * algorithms), and may be to the same x-coordinate too. So, you can form the new camera matrix for
  11529. * each view where the principal points are located at the center.
  11530. *
  11531. * param cameraMatrix Input camera matrix.
  11532. * parameter indicates whether this location should be at the image center or not.
  11533. * return automatically generated
  11534. */
  11535. public static Mat getDefaultNewCameraMatrix(Mat cameraMatrix)
  11536. {
  11537. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  11538. return new Mat(DisposableObject.ThrowIfNullIntPtr(calib3d_Calib3d_getDefaultNewCameraMatrix_12(cameraMatrix.nativeObj)));
  11539. }
  11540. //
  11541. // C++: void cv::undistortPoints(vector_Point2f src, vector_Point2f& dst, Mat cameraMatrix, Mat distCoeffs, Mat R = Mat(), Mat P = Mat())
  11542. //
  11543. /**
  11544. * Computes the ideal point coordinates from the observed point coordinates.
  11545. *
  11546. * The function is similar to #undistort and #initUndistortRectifyMap but it operates on a
  11547. * sparse set of points instead of a raster image. Also the function performs a reverse transformation
  11548. * to #projectPoints. In case of a 3D object, it does not reconstruct its 3D coordinates, but for a
  11549. * planar object, it does, up to a translation vector, if the proper R is specified.
  11550. *
  11551. * For each observed point coordinate \((u, v)\) the function computes:
  11552. * \(
  11553. * \begin{array}{l}
  11554. * x^{"} \leftarrow (u - c_x)/f_x \\
  11555. * y^{"} \leftarrow (v - c_y)/f_y \\
  11556. * (x',y') = undistort(x^{"},y^{"}, \texttt{distCoeffs}) \\
  11557. * {[X\,Y\,W]} ^T \leftarrow R*[x' \, y' \, 1]^T \\
  11558. * x \leftarrow X/W \\
  11559. * y \leftarrow Y/W \\
  11560. * \text{only performed if P is specified:} \\
  11561. * u' \leftarrow x {f'}_x + {c'}_x \\
  11562. * v' \leftarrow y {f'}_y + {c'}_y
  11563. * \end{array}
  11564. * \)
  11565. *
  11566. * where *undistort* is an approximate iterative algorithm that estimates the normalized original
  11567. * point coordinates out of the normalized distorted point coordinates ("normalized" means that the
  11568. * coordinates do not depend on the camera matrix).
  11569. *
  11570. * The function can be used for both a stereo camera head or a monocular camera (when R is empty).
  11571. * param src Observed point coordinates, 2xN/Nx2 1-channel or 1xN/Nx1 2-channel (CV_32FC2 or CV_64FC2) (or
  11572. * vector&lt;Point2f&gt; ).
  11573. * param dst Output ideal point coordinates (1xN/Nx1 2-channel or vector&lt;Point2f&gt; ) after undistortion and reverse perspective
  11574. * transformation. If matrix P is identity or omitted, dst will contain normalized point coordinates.
  11575. * param cameraMatrix Camera matrix \(\vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\) .
  11576. * param distCoeffs Input vector of distortion coefficients
  11577. * \((k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6[, s_1, s_2, s_3, s_4[, \tau_x, \tau_y]]]])\)
  11578. * of 4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed.
  11579. * param R Rectification transformation in the object space (3x3 matrix). R1 or R2 computed by
  11580. * #stereoRectify can be passed here. If the matrix is empty, the identity transformation is used.
  11581. * param P New camera matrix (3x3) or new projection matrix (3x4) \(\begin{bmatrix} {f'}_x &amp; 0 &amp; {c'}_x &amp; t_x \\ 0 &amp; {f'}_y &amp; {c'}_y &amp; t_y \\ 0 &amp; 0 &amp; 1 &amp; t_z \end{bmatrix}\). P1 or P2 computed by
  11582. * #stereoRectify can be passed here. If the matrix is empty, the identity new camera matrix is used.
  11583. */
  11584. public static void undistortPoints(MatOfPoint2f src, MatOfPoint2f dst, Mat cameraMatrix, Mat distCoeffs, Mat R, Mat P)
  11585. {
  11586. if (src != null) src.ThrowIfDisposed();
  11587. if (dst != null) dst.ThrowIfDisposed();
  11588. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  11589. if (distCoeffs != null) distCoeffs.ThrowIfDisposed();
  11590. if (R != null) R.ThrowIfDisposed();
  11591. if (P != null) P.ThrowIfDisposed();
  11592. Mat src_mat = src;
  11593. Mat dst_mat = dst;
  11594. calib3d_Calib3d_undistortPoints_10(src_mat.nativeObj, dst_mat.nativeObj, cameraMatrix.nativeObj, distCoeffs.nativeObj, R.nativeObj, P.nativeObj);
  11595. }
  11596. /**
  11597. * Computes the ideal point coordinates from the observed point coordinates.
  11598. *
  11599. * The function is similar to #undistort and #initUndistortRectifyMap but it operates on a
  11600. * sparse set of points instead of a raster image. Also the function performs a reverse transformation
  11601. * to #projectPoints. In case of a 3D object, it does not reconstruct its 3D coordinates, but for a
  11602. * planar object, it does, up to a translation vector, if the proper R is specified.
  11603. *
  11604. * For each observed point coordinate \((u, v)\) the function computes:
  11605. * \(
  11606. * \begin{array}{l}
  11607. * x^{"} \leftarrow (u - c_x)/f_x \\
  11608. * y^{"} \leftarrow (v - c_y)/f_y \\
  11609. * (x',y') = undistort(x^{"},y^{"}, \texttt{distCoeffs}) \\
  11610. * {[X\,Y\,W]} ^T \leftarrow R*[x' \, y' \, 1]^T \\
  11611. * x \leftarrow X/W \\
  11612. * y \leftarrow Y/W \\
  11613. * \text{only performed if P is specified:} \\
  11614. * u' \leftarrow x {f'}_x + {c'}_x \\
  11615. * v' \leftarrow y {f'}_y + {c'}_y
  11616. * \end{array}
  11617. * \)
  11618. *
  11619. * where *undistort* is an approximate iterative algorithm that estimates the normalized original
  11620. * point coordinates out of the normalized distorted point coordinates ("normalized" means that the
  11621. * coordinates do not depend on the camera matrix).
  11622. *
  11623. * The function can be used for both a stereo camera head or a monocular camera (when R is empty).
  11624. * param src Observed point coordinates, 2xN/Nx2 1-channel or 1xN/Nx1 2-channel (CV_32FC2 or CV_64FC2) (or
  11625. * vector&lt;Point2f&gt; ).
  11626. * param dst Output ideal point coordinates (1xN/Nx1 2-channel or vector&lt;Point2f&gt; ) after undistortion and reverse perspective
  11627. * transformation. If matrix P is identity or omitted, dst will contain normalized point coordinates.
  11628. * param cameraMatrix Camera matrix \(\vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\) .
  11629. * param distCoeffs Input vector of distortion coefficients
  11630. * \((k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6[, s_1, s_2, s_3, s_4[, \tau_x, \tau_y]]]])\)
  11631. * of 4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed.
  11632. * param R Rectification transformation in the object space (3x3 matrix). R1 or R2 computed by
  11633. * #stereoRectify can be passed here. If the matrix is empty, the identity transformation is used.
  11634. * #stereoRectify can be passed here. If the matrix is empty, the identity new camera matrix is used.
  11635. */
  11636. public static void undistortPoints(MatOfPoint2f src, MatOfPoint2f dst, Mat cameraMatrix, Mat distCoeffs, Mat R)
  11637. {
  11638. if (src != null) src.ThrowIfDisposed();
  11639. if (dst != null) dst.ThrowIfDisposed();
  11640. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  11641. if (distCoeffs != null) distCoeffs.ThrowIfDisposed();
  11642. if (R != null) R.ThrowIfDisposed();
  11643. Mat src_mat = src;
  11644. Mat dst_mat = dst;
  11645. calib3d_Calib3d_undistortPoints_11(src_mat.nativeObj, dst_mat.nativeObj, cameraMatrix.nativeObj, distCoeffs.nativeObj, R.nativeObj);
  11646. }
  11647. /**
  11648. * Computes the ideal point coordinates from the observed point coordinates.
  11649. *
  11650. * The function is similar to #undistort and #initUndistortRectifyMap but it operates on a
  11651. * sparse set of points instead of a raster image. Also the function performs a reverse transformation
  11652. * to #projectPoints. In case of a 3D object, it does not reconstruct its 3D coordinates, but for a
  11653. * planar object, it does, up to a translation vector, if the proper R is specified.
  11654. *
  11655. * For each observed point coordinate \((u, v)\) the function computes:
  11656. * \(
  11657. * \begin{array}{l}
  11658. * x^{"} \leftarrow (u - c_x)/f_x \\
  11659. * y^{"} \leftarrow (v - c_y)/f_y \\
  11660. * (x',y') = undistort(x^{"},y^{"}, \texttt{distCoeffs}) \\
  11661. * {[X\,Y\,W]} ^T \leftarrow R*[x' \, y' \, 1]^T \\
  11662. * x \leftarrow X/W \\
  11663. * y \leftarrow Y/W \\
  11664. * \text{only performed if P is specified:} \\
  11665. * u' \leftarrow x {f'}_x + {c'}_x \\
  11666. * v' \leftarrow y {f'}_y + {c'}_y
  11667. * \end{array}
  11668. * \)
  11669. *
  11670. * where *undistort* is an approximate iterative algorithm that estimates the normalized original
  11671. * point coordinates out of the normalized distorted point coordinates ("normalized" means that the
  11672. * coordinates do not depend on the camera matrix).
  11673. *
  11674. * The function can be used for both a stereo camera head or a monocular camera (when R is empty).
  11675. * param src Observed point coordinates, 2xN/Nx2 1-channel or 1xN/Nx1 2-channel (CV_32FC2 or CV_64FC2) (or
  11676. * vector&lt;Point2f&gt; ).
  11677. * param dst Output ideal point coordinates (1xN/Nx1 2-channel or vector&lt;Point2f&gt; ) after undistortion and reverse perspective
  11678. * transformation. If matrix P is identity or omitted, dst will contain normalized point coordinates.
  11679. * param cameraMatrix Camera matrix \(\vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\) .
  11680. * param distCoeffs Input vector of distortion coefficients
  11681. * \((k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6[, s_1, s_2, s_3, s_4[, \tau_x, \tau_y]]]])\)
  11682. * of 4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed.
  11683. * #stereoRectify can be passed here. If the matrix is empty, the identity transformation is used.
  11684. * #stereoRectify can be passed here. If the matrix is empty, the identity new camera matrix is used.
  11685. */
  11686. public static void undistortPoints(MatOfPoint2f src, MatOfPoint2f dst, Mat cameraMatrix, Mat distCoeffs)
  11687. {
  11688. if (src != null) src.ThrowIfDisposed();
  11689. if (dst != null) dst.ThrowIfDisposed();
  11690. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  11691. if (distCoeffs != null) distCoeffs.ThrowIfDisposed();
  11692. Mat src_mat = src;
  11693. Mat dst_mat = dst;
  11694. calib3d_Calib3d_undistortPoints_12(src_mat.nativeObj, dst_mat.nativeObj, cameraMatrix.nativeObj, distCoeffs.nativeObj);
  11695. }
  11696. //
  11697. // C++: void cv::undistortPoints(Mat src, Mat& dst, Mat cameraMatrix, Mat distCoeffs, Mat R, Mat P, TermCriteria criteria)
  11698. //
  11699. /**
  11700. *
  11701. * <b>Note:</b> Default version of #undistortPoints does 5 iterations to compute undistorted points.
  11702. * param src automatically generated
  11703. * param dst automatically generated
  11704. * param cameraMatrix automatically generated
  11705. * param distCoeffs automatically generated
  11706. * param R automatically generated
  11707. * param P automatically generated
  11708. * param criteria automatically generated
  11709. */
  11710. public static void undistortPointsIter(Mat src, Mat dst, Mat cameraMatrix, Mat distCoeffs, Mat R, Mat P, TermCriteria criteria)
  11711. {
  11712. if (src != null) src.ThrowIfDisposed();
  11713. if (dst != null) dst.ThrowIfDisposed();
  11714. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  11715. if (distCoeffs != null) distCoeffs.ThrowIfDisposed();
  11716. if (R != null) R.ThrowIfDisposed();
  11717. if (P != null) P.ThrowIfDisposed();
  11718. calib3d_Calib3d_undistortPointsIter_10(src.nativeObj, dst.nativeObj, cameraMatrix.nativeObj, distCoeffs.nativeObj, R.nativeObj, P.nativeObj, criteria.type, criteria.maxCount, criteria.epsilon);
  11719. }
  11720. //
  11721. // C++: void cv::undistortImagePoints(Mat src, Mat& dst, Mat cameraMatrix, Mat distCoeffs, TermCriteria arg1 = TermCriteria(TermCriteria::MAX_ITER + TermCriteria::EPS, 5, 0.01))
  11722. //
  11723. /**
  11724. * Compute undistorted image points position
  11725. *
  11726. * param src Observed points position, 2xN/Nx2 1-channel or 1xN/Nx1 2-channel (CV_32FC2 or
  11727. * CV_64FC2) (or vector&lt;Point2f&gt; ).
  11728. * param dst Output undistorted points position (1xN/Nx1 2-channel or vector&lt;Point2f&gt; ).
  11729. * param cameraMatrix Camera matrix \(\vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\) .
  11730. * param distCoeffs Distortion coefficients
  11731. * param arg1 automatically generated
  11732. */
  11733. public static void undistortImagePoints(Mat src, Mat dst, Mat cameraMatrix, Mat distCoeffs, TermCriteria arg1)
  11734. {
  11735. if (src != null) src.ThrowIfDisposed();
  11736. if (dst != null) dst.ThrowIfDisposed();
  11737. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  11738. if (distCoeffs != null) distCoeffs.ThrowIfDisposed();
  11739. calib3d_Calib3d_undistortImagePoints_10(src.nativeObj, dst.nativeObj, cameraMatrix.nativeObj, distCoeffs.nativeObj, arg1.type, arg1.maxCount, arg1.epsilon);
  11740. }
  11741. /**
  11742. * Compute undistorted image points position
  11743. *
  11744. * param src Observed points position, 2xN/Nx2 1-channel or 1xN/Nx1 2-channel (CV_32FC2 or
  11745. * CV_64FC2) (or vector&lt;Point2f&gt; ).
  11746. * param dst Output undistorted points position (1xN/Nx1 2-channel or vector&lt;Point2f&gt; ).
  11747. * param cameraMatrix Camera matrix \(\vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\) .
  11748. * param distCoeffs Distortion coefficients
  11749. */
  11750. public static void undistortImagePoints(Mat src, Mat dst, Mat cameraMatrix, Mat distCoeffs)
  11751. {
  11752. if (src != null) src.ThrowIfDisposed();
  11753. if (dst != null) dst.ThrowIfDisposed();
  11754. if (cameraMatrix != null) cameraMatrix.ThrowIfDisposed();
  11755. if (distCoeffs != null) distCoeffs.ThrowIfDisposed();
  11756. calib3d_Calib3d_undistortImagePoints_11(src.nativeObj, dst.nativeObj, cameraMatrix.nativeObj, distCoeffs.nativeObj);
  11757. }
  11758. //
  11759. // C++: void cv::fisheye::projectPoints(Mat objectPoints, Mat& imagePoints, Mat rvec, Mat tvec, Mat K, Mat D, double alpha = 0, Mat& jacobian = Mat())
  11760. //
  11761. public static void fisheye_projectPoints(Mat objectPoints, Mat imagePoints, Mat rvec, Mat tvec, Mat K, Mat D, double alpha, Mat jacobian)
  11762. {
  11763. if (objectPoints != null) objectPoints.ThrowIfDisposed();
  11764. if (imagePoints != null) imagePoints.ThrowIfDisposed();
  11765. if (rvec != null) rvec.ThrowIfDisposed();
  11766. if (tvec != null) tvec.ThrowIfDisposed();
  11767. if (K != null) K.ThrowIfDisposed();
  11768. if (D != null) D.ThrowIfDisposed();
  11769. if (jacobian != null) jacobian.ThrowIfDisposed();
  11770. calib3d_Calib3d_fisheye_1projectPoints_10(objectPoints.nativeObj, imagePoints.nativeObj, rvec.nativeObj, tvec.nativeObj, K.nativeObj, D.nativeObj, alpha, jacobian.nativeObj);
  11771. }
  11772. public static void fisheye_projectPoints(Mat objectPoints, Mat imagePoints, Mat rvec, Mat tvec, Mat K, Mat D, double alpha)
  11773. {
  11774. if (objectPoints != null) objectPoints.ThrowIfDisposed();
  11775. if (imagePoints != null) imagePoints.ThrowIfDisposed();
  11776. if (rvec != null) rvec.ThrowIfDisposed();
  11777. if (tvec != null) tvec.ThrowIfDisposed();
  11778. if (K != null) K.ThrowIfDisposed();
  11779. if (D != null) D.ThrowIfDisposed();
  11780. calib3d_Calib3d_fisheye_1projectPoints_11(objectPoints.nativeObj, imagePoints.nativeObj, rvec.nativeObj, tvec.nativeObj, K.nativeObj, D.nativeObj, alpha);
  11781. }
  11782. public static void fisheye_projectPoints(Mat objectPoints, Mat imagePoints, Mat rvec, Mat tvec, Mat K, Mat D)
  11783. {
  11784. if (objectPoints != null) objectPoints.ThrowIfDisposed();
  11785. if (imagePoints != null) imagePoints.ThrowIfDisposed();
  11786. if (rvec != null) rvec.ThrowIfDisposed();
  11787. if (tvec != null) tvec.ThrowIfDisposed();
  11788. if (K != null) K.ThrowIfDisposed();
  11789. if (D != null) D.ThrowIfDisposed();
  11790. calib3d_Calib3d_fisheye_1projectPoints_12(objectPoints.nativeObj, imagePoints.nativeObj, rvec.nativeObj, tvec.nativeObj, K.nativeObj, D.nativeObj);
  11791. }
  11792. //
  11793. // C++: void cv::fisheye::distortPoints(Mat undistorted, Mat& distorted, Mat K, Mat D, double alpha = 0)
  11794. //
  11795. /**
  11796. * Distorts 2D points using fisheye model.
  11797. *
  11798. * param undistorted Array of object points, 1xN/Nx1 2-channel (or vector&lt;Point2f&gt; ), where N is
  11799. * the number of points in the view.
  11800. * param K Camera intrinsic matrix \(cameramatrix{K}\).
  11801. * param D Input vector of distortion coefficients \(\distcoeffsfisheye\).
  11802. * param alpha The skew coefficient.
  11803. * param distorted Output array of image points, 1xN/Nx1 2-channel, or vector&lt;Point2f&gt; .
  11804. *
  11805. * Note that the function assumes the camera intrinsic matrix of the undistorted points to be identity.
  11806. * This means if you want to distort image points you have to multiply them with \(K^{-1}\).
  11807. */
  11808. public static void fisheye_distortPoints(Mat undistorted, Mat distorted, Mat K, Mat D, double alpha)
  11809. {
  11810. if (undistorted != null) undistorted.ThrowIfDisposed();
  11811. if (distorted != null) distorted.ThrowIfDisposed();
  11812. if (K != null) K.ThrowIfDisposed();
  11813. if (D != null) D.ThrowIfDisposed();
  11814. calib3d_Calib3d_fisheye_1distortPoints_10(undistorted.nativeObj, distorted.nativeObj, K.nativeObj, D.nativeObj, alpha);
  11815. }
  11816. /**
  11817. * Distorts 2D points using fisheye model.
  11818. *
  11819. * param undistorted Array of object points, 1xN/Nx1 2-channel (or vector&lt;Point2f&gt; ), where N is
  11820. * the number of points in the view.
  11821. * param K Camera intrinsic matrix \(cameramatrix{K}\).
  11822. * param D Input vector of distortion coefficients \(\distcoeffsfisheye\).
  11823. * param distorted Output array of image points, 1xN/Nx1 2-channel, or vector&lt;Point2f&gt; .
  11824. *
  11825. * Note that the function assumes the camera intrinsic matrix of the undistorted points to be identity.
  11826. * This means if you want to distort image points you have to multiply them with \(K^{-1}\).
  11827. */
  11828. public static void fisheye_distortPoints(Mat undistorted, Mat distorted, Mat K, Mat D)
  11829. {
  11830. if (undistorted != null) undistorted.ThrowIfDisposed();
  11831. if (distorted != null) distorted.ThrowIfDisposed();
  11832. if (K != null) K.ThrowIfDisposed();
  11833. if (D != null) D.ThrowIfDisposed();
  11834. calib3d_Calib3d_fisheye_1distortPoints_11(undistorted.nativeObj, distorted.nativeObj, K.nativeObj, D.nativeObj);
  11835. }
  11836. //
  11837. // C++: void cv::fisheye::undistortPoints(Mat distorted, Mat& undistorted, Mat K, Mat D, Mat R = Mat(), Mat P = Mat(), TermCriteria criteria = TermCriteria(TermCriteria::MAX_ITER + TermCriteria::EPS, 10, 1e-8))
  11838. //
  11839. /**
  11840. * Undistorts 2D points using fisheye model
  11841. *
  11842. * param distorted Array of object points, 1xN/Nx1 2-channel (or vector&lt;Point2f&gt; ), where N is the
  11843. * number of points in the view.
  11844. * param K Camera intrinsic matrix \(cameramatrix{K}\).
  11845. * param D Input vector of distortion coefficients \(\distcoeffsfisheye\).
  11846. * param R Rectification transformation in the object space: 3x3 1-channel, or vector: 3x1/1x3
  11847. * 1-channel or 1x1 3-channel
  11848. * param P New camera intrinsic matrix (3x3) or new projection matrix (3x4)
  11849. * param criteria Termination criteria
  11850. * param undistorted Output array of image points, 1xN/Nx1 2-channel, or vector&lt;Point2f&gt; .
  11851. */
  11852. public static void fisheye_undistortPoints(Mat distorted, Mat undistorted, Mat K, Mat D, Mat R, Mat P, TermCriteria criteria)
  11853. {
  11854. if (distorted != null) distorted.ThrowIfDisposed();
  11855. if (undistorted != null) undistorted.ThrowIfDisposed();
  11856. if (K != null) K.ThrowIfDisposed();
  11857. if (D != null) D.ThrowIfDisposed();
  11858. if (R != null) R.ThrowIfDisposed();
  11859. if (P != null) P.ThrowIfDisposed();
  11860. calib3d_Calib3d_fisheye_1undistortPoints_10(distorted.nativeObj, undistorted.nativeObj, K.nativeObj, D.nativeObj, R.nativeObj, P.nativeObj, criteria.type, criteria.maxCount, criteria.epsilon);
  11861. }
  11862. /**
  11863. * Undistorts 2D points using fisheye model
  11864. *
  11865. * param distorted Array of object points, 1xN/Nx1 2-channel (or vector&lt;Point2f&gt; ), where N is the
  11866. * number of points in the view.
  11867. * param K Camera intrinsic matrix \(cameramatrix{K}\).
  11868. * param D Input vector of distortion coefficients \(\distcoeffsfisheye\).
  11869. * param R Rectification transformation in the object space: 3x3 1-channel, or vector: 3x1/1x3
  11870. * 1-channel or 1x1 3-channel
  11871. * param P New camera intrinsic matrix (3x3) or new projection matrix (3x4)
  11872. * param undistorted Output array of image points, 1xN/Nx1 2-channel, or vector&lt;Point2f&gt; .
  11873. */
  11874. public static void fisheye_undistortPoints(Mat distorted, Mat undistorted, Mat K, Mat D, Mat R, Mat P)
  11875. {
  11876. if (distorted != null) distorted.ThrowIfDisposed();
  11877. if (undistorted != null) undistorted.ThrowIfDisposed();
  11878. if (K != null) K.ThrowIfDisposed();
  11879. if (D != null) D.ThrowIfDisposed();
  11880. if (R != null) R.ThrowIfDisposed();
  11881. if (P != null) P.ThrowIfDisposed();
  11882. calib3d_Calib3d_fisheye_1undistortPoints_11(distorted.nativeObj, undistorted.nativeObj, K.nativeObj, D.nativeObj, R.nativeObj, P.nativeObj);
  11883. }
  11884. /**
  11885. * Undistorts 2D points using fisheye model
  11886. *
  11887. * param distorted Array of object points, 1xN/Nx1 2-channel (or vector&lt;Point2f&gt; ), where N is the
  11888. * number of points in the view.
  11889. * param K Camera intrinsic matrix \(cameramatrix{K}\).
  11890. * param D Input vector of distortion coefficients \(\distcoeffsfisheye\).
  11891. * param R Rectification transformation in the object space: 3x3 1-channel, or vector: 3x1/1x3
  11892. * 1-channel or 1x1 3-channel
  11893. * param undistorted Output array of image points, 1xN/Nx1 2-channel, or vector&lt;Point2f&gt; .
  11894. */
  11895. public static void fisheye_undistortPoints(Mat distorted, Mat undistorted, Mat K, Mat D, Mat R)
  11896. {
  11897. if (distorted != null) distorted.ThrowIfDisposed();
  11898. if (undistorted != null) undistorted.ThrowIfDisposed();
  11899. if (K != null) K.ThrowIfDisposed();
  11900. if (D != null) D.ThrowIfDisposed();
  11901. if (R != null) R.ThrowIfDisposed();
  11902. calib3d_Calib3d_fisheye_1undistortPoints_12(distorted.nativeObj, undistorted.nativeObj, K.nativeObj, D.nativeObj, R.nativeObj);
  11903. }
  11904. /**
  11905. * Undistorts 2D points using fisheye model
  11906. *
  11907. * param distorted Array of object points, 1xN/Nx1 2-channel (or vector&lt;Point2f&gt; ), where N is the
  11908. * number of points in the view.
  11909. * param K Camera intrinsic matrix \(cameramatrix{K}\).
  11910. * param D Input vector of distortion coefficients \(\distcoeffsfisheye\).
  11911. * 1-channel or 1x1 3-channel
  11912. * param undistorted Output array of image points, 1xN/Nx1 2-channel, or vector&lt;Point2f&gt; .
  11913. */
  11914. public static void fisheye_undistortPoints(Mat distorted, Mat undistorted, Mat K, Mat D)
  11915. {
  11916. if (distorted != null) distorted.ThrowIfDisposed();
  11917. if (undistorted != null) undistorted.ThrowIfDisposed();
  11918. if (K != null) K.ThrowIfDisposed();
  11919. if (D != null) D.ThrowIfDisposed();
  11920. calib3d_Calib3d_fisheye_1undistortPoints_13(distorted.nativeObj, undistorted.nativeObj, K.nativeObj, D.nativeObj);
  11921. }
  11922. //
  11923. // C++: void cv::fisheye::initUndistortRectifyMap(Mat K, Mat D, Mat R, Mat P, Size size, int m1type, Mat& map1, Mat& map2)
  11924. //
  11925. /**
  11926. * Computes undistortion and rectification maps for image transform by #remap. If D is empty zero
  11927. * distortion is used, if R or P is empty identity matrixes are used.
  11928. *
  11929. * param K Camera intrinsic matrix \(cameramatrix{K}\).
  11930. * param D Input vector of distortion coefficients \(\distcoeffsfisheye\).
  11931. * param R Rectification transformation in the object space: 3x3 1-channel, or vector: 3x1/1x3
  11932. * 1-channel or 1x1 3-channel
  11933. * param P New camera intrinsic matrix (3x3) or new projection matrix (3x4)
  11934. * param size Undistorted image size.
  11935. * param m1type Type of the first output map that can be CV_32FC1 or CV_16SC2 . See #convertMaps
  11936. * for details.
  11937. * param map1 The first output map.
  11938. * param map2 The second output map.
  11939. */
  11940. public static void fisheye_initUndistortRectifyMap(Mat K, Mat D, Mat R, Mat P, Size size, int m1type, Mat map1, Mat map2)
  11941. {
  11942. if (K != null) K.ThrowIfDisposed();
  11943. if (D != null) D.ThrowIfDisposed();
  11944. if (R != null) R.ThrowIfDisposed();
  11945. if (P != null) P.ThrowIfDisposed();
  11946. if (map1 != null) map1.ThrowIfDisposed();
  11947. if (map2 != null) map2.ThrowIfDisposed();
  11948. calib3d_Calib3d_fisheye_1initUndistortRectifyMap_10(K.nativeObj, D.nativeObj, R.nativeObj, P.nativeObj, size.width, size.height, m1type, map1.nativeObj, map2.nativeObj);
  11949. }
  11950. //
  11951. // C++: void cv::fisheye::undistortImage(Mat distorted, Mat& undistorted, Mat K, Mat D, Mat Knew = cv::Mat(), Size new_size = Size())
  11952. //
  11953. /**
  11954. * Transforms an image to compensate for fisheye lens distortion.
  11955. *
  11956. * param distorted image with fisheye lens distortion.
  11957. * param undistorted Output image with compensated fisheye lens distortion.
  11958. * param K Camera intrinsic matrix \(cameramatrix{K}\).
  11959. * param D Input vector of distortion coefficients \(\distcoeffsfisheye\).
  11960. * param Knew Camera intrinsic matrix of the distorted image. By default, it is the identity matrix but you
  11961. * may additionally scale and shift the result by using a different matrix.
  11962. * param new_size the new size
  11963. *
  11964. * The function transforms an image to compensate radial and tangential lens distortion.
  11965. *
  11966. * The function is simply a combination of #fisheye::initUndistortRectifyMap (with unity R ) and #remap
  11967. * (with bilinear interpolation). See the former function for details of the transformation being
  11968. * performed.
  11969. *
  11970. * See below the results of undistortImage.
  11971. * <ul>
  11972. * <li>
  11973. * a\) result of undistort of perspective camera model (all possible coefficients (k_1, k_2, k_3,
  11974. * k_4, k_5, k_6) of distortion were optimized under calibration)
  11975. * <ul>
  11976. * <li>
  11977. * b\) result of #fisheye::undistortImage of fisheye camera model (all possible coefficients (k_1, k_2,
  11978. * k_3, k_4) of fisheye distortion were optimized under calibration)
  11979. * </li>
  11980. * <li>
  11981. * c\) original image was captured with fisheye lens
  11982. * </li>
  11983. * </ul>
  11984. *
  11985. * Pictures a) and b) almost the same. But if we consider points of image located far from the center
  11986. * of image, we can notice that on image a) these points are distorted.
  11987. * </li>
  11988. * </ul>
  11989. *
  11990. * ![image](pics/fisheye_undistorted.jpg)
  11991. */
  11992. public static void fisheye_undistortImage(Mat distorted, Mat undistorted, Mat K, Mat D, Mat Knew, Size new_size)
  11993. {
  11994. if (distorted != null) distorted.ThrowIfDisposed();
  11995. if (undistorted != null) undistorted.ThrowIfDisposed();
  11996. if (K != null) K.ThrowIfDisposed();
  11997. if (D != null) D.ThrowIfDisposed();
  11998. if (Knew != null) Knew.ThrowIfDisposed();
  11999. calib3d_Calib3d_fisheye_1undistortImage_10(distorted.nativeObj, undistorted.nativeObj, K.nativeObj, D.nativeObj, Knew.nativeObj, new_size.width, new_size.height);
  12000. }
  12001. /**
  12002. * Transforms an image to compensate for fisheye lens distortion.
  12003. *
  12004. * param distorted image with fisheye lens distortion.
  12005. * param undistorted Output image with compensated fisheye lens distortion.
  12006. * param K Camera intrinsic matrix \(cameramatrix{K}\).
  12007. * param D Input vector of distortion coefficients \(\distcoeffsfisheye\).
  12008. * param Knew Camera intrinsic matrix of the distorted image. By default, it is the identity matrix but you
  12009. * may additionally scale and shift the result by using a different matrix.
  12010. *
  12011. * The function transforms an image to compensate radial and tangential lens distortion.
  12012. *
  12013. * The function is simply a combination of #fisheye::initUndistortRectifyMap (with unity R ) and #remap
  12014. * (with bilinear interpolation). See the former function for details of the transformation being
  12015. * performed.
  12016. *
  12017. * See below the results of undistortImage.
  12018. * <ul>
  12019. * <li>
  12020. * a\) result of undistort of perspective camera model (all possible coefficients (k_1, k_2, k_3,
  12021. * k_4, k_5, k_6) of distortion were optimized under calibration)
  12022. * <ul>
  12023. * <li>
  12024. * b\) result of #fisheye::undistortImage of fisheye camera model (all possible coefficients (k_1, k_2,
  12025. * k_3, k_4) of fisheye distortion were optimized under calibration)
  12026. * </li>
  12027. * <li>
  12028. * c\) original image was captured with fisheye lens
  12029. * </li>
  12030. * </ul>
  12031. *
  12032. * Pictures a) and b) almost the same. But if we consider points of image located far from the center
  12033. * of image, we can notice that on image a) these points are distorted.
  12034. * </li>
  12035. * </ul>
  12036. *
  12037. * ![image](pics/fisheye_undistorted.jpg)
  12038. */
  12039. public static void fisheye_undistortImage(Mat distorted, Mat undistorted, Mat K, Mat D, Mat Knew)
  12040. {
  12041. if (distorted != null) distorted.ThrowIfDisposed();
  12042. if (undistorted != null) undistorted.ThrowIfDisposed();
  12043. if (K != null) K.ThrowIfDisposed();
  12044. if (D != null) D.ThrowIfDisposed();
  12045. if (Knew != null) Knew.ThrowIfDisposed();
  12046. calib3d_Calib3d_fisheye_1undistortImage_11(distorted.nativeObj, undistorted.nativeObj, K.nativeObj, D.nativeObj, Knew.nativeObj);
  12047. }
  12048. /**
  12049. * Transforms an image to compensate for fisheye lens distortion.
  12050. *
  12051. * param distorted image with fisheye lens distortion.
  12052. * param undistorted Output image with compensated fisheye lens distortion.
  12053. * param K Camera intrinsic matrix \(cameramatrix{K}\).
  12054. * param D Input vector of distortion coefficients \(\distcoeffsfisheye\).
  12055. * may additionally scale and shift the result by using a different matrix.
  12056. *
  12057. * The function transforms an image to compensate radial and tangential lens distortion.
  12058. *
  12059. * The function is simply a combination of #fisheye::initUndistortRectifyMap (with unity R ) and #remap
  12060. * (with bilinear interpolation). See the former function for details of the transformation being
  12061. * performed.
  12062. *
  12063. * See below the results of undistortImage.
  12064. * <ul>
  12065. * <li>
  12066. * a\) result of undistort of perspective camera model (all possible coefficients (k_1, k_2, k_3,
  12067. * k_4, k_5, k_6) of distortion were optimized under calibration)
  12068. * <ul>
  12069. * <li>
  12070. * b\) result of #fisheye::undistortImage of fisheye camera model (all possible coefficients (k_1, k_2,
  12071. * k_3, k_4) of fisheye distortion were optimized under calibration)
  12072. * </li>
  12073. * <li>
  12074. * c\) original image was captured with fisheye lens
  12075. * </li>
  12076. * </ul>
  12077. *
  12078. * Pictures a) and b) almost the same. But if we consider points of image located far from the center
  12079. * of image, we can notice that on image a) these points are distorted.
  12080. * </li>
  12081. * </ul>
  12082. *
  12083. * ![image](pics/fisheye_undistorted.jpg)
  12084. */
  12085. public static void fisheye_undistortImage(Mat distorted, Mat undistorted, Mat K, Mat D)
  12086. {
  12087. if (distorted != null) distorted.ThrowIfDisposed();
  12088. if (undistorted != null) undistorted.ThrowIfDisposed();
  12089. if (K != null) K.ThrowIfDisposed();
  12090. if (D != null) D.ThrowIfDisposed();
  12091. calib3d_Calib3d_fisheye_1undistortImage_12(distorted.nativeObj, undistorted.nativeObj, K.nativeObj, D.nativeObj);
  12092. }
  12093. //
  12094. // C++: void cv::fisheye::estimateNewCameraMatrixForUndistortRectify(Mat K, Mat D, Size image_size, Mat R, Mat& P, double balance = 0.0, Size new_size = Size(), double fov_scale = 1.0)
  12095. //
  12096. /**
  12097. * Estimates new camera intrinsic matrix for undistortion or rectification.
  12098. *
  12099. * param K Camera intrinsic matrix \(cameramatrix{K}\).
  12100. * param image_size Size of the image
  12101. * param D Input vector of distortion coefficients \(\distcoeffsfisheye\).
  12102. * param R Rectification transformation in the object space: 3x3 1-channel, or vector: 3x1/1x3
  12103. * 1-channel or 1x1 3-channel
  12104. * param P New camera intrinsic matrix (3x3) or new projection matrix (3x4)
  12105. * param balance Sets the new focal length in range between the min focal length and the max focal
  12106. * length. Balance is in range of [0, 1].
  12107. * param new_size the new size
  12108. * param fov_scale Divisor for new focal length.
  12109. */
  12110. public static void fisheye_estimateNewCameraMatrixForUndistortRectify(Mat K, Mat D, Size image_size, Mat R, Mat P, double balance, Size new_size, double fov_scale)
  12111. {
  12112. if (K != null) K.ThrowIfDisposed();
  12113. if (D != null) D.ThrowIfDisposed();
  12114. if (R != null) R.ThrowIfDisposed();
  12115. if (P != null) P.ThrowIfDisposed();
  12116. calib3d_Calib3d_fisheye_1estimateNewCameraMatrixForUndistortRectify_10(K.nativeObj, D.nativeObj, image_size.width, image_size.height, R.nativeObj, P.nativeObj, balance, new_size.width, new_size.height, fov_scale);
  12117. }
  12118. /**
  12119. * Estimates new camera intrinsic matrix for undistortion or rectification.
  12120. *
  12121. * param K Camera intrinsic matrix \(cameramatrix{K}\).
  12122. * param image_size Size of the image
  12123. * param D Input vector of distortion coefficients \(\distcoeffsfisheye\).
  12124. * param R Rectification transformation in the object space: 3x3 1-channel, or vector: 3x1/1x3
  12125. * 1-channel or 1x1 3-channel
  12126. * param P New camera intrinsic matrix (3x3) or new projection matrix (3x4)
  12127. * param balance Sets the new focal length in range between the min focal length and the max focal
  12128. * length. Balance is in range of [0, 1].
  12129. * param new_size the new size
  12130. */
  12131. public static void fisheye_estimateNewCameraMatrixForUndistortRectify(Mat K, Mat D, Size image_size, Mat R, Mat P, double balance, Size new_size)
  12132. {
  12133. if (K != null) K.ThrowIfDisposed();
  12134. if (D != null) D.ThrowIfDisposed();
  12135. if (R != null) R.ThrowIfDisposed();
  12136. if (P != null) P.ThrowIfDisposed();
  12137. calib3d_Calib3d_fisheye_1estimateNewCameraMatrixForUndistortRectify_11(K.nativeObj, D.nativeObj, image_size.width, image_size.height, R.nativeObj, P.nativeObj, balance, new_size.width, new_size.height);
  12138. }
  12139. /**
  12140. * Estimates new camera intrinsic matrix for undistortion or rectification.
  12141. *
  12142. * param K Camera intrinsic matrix \(cameramatrix{K}\).
  12143. * param image_size Size of the image
  12144. * param D Input vector of distortion coefficients \(\distcoeffsfisheye\).
  12145. * param R Rectification transformation in the object space: 3x3 1-channel, or vector: 3x1/1x3
  12146. * 1-channel or 1x1 3-channel
  12147. * param P New camera intrinsic matrix (3x3) or new projection matrix (3x4)
  12148. * param balance Sets the new focal length in range between the min focal length and the max focal
  12149. * length. Balance is in range of [0, 1].
  12150. */
  12151. public static void fisheye_estimateNewCameraMatrixForUndistortRectify(Mat K, Mat D, Size image_size, Mat R, Mat P, double balance)
  12152. {
  12153. if (K != null) K.ThrowIfDisposed();
  12154. if (D != null) D.ThrowIfDisposed();
  12155. if (R != null) R.ThrowIfDisposed();
  12156. if (P != null) P.ThrowIfDisposed();
  12157. calib3d_Calib3d_fisheye_1estimateNewCameraMatrixForUndistortRectify_12(K.nativeObj, D.nativeObj, image_size.width, image_size.height, R.nativeObj, P.nativeObj, balance);
  12158. }
  12159. /**
  12160. * Estimates new camera intrinsic matrix for undistortion or rectification.
  12161. *
  12162. * param K Camera intrinsic matrix \(cameramatrix{K}\).
  12163. * param image_size Size of the image
  12164. * param D Input vector of distortion coefficients \(\distcoeffsfisheye\).
  12165. * param R Rectification transformation in the object space: 3x3 1-channel, or vector: 3x1/1x3
  12166. * 1-channel or 1x1 3-channel
  12167. * param P New camera intrinsic matrix (3x3) or new projection matrix (3x4)
  12168. * length. Balance is in range of [0, 1].
  12169. */
  12170. public static void fisheye_estimateNewCameraMatrixForUndistortRectify(Mat K, Mat D, Size image_size, Mat R, Mat P)
  12171. {
  12172. if (K != null) K.ThrowIfDisposed();
  12173. if (D != null) D.ThrowIfDisposed();
  12174. if (R != null) R.ThrowIfDisposed();
  12175. if (P != null) P.ThrowIfDisposed();
  12176. calib3d_Calib3d_fisheye_1estimateNewCameraMatrixForUndistortRectify_13(K.nativeObj, D.nativeObj, image_size.width, image_size.height, R.nativeObj, P.nativeObj);
  12177. }
  12178. //
  12179. // C++: double cv::fisheye::calibrate(vector_Mat objectPoints, vector_Mat imagePoints, Size image_size, Mat& K, Mat& D, vector_Mat& rvecs, vector_Mat& tvecs, int flags = 0, TermCriteria criteria = TermCriteria(TermCriteria::COUNT + TermCriteria::EPS, 100, DBL_EPSILON))
  12180. //
  12181. /**
  12182. * Performs camera calibration
  12183. *
  12184. * param objectPoints vector of vectors of calibration pattern points in the calibration pattern
  12185. * coordinate space.
  12186. * param imagePoints vector of vectors of the projections of calibration pattern points.
  12187. * imagePoints.size() and objectPoints.size() and imagePoints[i].size() must be equal to
  12188. * objectPoints[i].size() for each i.
  12189. * param image_size Size of the image used only to initialize the camera intrinsic matrix.
  12190. * param K Output 3x3 floating-point camera intrinsic matrix
  12191. * \(\cameramatrix{A}\) . If
  12192. * REF: fisheye::CALIB_USE_INTRINSIC_GUESS is specified, some or all of fx, fy, cx, cy must be
  12193. * initialized before calling the function.
  12194. * param D Output vector of distortion coefficients \(\distcoeffsfisheye\).
  12195. * param rvecs Output vector of rotation vectors (see Rodrigues ) estimated for each pattern view.
  12196. * That is, each k-th rotation vector together with the corresponding k-th translation vector (see
  12197. * the next output parameter description) brings the calibration pattern from the model coordinate
  12198. * space (in which object points are specified) to the world coordinate space, that is, a real
  12199. * position of the calibration pattern in the k-th pattern view (k=0.. *M* -1).
  12200. * param tvecs Output vector of translation vectors estimated for each pattern view.
  12201. * param flags Different flags that may be zero or a combination of the following values:
  12202. * <ul>
  12203. * <li>
  12204. * REF: fisheye::CALIB_USE_INTRINSIC_GUESS cameraMatrix contains valid initial values of
  12205. * fx, fy, cx, cy that are optimized further. Otherwise, (cx, cy) is initially set to the image
  12206. * center ( imageSize is used), and focal distances are computed in a least-squares fashion.
  12207. * </li>
  12208. * <li>
  12209. * REF: fisheye::CALIB_RECOMPUTE_EXTRINSIC Extrinsic will be recomputed after each iteration
  12210. * of intrinsic optimization.
  12211. * </li>
  12212. * <li>
  12213. * REF: fisheye::CALIB_CHECK_COND The functions will check validity of condition number.
  12214. * </li>
  12215. * <li>
  12216. * REF: fisheye::CALIB_FIX_SKEW Skew coefficient (alpha) is set to zero and stay zero.
  12217. * </li>
  12218. * <li>
  12219. * REF: fisheye::CALIB_FIX_K1,..., REF: fisheye::CALIB_FIX_K4 Selected distortion coefficients
  12220. * are set to zeros and stay zero.
  12221. * </li>
  12222. * <li>
  12223. * REF: fisheye::CALIB_FIX_PRINCIPAL_POINT The principal point is not changed during the global
  12224. * optimization. It stays at the center or at a different location specified when REF: fisheye::CALIB_USE_INTRINSIC_GUESS is set too.
  12225. * </li>
  12226. * <li>
  12227. * REF: fisheye::CALIB_FIX_FOCAL_LENGTH The focal length is not changed during the global
  12228. * optimization. It is the \(max(width,height)/\pi\) or the provided \(f_x\), \(f_y\) when REF: fisheye::CALIB_USE_INTRINSIC_GUESS is set too.
  12229. * </li>
  12230. * </ul>
  12231. * param criteria Termination criteria for the iterative optimization algorithm.
  12232. * return automatically generated
  12233. */
  12234. public static double fisheye_calibrate(List<Mat> objectPoints, List<Mat> imagePoints, Size image_size, Mat K, Mat D, List<Mat> rvecs, List<Mat> tvecs, int flags, TermCriteria criteria)
  12235. {
  12236. if (K != null) K.ThrowIfDisposed();
  12237. if (D != null) D.ThrowIfDisposed();
  12238. Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints);
  12239. Mat imagePoints_mat = Converters.vector_Mat_to_Mat(imagePoints);
  12240. Mat rvecs_mat = new Mat();
  12241. Mat tvecs_mat = new Mat();
  12242. double retVal = calib3d_Calib3d_fisheye_1calibrate_10(objectPoints_mat.nativeObj, imagePoints_mat.nativeObj, image_size.width, image_size.height, K.nativeObj, D.nativeObj, rvecs_mat.nativeObj, tvecs_mat.nativeObj, flags, criteria.type, criteria.maxCount, criteria.epsilon);
  12243. Converters.Mat_to_vector_Mat(rvecs_mat, rvecs);
  12244. rvecs_mat.release();
  12245. Converters.Mat_to_vector_Mat(tvecs_mat, tvecs);
  12246. tvecs_mat.release();
  12247. return retVal;
  12248. }
  12249. /**
  12250. * Performs camera calibration
  12251. *
  12252. * param objectPoints vector of vectors of calibration pattern points in the calibration pattern
  12253. * coordinate space.
  12254. * param imagePoints vector of vectors of the projections of calibration pattern points.
  12255. * imagePoints.size() and objectPoints.size() and imagePoints[i].size() must be equal to
  12256. * objectPoints[i].size() for each i.
  12257. * param image_size Size of the image used only to initialize the camera intrinsic matrix.
  12258. * param K Output 3x3 floating-point camera intrinsic matrix
  12259. * \(\cameramatrix{A}\) . If
  12260. * REF: fisheye::CALIB_USE_INTRINSIC_GUESS is specified, some or all of fx, fy, cx, cy must be
  12261. * initialized before calling the function.
  12262. * param D Output vector of distortion coefficients \(\distcoeffsfisheye\).
  12263. * param rvecs Output vector of rotation vectors (see Rodrigues ) estimated for each pattern view.
  12264. * That is, each k-th rotation vector together with the corresponding k-th translation vector (see
  12265. * the next output parameter description) brings the calibration pattern from the model coordinate
  12266. * space (in which object points are specified) to the world coordinate space, that is, a real
  12267. * position of the calibration pattern in the k-th pattern view (k=0.. *M* -1).
  12268. * param tvecs Output vector of translation vectors estimated for each pattern view.
  12269. * param flags Different flags that may be zero or a combination of the following values:
  12270. * <ul>
  12271. * <li>
  12272. * REF: fisheye::CALIB_USE_INTRINSIC_GUESS cameraMatrix contains valid initial values of
  12273. * fx, fy, cx, cy that are optimized further. Otherwise, (cx, cy) is initially set to the image
  12274. * center ( imageSize is used), and focal distances are computed in a least-squares fashion.
  12275. * </li>
  12276. * <li>
  12277. * REF: fisheye::CALIB_RECOMPUTE_EXTRINSIC Extrinsic will be recomputed after each iteration
  12278. * of intrinsic optimization.
  12279. * </li>
  12280. * <li>
  12281. * REF: fisheye::CALIB_CHECK_COND The functions will check validity of condition number.
  12282. * </li>
  12283. * <li>
  12284. * REF: fisheye::CALIB_FIX_SKEW Skew coefficient (alpha) is set to zero and stay zero.
  12285. * </li>
  12286. * <li>
  12287. * REF: fisheye::CALIB_FIX_K1,..., REF: fisheye::CALIB_FIX_K4 Selected distortion coefficients
  12288. * are set to zeros and stay zero.
  12289. * </li>
  12290. * <li>
  12291. * REF: fisheye::CALIB_FIX_PRINCIPAL_POINT The principal point is not changed during the global
  12292. * optimization. It stays at the center or at a different location specified when REF: fisheye::CALIB_USE_INTRINSIC_GUESS is set too.
  12293. * </li>
  12294. * <li>
  12295. * REF: fisheye::CALIB_FIX_FOCAL_LENGTH The focal length is not changed during the global
  12296. * optimization. It is the \(max(width,height)/\pi\) or the provided \(f_x\), \(f_y\) when REF: fisheye::CALIB_USE_INTRINSIC_GUESS is set too.
  12297. * </li>
  12298. * </ul>
  12299. * return automatically generated
  12300. */
  12301. public static double fisheye_calibrate(List<Mat> objectPoints, List<Mat> imagePoints, Size image_size, Mat K, Mat D, List<Mat> rvecs, List<Mat> tvecs, int flags)
  12302. {
  12303. if (K != null) K.ThrowIfDisposed();
  12304. if (D != null) D.ThrowIfDisposed();
  12305. Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints);
  12306. Mat imagePoints_mat = Converters.vector_Mat_to_Mat(imagePoints);
  12307. Mat rvecs_mat = new Mat();
  12308. Mat tvecs_mat = new Mat();
  12309. double retVal = calib3d_Calib3d_fisheye_1calibrate_11(objectPoints_mat.nativeObj, imagePoints_mat.nativeObj, image_size.width, image_size.height, K.nativeObj, D.nativeObj, rvecs_mat.nativeObj, tvecs_mat.nativeObj, flags);
  12310. Converters.Mat_to_vector_Mat(rvecs_mat, rvecs);
  12311. rvecs_mat.release();
  12312. Converters.Mat_to_vector_Mat(tvecs_mat, tvecs);
  12313. tvecs_mat.release();
  12314. return retVal;
  12315. }
  12316. /**
  12317. * Performs camera calibration
  12318. *
  12319. * param objectPoints vector of vectors of calibration pattern points in the calibration pattern
  12320. * coordinate space.
  12321. * param imagePoints vector of vectors of the projections of calibration pattern points.
  12322. * imagePoints.size() and objectPoints.size() and imagePoints[i].size() must be equal to
  12323. * objectPoints[i].size() for each i.
  12324. * param image_size Size of the image used only to initialize the camera intrinsic matrix.
  12325. * param K Output 3x3 floating-point camera intrinsic matrix
  12326. * \(\cameramatrix{A}\) . If
  12327. * REF: fisheye::CALIB_USE_INTRINSIC_GUESS is specified, some or all of fx, fy, cx, cy must be
  12328. * initialized before calling the function.
  12329. * param D Output vector of distortion coefficients \(\distcoeffsfisheye\).
  12330. * param rvecs Output vector of rotation vectors (see Rodrigues ) estimated for each pattern view.
  12331. * That is, each k-th rotation vector together with the corresponding k-th translation vector (see
  12332. * the next output parameter description) brings the calibration pattern from the model coordinate
  12333. * space (in which object points are specified) to the world coordinate space, that is, a real
  12334. * position of the calibration pattern in the k-th pattern view (k=0.. *M* -1).
  12335. * param tvecs Output vector of translation vectors estimated for each pattern view.
  12336. * <ul>
  12337. * <li>
  12338. * REF: fisheye::CALIB_USE_INTRINSIC_GUESS cameraMatrix contains valid initial values of
  12339. * fx, fy, cx, cy that are optimized further. Otherwise, (cx, cy) is initially set to the image
  12340. * center ( imageSize is used), and focal distances are computed in a least-squares fashion.
  12341. * </li>
  12342. * <li>
  12343. * REF: fisheye::CALIB_RECOMPUTE_EXTRINSIC Extrinsic will be recomputed after each iteration
  12344. * of intrinsic optimization.
  12345. * </li>
  12346. * <li>
  12347. * REF: fisheye::CALIB_CHECK_COND The functions will check validity of condition number.
  12348. * </li>
  12349. * <li>
  12350. * REF: fisheye::CALIB_FIX_SKEW Skew coefficient (alpha) is set to zero and stay zero.
  12351. * </li>
  12352. * <li>
  12353. * REF: fisheye::CALIB_FIX_K1,..., REF: fisheye::CALIB_FIX_K4 Selected distortion coefficients
  12354. * are set to zeros and stay zero.
  12355. * </li>
  12356. * <li>
  12357. * REF: fisheye::CALIB_FIX_PRINCIPAL_POINT The principal point is not changed during the global
  12358. * optimization. It stays at the center or at a different location specified when REF: fisheye::CALIB_USE_INTRINSIC_GUESS is set too.
  12359. * </li>
  12360. * <li>
  12361. * REF: fisheye::CALIB_FIX_FOCAL_LENGTH The focal length is not changed during the global
  12362. * optimization. It is the \(max(width,height)/\pi\) or the provided \(f_x\), \(f_y\) when REF: fisheye::CALIB_USE_INTRINSIC_GUESS is set too.
  12363. * </li>
  12364. * </ul>
  12365. * return automatically generated
  12366. */
  12367. public static double fisheye_calibrate(List<Mat> objectPoints, List<Mat> imagePoints, Size image_size, Mat K, Mat D, List<Mat> rvecs, List<Mat> tvecs)
  12368. {
  12369. if (K != null) K.ThrowIfDisposed();
  12370. if (D != null) D.ThrowIfDisposed();
  12371. Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints);
  12372. Mat imagePoints_mat = Converters.vector_Mat_to_Mat(imagePoints);
  12373. Mat rvecs_mat = new Mat();
  12374. Mat tvecs_mat = new Mat();
  12375. double retVal = calib3d_Calib3d_fisheye_1calibrate_12(objectPoints_mat.nativeObj, imagePoints_mat.nativeObj, image_size.width, image_size.height, K.nativeObj, D.nativeObj, rvecs_mat.nativeObj, tvecs_mat.nativeObj);
  12376. Converters.Mat_to_vector_Mat(rvecs_mat, rvecs);
  12377. rvecs_mat.release();
  12378. Converters.Mat_to_vector_Mat(tvecs_mat, tvecs);
  12379. tvecs_mat.release();
  12380. return retVal;
  12381. }
  12382. //
  12383. // C++: void cv::fisheye::stereoRectify(Mat K1, Mat D1, Mat K2, Mat D2, Size imageSize, Mat R, Mat tvec, Mat& R1, Mat& R2, Mat& P1, Mat& P2, Mat& Q, int flags, Size newImageSize = Size(), double balance = 0.0, double fov_scale = 1.0)
  12384. //
  12385. /**
  12386. * Stereo rectification for fisheye camera model
  12387. *
  12388. * param K1 First camera intrinsic matrix.
  12389. * param D1 First camera distortion parameters.
  12390. * param K2 Second camera intrinsic matrix.
  12391. * param D2 Second camera distortion parameters.
  12392. * param imageSize Size of the image used for stereo calibration.
  12393. * param R Rotation matrix between the coordinate systems of the first and the second
  12394. * cameras.
  12395. * param tvec Translation vector between coordinate systems of the cameras.
  12396. * param R1 Output 3x3 rectification transform (rotation matrix) for the first camera.
  12397. * param R2 Output 3x3 rectification transform (rotation matrix) for the second camera.
  12398. * param P1 Output 3x4 projection matrix in the new (rectified) coordinate systems for the first
  12399. * camera.
  12400. * param P2 Output 3x4 projection matrix in the new (rectified) coordinate systems for the second
  12401. * camera.
  12402. * param Q Output \(4 \times 4\) disparity-to-depth mapping matrix (see #reprojectImageTo3D ).
  12403. * param flags Operation flags that may be zero or REF: fisheye::CALIB_ZERO_DISPARITY . If the flag is set,
  12404. * the function makes the principal points of each camera have the same pixel coordinates in the
  12405. * rectified views. And if the flag is not set, the function may still shift the images in the
  12406. * horizontal or vertical direction (depending on the orientation of epipolar lines) to maximize the
  12407. * useful image area.
  12408. * param newImageSize New image resolution after rectification. The same size should be passed to
  12409. * #initUndistortRectifyMap (see the stereo_calib.cpp sample in OpenCV samples directory). When (0,0)
  12410. * is passed (default), it is set to the original imageSize . Setting it to larger value can help you
  12411. * preserve details in the original image, especially when there is a big radial distortion.
  12412. * param balance Sets the new focal length in range between the min focal length and the max focal
  12413. * length. Balance is in range of [0, 1].
  12414. * param fov_scale Divisor for new focal length.
  12415. */
  12416. public static void fisheye_stereoRectify(Mat K1, Mat D1, Mat K2, Mat D2, Size imageSize, Mat R, Mat tvec, Mat R1, Mat R2, Mat P1, Mat P2, Mat Q, int flags, Size newImageSize, double balance, double fov_scale)
  12417. {
  12418. if (K1 != null) K1.ThrowIfDisposed();
  12419. if (D1 != null) D1.ThrowIfDisposed();
  12420. if (K2 != null) K2.ThrowIfDisposed();
  12421. if (D2 != null) D2.ThrowIfDisposed();
  12422. if (R != null) R.ThrowIfDisposed();
  12423. if (tvec != null) tvec.ThrowIfDisposed();
  12424. if (R1 != null) R1.ThrowIfDisposed();
  12425. if (R2 != null) R2.ThrowIfDisposed();
  12426. if (P1 != null) P1.ThrowIfDisposed();
  12427. if (P2 != null) P2.ThrowIfDisposed();
  12428. if (Q != null) Q.ThrowIfDisposed();
  12429. calib3d_Calib3d_fisheye_1stereoRectify_10(K1.nativeObj, D1.nativeObj, K2.nativeObj, D2.nativeObj, imageSize.width, imageSize.height, R.nativeObj, tvec.nativeObj, R1.nativeObj, R2.nativeObj, P1.nativeObj, P2.nativeObj, Q.nativeObj, flags, newImageSize.width, newImageSize.height, balance, fov_scale);
  12430. }
  12431. /**
  12432. * Stereo rectification for fisheye camera model
  12433. *
  12434. * param K1 First camera intrinsic matrix.
  12435. * param D1 First camera distortion parameters.
  12436. * param K2 Second camera intrinsic matrix.
  12437. * param D2 Second camera distortion parameters.
  12438. * param imageSize Size of the image used for stereo calibration.
  12439. * param R Rotation matrix between the coordinate systems of the first and the second
  12440. * cameras.
  12441. * param tvec Translation vector between coordinate systems of the cameras.
  12442. * param R1 Output 3x3 rectification transform (rotation matrix) for the first camera.
  12443. * param R2 Output 3x3 rectification transform (rotation matrix) for the second camera.
  12444. * param P1 Output 3x4 projection matrix in the new (rectified) coordinate systems for the first
  12445. * camera.
  12446. * param P2 Output 3x4 projection matrix in the new (rectified) coordinate systems for the second
  12447. * camera.
  12448. * param Q Output \(4 \times 4\) disparity-to-depth mapping matrix (see #reprojectImageTo3D ).
  12449. * param flags Operation flags that may be zero or REF: fisheye::CALIB_ZERO_DISPARITY . If the flag is set,
  12450. * the function makes the principal points of each camera have the same pixel coordinates in the
  12451. * rectified views. And if the flag is not set, the function may still shift the images in the
  12452. * horizontal or vertical direction (depending on the orientation of epipolar lines) to maximize the
  12453. * useful image area.
  12454. * param newImageSize New image resolution after rectification. The same size should be passed to
  12455. * #initUndistortRectifyMap (see the stereo_calib.cpp sample in OpenCV samples directory). When (0,0)
  12456. * is passed (default), it is set to the original imageSize . Setting it to larger value can help you
  12457. * preserve details in the original image, especially when there is a big radial distortion.
  12458. * param balance Sets the new focal length in range between the min focal length and the max focal
  12459. * length. Balance is in range of [0, 1].
  12460. */
  12461. public static void fisheye_stereoRectify(Mat K1, Mat D1, Mat K2, Mat D2, Size imageSize, Mat R, Mat tvec, Mat R1, Mat R2, Mat P1, Mat P2, Mat Q, int flags, Size newImageSize, double balance)
  12462. {
  12463. if (K1 != null) K1.ThrowIfDisposed();
  12464. if (D1 != null) D1.ThrowIfDisposed();
  12465. if (K2 != null) K2.ThrowIfDisposed();
  12466. if (D2 != null) D2.ThrowIfDisposed();
  12467. if (R != null) R.ThrowIfDisposed();
  12468. if (tvec != null) tvec.ThrowIfDisposed();
  12469. if (R1 != null) R1.ThrowIfDisposed();
  12470. if (R2 != null) R2.ThrowIfDisposed();
  12471. if (P1 != null) P1.ThrowIfDisposed();
  12472. if (P2 != null) P2.ThrowIfDisposed();
  12473. if (Q != null) Q.ThrowIfDisposed();
  12474. calib3d_Calib3d_fisheye_1stereoRectify_11(K1.nativeObj, D1.nativeObj, K2.nativeObj, D2.nativeObj, imageSize.width, imageSize.height, R.nativeObj, tvec.nativeObj, R1.nativeObj, R2.nativeObj, P1.nativeObj, P2.nativeObj, Q.nativeObj, flags, newImageSize.width, newImageSize.height, balance);
  12475. }
  12476. /**
  12477. * Stereo rectification for fisheye camera model
  12478. *
  12479. * param K1 First camera intrinsic matrix.
  12480. * param D1 First camera distortion parameters.
  12481. * param K2 Second camera intrinsic matrix.
  12482. * param D2 Second camera distortion parameters.
  12483. * param imageSize Size of the image used for stereo calibration.
  12484. * param R Rotation matrix between the coordinate systems of the first and the second
  12485. * cameras.
  12486. * param tvec Translation vector between coordinate systems of the cameras.
  12487. * param R1 Output 3x3 rectification transform (rotation matrix) for the first camera.
  12488. * param R2 Output 3x3 rectification transform (rotation matrix) for the second camera.
  12489. * param P1 Output 3x4 projection matrix in the new (rectified) coordinate systems for the first
  12490. * camera.
  12491. * param P2 Output 3x4 projection matrix in the new (rectified) coordinate systems for the second
  12492. * camera.
  12493. * param Q Output \(4 \times 4\) disparity-to-depth mapping matrix (see #reprojectImageTo3D ).
  12494. * param flags Operation flags that may be zero or REF: fisheye::CALIB_ZERO_DISPARITY . If the flag is set,
  12495. * the function makes the principal points of each camera have the same pixel coordinates in the
  12496. * rectified views. And if the flag is not set, the function may still shift the images in the
  12497. * horizontal or vertical direction (depending on the orientation of epipolar lines) to maximize the
  12498. * useful image area.
  12499. * param newImageSize New image resolution after rectification. The same size should be passed to
  12500. * #initUndistortRectifyMap (see the stereo_calib.cpp sample in OpenCV samples directory). When (0,0)
  12501. * is passed (default), it is set to the original imageSize . Setting it to larger value can help you
  12502. * preserve details in the original image, especially when there is a big radial distortion.
  12503. * length. Balance is in range of [0, 1].
  12504. */
  12505. public static void fisheye_stereoRectify(Mat K1, Mat D1, Mat K2, Mat D2, Size imageSize, Mat R, Mat tvec, Mat R1, Mat R2, Mat P1, Mat P2, Mat Q, int flags, Size newImageSize)
  12506. {
  12507. if (K1 != null) K1.ThrowIfDisposed();
  12508. if (D1 != null) D1.ThrowIfDisposed();
  12509. if (K2 != null) K2.ThrowIfDisposed();
  12510. if (D2 != null) D2.ThrowIfDisposed();
  12511. if (R != null) R.ThrowIfDisposed();
  12512. if (tvec != null) tvec.ThrowIfDisposed();
  12513. if (R1 != null) R1.ThrowIfDisposed();
  12514. if (R2 != null) R2.ThrowIfDisposed();
  12515. if (P1 != null) P1.ThrowIfDisposed();
  12516. if (P2 != null) P2.ThrowIfDisposed();
  12517. if (Q != null) Q.ThrowIfDisposed();
  12518. calib3d_Calib3d_fisheye_1stereoRectify_12(K1.nativeObj, D1.nativeObj, K2.nativeObj, D2.nativeObj, imageSize.width, imageSize.height, R.nativeObj, tvec.nativeObj, R1.nativeObj, R2.nativeObj, P1.nativeObj, P2.nativeObj, Q.nativeObj, flags, newImageSize.width, newImageSize.height);
  12519. }
  12520. /**
  12521. * Stereo rectification for fisheye camera model
  12522. *
  12523. * param K1 First camera intrinsic matrix.
  12524. * param D1 First camera distortion parameters.
  12525. * param K2 Second camera intrinsic matrix.
  12526. * param D2 Second camera distortion parameters.
  12527. * param imageSize Size of the image used for stereo calibration.
  12528. * param R Rotation matrix between the coordinate systems of the first and the second
  12529. * cameras.
  12530. * param tvec Translation vector between coordinate systems of the cameras.
  12531. * param R1 Output 3x3 rectification transform (rotation matrix) for the first camera.
  12532. * param R2 Output 3x3 rectification transform (rotation matrix) for the second camera.
  12533. * param P1 Output 3x4 projection matrix in the new (rectified) coordinate systems for the first
  12534. * camera.
  12535. * param P2 Output 3x4 projection matrix in the new (rectified) coordinate systems for the second
  12536. * camera.
  12537. * param Q Output \(4 \times 4\) disparity-to-depth mapping matrix (see #reprojectImageTo3D ).
  12538. * param flags Operation flags that may be zero or REF: fisheye::CALIB_ZERO_DISPARITY . If the flag is set,
  12539. * the function makes the principal points of each camera have the same pixel coordinates in the
  12540. * rectified views. And if the flag is not set, the function may still shift the images in the
  12541. * horizontal or vertical direction (depending on the orientation of epipolar lines) to maximize the
  12542. * useful image area.
  12543. * #initUndistortRectifyMap (see the stereo_calib.cpp sample in OpenCV samples directory). When (0,0)
  12544. * is passed (default), it is set to the original imageSize . Setting it to larger value can help you
  12545. * preserve details in the original image, especially when there is a big radial distortion.
  12546. * length. Balance is in range of [0, 1].
  12547. */
  12548. public static void fisheye_stereoRectify(Mat K1, Mat D1, Mat K2, Mat D2, Size imageSize, Mat R, Mat tvec, Mat R1, Mat R2, Mat P1, Mat P2, Mat Q, int flags)
  12549. {
  12550. if (K1 != null) K1.ThrowIfDisposed();
  12551. if (D1 != null) D1.ThrowIfDisposed();
  12552. if (K2 != null) K2.ThrowIfDisposed();
  12553. if (D2 != null) D2.ThrowIfDisposed();
  12554. if (R != null) R.ThrowIfDisposed();
  12555. if (tvec != null) tvec.ThrowIfDisposed();
  12556. if (R1 != null) R1.ThrowIfDisposed();
  12557. if (R2 != null) R2.ThrowIfDisposed();
  12558. if (P1 != null) P1.ThrowIfDisposed();
  12559. if (P2 != null) P2.ThrowIfDisposed();
  12560. if (Q != null) Q.ThrowIfDisposed();
  12561. calib3d_Calib3d_fisheye_1stereoRectify_13(K1.nativeObj, D1.nativeObj, K2.nativeObj, D2.nativeObj, imageSize.width, imageSize.height, R.nativeObj, tvec.nativeObj, R1.nativeObj, R2.nativeObj, P1.nativeObj, P2.nativeObj, Q.nativeObj, flags);
  12562. }
  12563. //
  12564. // C++: double cv::fisheye::stereoCalibrate(vector_Mat objectPoints, vector_Mat imagePoints1, vector_Mat imagePoints2, Mat& K1, Mat& D1, Mat& K2, Mat& D2, Size imageSize, Mat& R, Mat& T, vector_Mat& rvecs, vector_Mat& tvecs, int flags = fisheye::CALIB_FIX_INTRINSIC, TermCriteria criteria = TermCriteria(TermCriteria::COUNT + TermCriteria::EPS, 100, DBL_EPSILON))
  12565. //
  12566. /**
  12567. * Performs stereo calibration
  12568. *
  12569. * param objectPoints Vector of vectors of the calibration pattern points.
  12570. * param imagePoints1 Vector of vectors of the projections of the calibration pattern points,
  12571. * observed by the first camera.
  12572. * param imagePoints2 Vector of vectors of the projections of the calibration pattern points,
  12573. * observed by the second camera.
  12574. * param K1 Input/output first camera intrinsic matrix:
  12575. * \(\vecthreethree{f_x^{(j)}}{0}{c_x^{(j)}}{0}{f_y^{(j)}}{c_y^{(j)}}{0}{0}{1}\) , \(j = 0,\, 1\) . If
  12576. * any of REF: fisheye::CALIB_USE_INTRINSIC_GUESS , REF: fisheye::CALIB_FIX_INTRINSIC are specified,
  12577. * some or all of the matrix components must be initialized.
  12578. * param D1 Input/output vector of distortion coefficients \(\distcoeffsfisheye\) of 4 elements.
  12579. * param K2 Input/output second camera intrinsic matrix. The parameter is similar to K1 .
  12580. * param D2 Input/output lens distortion coefficients for the second camera. The parameter is
  12581. * similar to D1 .
  12582. * param imageSize Size of the image used only to initialize camera intrinsic matrix.
  12583. * param R Output rotation matrix between the 1st and the 2nd camera coordinate systems.
  12584. * param T Output translation vector between the coordinate systems of the cameras.
  12585. * param rvecs Output vector of rotation vectors ( REF: Rodrigues ) estimated for each pattern view in the
  12586. * coordinate system of the first camera of the stereo pair (e.g. std::vector&lt;cv::Mat&gt;). More in detail, each
  12587. * i-th rotation vector together with the corresponding i-th translation vector (see the next output parameter
  12588. * description) brings the calibration pattern from the object coordinate space (in which object points are
  12589. * specified) to the camera coordinate space of the first camera of the stereo pair. In more technical terms,
  12590. * the tuple of the i-th rotation and translation vector performs a change of basis from object coordinate space
  12591. * to camera coordinate space of the first camera of the stereo pair.
  12592. * param tvecs Output vector of translation vectors estimated for each pattern view, see parameter description
  12593. * of previous output parameter ( rvecs ).
  12594. * param flags Different flags that may be zero or a combination of the following values:
  12595. * <ul>
  12596. * <li>
  12597. * REF: fisheye::CALIB_FIX_INTRINSIC Fix K1, K2? and D1, D2? so that only R, T matrices
  12598. * are estimated.
  12599. * </li>
  12600. * <li>
  12601. * REF: fisheye::CALIB_USE_INTRINSIC_GUESS K1, K2 contains valid initial values of
  12602. * fx, fy, cx, cy that are optimized further. Otherwise, (cx, cy) is initially set to the image
  12603. * center (imageSize is used), and focal distances are computed in a least-squares fashion.
  12604. * </li>
  12605. * <li>
  12606. * REF: fisheye::CALIB_RECOMPUTE_EXTRINSIC Extrinsic will be recomputed after each iteration
  12607. * of intrinsic optimization.
  12608. * </li>
  12609. * <li>
  12610. * REF: fisheye::CALIB_CHECK_COND The functions will check validity of condition number.
  12611. * </li>
  12612. * <li>
  12613. * REF: fisheye::CALIB_FIX_SKEW Skew coefficient (alpha) is set to zero and stay zero.
  12614. * </li>
  12615. * <li>
  12616. * REF: fisheye::CALIB_FIX_K1,..., REF: fisheye::CALIB_FIX_K4 Selected distortion coefficients are set to zeros and stay
  12617. * zero.
  12618. * </li>
  12619. * </ul>
  12620. * param criteria Termination criteria for the iterative optimization algorithm.
  12621. * return automatically generated
  12622. */
  12623. public static double fisheye_stereoCalibrate(List<Mat> objectPoints, List<Mat> imagePoints1, List<Mat> imagePoints2, Mat K1, Mat D1, Mat K2, Mat D2, Size imageSize, Mat R, Mat T, List<Mat> rvecs, List<Mat> tvecs, int flags, TermCriteria criteria)
  12624. {
  12625. if (K1 != null) K1.ThrowIfDisposed();
  12626. if (D1 != null) D1.ThrowIfDisposed();
  12627. if (K2 != null) K2.ThrowIfDisposed();
  12628. if (D2 != null) D2.ThrowIfDisposed();
  12629. if (R != null) R.ThrowIfDisposed();
  12630. if (T != null) T.ThrowIfDisposed();
  12631. Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints);
  12632. Mat imagePoints1_mat = Converters.vector_Mat_to_Mat(imagePoints1);
  12633. Mat imagePoints2_mat = Converters.vector_Mat_to_Mat(imagePoints2);
  12634. Mat rvecs_mat = new Mat();
  12635. Mat tvecs_mat = new Mat();
  12636. double retVal = calib3d_Calib3d_fisheye_1stereoCalibrate_10(objectPoints_mat.nativeObj, imagePoints1_mat.nativeObj, imagePoints2_mat.nativeObj, K1.nativeObj, D1.nativeObj, K2.nativeObj, D2.nativeObj, imageSize.width, imageSize.height, R.nativeObj, T.nativeObj, rvecs_mat.nativeObj, tvecs_mat.nativeObj, flags, criteria.type, criteria.maxCount, criteria.epsilon);
  12637. Converters.Mat_to_vector_Mat(rvecs_mat, rvecs);
  12638. rvecs_mat.release();
  12639. Converters.Mat_to_vector_Mat(tvecs_mat, tvecs);
  12640. tvecs_mat.release();
  12641. return retVal;
  12642. }
  12643. /**
  12644. * Performs stereo calibration
  12645. *
  12646. * param objectPoints Vector of vectors of the calibration pattern points.
  12647. * param imagePoints1 Vector of vectors of the projections of the calibration pattern points,
  12648. * observed by the first camera.
  12649. * param imagePoints2 Vector of vectors of the projections of the calibration pattern points,
  12650. * observed by the second camera.
  12651. * param K1 Input/output first camera intrinsic matrix:
  12652. * \(\vecthreethree{f_x^{(j)}}{0}{c_x^{(j)}}{0}{f_y^{(j)}}{c_y^{(j)}}{0}{0}{1}\) , \(j = 0,\, 1\) . If
  12653. * any of REF: fisheye::CALIB_USE_INTRINSIC_GUESS , REF: fisheye::CALIB_FIX_INTRINSIC are specified,
  12654. * some or all of the matrix components must be initialized.
  12655. * param D1 Input/output vector of distortion coefficients \(\distcoeffsfisheye\) of 4 elements.
  12656. * param K2 Input/output second camera intrinsic matrix. The parameter is similar to K1 .
  12657. * param D2 Input/output lens distortion coefficients for the second camera. The parameter is
  12658. * similar to D1 .
  12659. * param imageSize Size of the image used only to initialize camera intrinsic matrix.
  12660. * param R Output rotation matrix between the 1st and the 2nd camera coordinate systems.
  12661. * param T Output translation vector between the coordinate systems of the cameras.
  12662. * param rvecs Output vector of rotation vectors ( REF: Rodrigues ) estimated for each pattern view in the
  12663. * coordinate system of the first camera of the stereo pair (e.g. std::vector&lt;cv::Mat&gt;). More in detail, each
  12664. * i-th rotation vector together with the corresponding i-th translation vector (see the next output parameter
  12665. * description) brings the calibration pattern from the object coordinate space (in which object points are
  12666. * specified) to the camera coordinate space of the first camera of the stereo pair. In more technical terms,
  12667. * the tuple of the i-th rotation and translation vector performs a change of basis from object coordinate space
  12668. * to camera coordinate space of the first camera of the stereo pair.
  12669. * param tvecs Output vector of translation vectors estimated for each pattern view, see parameter description
  12670. * of previous output parameter ( rvecs ).
  12671. * param flags Different flags that may be zero or a combination of the following values:
  12672. * <ul>
  12673. * <li>
  12674. * REF: fisheye::CALIB_FIX_INTRINSIC Fix K1, K2? and D1, D2? so that only R, T matrices
  12675. * are estimated.
  12676. * </li>
  12677. * <li>
  12678. * REF: fisheye::CALIB_USE_INTRINSIC_GUESS K1, K2 contains valid initial values of
  12679. * fx, fy, cx, cy that are optimized further. Otherwise, (cx, cy) is initially set to the image
  12680. * center (imageSize is used), and focal distances are computed in a least-squares fashion.
  12681. * </li>
  12682. * <li>
  12683. * REF: fisheye::CALIB_RECOMPUTE_EXTRINSIC Extrinsic will be recomputed after each iteration
  12684. * of intrinsic optimization.
  12685. * </li>
  12686. * <li>
  12687. * REF: fisheye::CALIB_CHECK_COND The functions will check validity of condition number.
  12688. * </li>
  12689. * <li>
  12690. * REF: fisheye::CALIB_FIX_SKEW Skew coefficient (alpha) is set to zero and stay zero.
  12691. * </li>
  12692. * <li>
  12693. * REF: fisheye::CALIB_FIX_K1,..., REF: fisheye::CALIB_FIX_K4 Selected distortion coefficients are set to zeros and stay
  12694. * zero.
  12695. * </li>
  12696. * </ul>
  12697. * return automatically generated
  12698. */
  12699. public static double fisheye_stereoCalibrate(List<Mat> objectPoints, List<Mat> imagePoints1, List<Mat> imagePoints2, Mat K1, Mat D1, Mat K2, Mat D2, Size imageSize, Mat R, Mat T, List<Mat> rvecs, List<Mat> tvecs, int flags)
  12700. {
  12701. if (K1 != null) K1.ThrowIfDisposed();
  12702. if (D1 != null) D1.ThrowIfDisposed();
  12703. if (K2 != null) K2.ThrowIfDisposed();
  12704. if (D2 != null) D2.ThrowIfDisposed();
  12705. if (R != null) R.ThrowIfDisposed();
  12706. if (T != null) T.ThrowIfDisposed();
  12707. Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints);
  12708. Mat imagePoints1_mat = Converters.vector_Mat_to_Mat(imagePoints1);
  12709. Mat imagePoints2_mat = Converters.vector_Mat_to_Mat(imagePoints2);
  12710. Mat rvecs_mat = new Mat();
  12711. Mat tvecs_mat = new Mat();
  12712. double retVal = calib3d_Calib3d_fisheye_1stereoCalibrate_11(objectPoints_mat.nativeObj, imagePoints1_mat.nativeObj, imagePoints2_mat.nativeObj, K1.nativeObj, D1.nativeObj, K2.nativeObj, D2.nativeObj, imageSize.width, imageSize.height, R.nativeObj, T.nativeObj, rvecs_mat.nativeObj, tvecs_mat.nativeObj, flags);
  12713. Converters.Mat_to_vector_Mat(rvecs_mat, rvecs);
  12714. rvecs_mat.release();
  12715. Converters.Mat_to_vector_Mat(tvecs_mat, tvecs);
  12716. tvecs_mat.release();
  12717. return retVal;
  12718. }
  12719. /**
  12720. * Performs stereo calibration
  12721. *
  12722. * param objectPoints Vector of vectors of the calibration pattern points.
  12723. * param imagePoints1 Vector of vectors of the projections of the calibration pattern points,
  12724. * observed by the first camera.
  12725. * param imagePoints2 Vector of vectors of the projections of the calibration pattern points,
  12726. * observed by the second camera.
  12727. * param K1 Input/output first camera intrinsic matrix:
  12728. * \(\vecthreethree{f_x^{(j)}}{0}{c_x^{(j)}}{0}{f_y^{(j)}}{c_y^{(j)}}{0}{0}{1}\) , \(j = 0,\, 1\) . If
  12729. * any of REF: fisheye::CALIB_USE_INTRINSIC_GUESS , REF: fisheye::CALIB_FIX_INTRINSIC are specified,
  12730. * some or all of the matrix components must be initialized.
  12731. * param D1 Input/output vector of distortion coefficients \(\distcoeffsfisheye\) of 4 elements.
  12732. * param K2 Input/output second camera intrinsic matrix. The parameter is similar to K1 .
  12733. * param D2 Input/output lens distortion coefficients for the second camera. The parameter is
  12734. * similar to D1 .
  12735. * param imageSize Size of the image used only to initialize camera intrinsic matrix.
  12736. * param R Output rotation matrix between the 1st and the 2nd camera coordinate systems.
  12737. * param T Output translation vector between the coordinate systems of the cameras.
  12738. * param rvecs Output vector of rotation vectors ( REF: Rodrigues ) estimated for each pattern view in the
  12739. * coordinate system of the first camera of the stereo pair (e.g. std::vector&lt;cv::Mat&gt;). More in detail, each
  12740. * i-th rotation vector together with the corresponding i-th translation vector (see the next output parameter
  12741. * description) brings the calibration pattern from the object coordinate space (in which object points are
  12742. * specified) to the camera coordinate space of the first camera of the stereo pair. In more technical terms,
  12743. * the tuple of the i-th rotation and translation vector performs a change of basis from object coordinate space
  12744. * to camera coordinate space of the first camera of the stereo pair.
  12745. * param tvecs Output vector of translation vectors estimated for each pattern view, see parameter description
  12746. * of previous output parameter ( rvecs ).
  12747. * <ul>
  12748. * <li>
  12749. * REF: fisheye::CALIB_FIX_INTRINSIC Fix K1, K2? and D1, D2? so that only R, T matrices
  12750. * are estimated.
  12751. * </li>
  12752. * <li>
  12753. * REF: fisheye::CALIB_USE_INTRINSIC_GUESS K1, K2 contains valid initial values of
  12754. * fx, fy, cx, cy that are optimized further. Otherwise, (cx, cy) is initially set to the image
  12755. * center (imageSize is used), and focal distances are computed in a least-squares fashion.
  12756. * </li>
  12757. * <li>
  12758. * REF: fisheye::CALIB_RECOMPUTE_EXTRINSIC Extrinsic will be recomputed after each iteration
  12759. * of intrinsic optimization.
  12760. * </li>
  12761. * <li>
  12762. * REF: fisheye::CALIB_CHECK_COND The functions will check validity of condition number.
  12763. * </li>
  12764. * <li>
  12765. * REF: fisheye::CALIB_FIX_SKEW Skew coefficient (alpha) is set to zero and stay zero.
  12766. * </li>
  12767. * <li>
  12768. * REF: fisheye::CALIB_FIX_K1,..., REF: fisheye::CALIB_FIX_K4 Selected distortion coefficients are set to zeros and stay
  12769. * zero.
  12770. * </li>
  12771. * </ul>
  12772. * return automatically generated
  12773. */
  12774. public static double fisheye_stereoCalibrate(List<Mat> objectPoints, List<Mat> imagePoints1, List<Mat> imagePoints2, Mat K1, Mat D1, Mat K2, Mat D2, Size imageSize, Mat R, Mat T, List<Mat> rvecs, List<Mat> tvecs)
  12775. {
  12776. if (K1 != null) K1.ThrowIfDisposed();
  12777. if (D1 != null) D1.ThrowIfDisposed();
  12778. if (K2 != null) K2.ThrowIfDisposed();
  12779. if (D2 != null) D2.ThrowIfDisposed();
  12780. if (R != null) R.ThrowIfDisposed();
  12781. if (T != null) T.ThrowIfDisposed();
  12782. Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints);
  12783. Mat imagePoints1_mat = Converters.vector_Mat_to_Mat(imagePoints1);
  12784. Mat imagePoints2_mat = Converters.vector_Mat_to_Mat(imagePoints2);
  12785. Mat rvecs_mat = new Mat();
  12786. Mat tvecs_mat = new Mat();
  12787. double retVal = calib3d_Calib3d_fisheye_1stereoCalibrate_12(objectPoints_mat.nativeObj, imagePoints1_mat.nativeObj, imagePoints2_mat.nativeObj, K1.nativeObj, D1.nativeObj, K2.nativeObj, D2.nativeObj, imageSize.width, imageSize.height, R.nativeObj, T.nativeObj, rvecs_mat.nativeObj, tvecs_mat.nativeObj);
  12788. Converters.Mat_to_vector_Mat(rvecs_mat, rvecs);
  12789. rvecs_mat.release();
  12790. Converters.Mat_to_vector_Mat(tvecs_mat, tvecs);
  12791. tvecs_mat.release();
  12792. return retVal;
  12793. }
  12794. //
  12795. // C++: double cv::fisheye::stereoCalibrate(vector_Mat objectPoints, vector_Mat imagePoints1, vector_Mat imagePoints2, Mat& K1, Mat& D1, Mat& K2, Mat& D2, Size imageSize, Mat& R, Mat& T, int flags = fisheye::CALIB_FIX_INTRINSIC, TermCriteria criteria = TermCriteria(TermCriteria::COUNT + TermCriteria::EPS, 100, DBL_EPSILON))
  12796. //
  12797. public static double fisheye_stereoCalibrate(List<Mat> objectPoints, List<Mat> imagePoints1, List<Mat> imagePoints2, Mat K1, Mat D1, Mat K2, Mat D2, Size imageSize, Mat R, Mat T, int flags, TermCriteria criteria)
  12798. {
  12799. if (K1 != null) K1.ThrowIfDisposed();
  12800. if (D1 != null) D1.ThrowIfDisposed();
  12801. if (K2 != null) K2.ThrowIfDisposed();
  12802. if (D2 != null) D2.ThrowIfDisposed();
  12803. if (R != null) R.ThrowIfDisposed();
  12804. if (T != null) T.ThrowIfDisposed();
  12805. Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints);
  12806. Mat imagePoints1_mat = Converters.vector_Mat_to_Mat(imagePoints1);
  12807. Mat imagePoints2_mat = Converters.vector_Mat_to_Mat(imagePoints2);
  12808. return calib3d_Calib3d_fisheye_1stereoCalibrate_13(objectPoints_mat.nativeObj, imagePoints1_mat.nativeObj, imagePoints2_mat.nativeObj, K1.nativeObj, D1.nativeObj, K2.nativeObj, D2.nativeObj, imageSize.width, imageSize.height, R.nativeObj, T.nativeObj, flags, criteria.type, criteria.maxCount, criteria.epsilon);
  12809. }
  12810. public static double fisheye_stereoCalibrate(List<Mat> objectPoints, List<Mat> imagePoints1, List<Mat> imagePoints2, Mat K1, Mat D1, Mat K2, Mat D2, Size imageSize, Mat R, Mat T, int flags)
  12811. {
  12812. if (K1 != null) K1.ThrowIfDisposed();
  12813. if (D1 != null) D1.ThrowIfDisposed();
  12814. if (K2 != null) K2.ThrowIfDisposed();
  12815. if (D2 != null) D2.ThrowIfDisposed();
  12816. if (R != null) R.ThrowIfDisposed();
  12817. if (T != null) T.ThrowIfDisposed();
  12818. Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints);
  12819. Mat imagePoints1_mat = Converters.vector_Mat_to_Mat(imagePoints1);
  12820. Mat imagePoints2_mat = Converters.vector_Mat_to_Mat(imagePoints2);
  12821. return calib3d_Calib3d_fisheye_1stereoCalibrate_14(objectPoints_mat.nativeObj, imagePoints1_mat.nativeObj, imagePoints2_mat.nativeObj, K1.nativeObj, D1.nativeObj, K2.nativeObj, D2.nativeObj, imageSize.width, imageSize.height, R.nativeObj, T.nativeObj, flags);
  12822. }
  12823. public static double fisheye_stereoCalibrate(List<Mat> objectPoints, List<Mat> imagePoints1, List<Mat> imagePoints2, Mat K1, Mat D1, Mat K2, Mat D2, Size imageSize, Mat R, Mat T)
  12824. {
  12825. if (K1 != null) K1.ThrowIfDisposed();
  12826. if (D1 != null) D1.ThrowIfDisposed();
  12827. if (K2 != null) K2.ThrowIfDisposed();
  12828. if (D2 != null) D2.ThrowIfDisposed();
  12829. if (R != null) R.ThrowIfDisposed();
  12830. if (T != null) T.ThrowIfDisposed();
  12831. Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints);
  12832. Mat imagePoints1_mat = Converters.vector_Mat_to_Mat(imagePoints1);
  12833. Mat imagePoints2_mat = Converters.vector_Mat_to_Mat(imagePoints2);
  12834. return calib3d_Calib3d_fisheye_1stereoCalibrate_15(objectPoints_mat.nativeObj, imagePoints1_mat.nativeObj, imagePoints2_mat.nativeObj, K1.nativeObj, D1.nativeObj, K2.nativeObj, D2.nativeObj, imageSize.width, imageSize.height, R.nativeObj, T.nativeObj);
  12835. }
  12836. #if (UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR
  12837. const string LIBNAME = "__Internal";
  12838. #else
  12839. const string LIBNAME = "opencvforunity";
  12840. #endif
  12841. // C++: void cv::Rodrigues(Mat src, Mat& dst, Mat& jacobian = Mat())
  12842. [DllImport(LIBNAME)]
  12843. private static extern void calib3d_Calib3d_Rodrigues_10(IntPtr src_nativeObj, IntPtr dst_nativeObj, IntPtr jacobian_nativeObj);
  12844. [DllImport(LIBNAME)]
  12845. private static extern void calib3d_Calib3d_Rodrigues_11(IntPtr src_nativeObj, IntPtr dst_nativeObj);
  12846. // C++: Mat cv::findHomography(vector_Point2f srcPoints, vector_Point2f dstPoints, int method = 0, double ransacReprojThreshold = 3, Mat& mask = Mat(), int maxIters = 2000, double confidence = 0.995)
  12847. [DllImport(LIBNAME)]
  12848. private static extern IntPtr calib3d_Calib3d_findHomography_10(IntPtr srcPoints_mat_nativeObj, IntPtr dstPoints_mat_nativeObj, int method, double ransacReprojThreshold, IntPtr mask_nativeObj, int maxIters, double confidence);
  12849. [DllImport(LIBNAME)]
  12850. private static extern IntPtr calib3d_Calib3d_findHomography_11(IntPtr srcPoints_mat_nativeObj, IntPtr dstPoints_mat_nativeObj, int method, double ransacReprojThreshold, IntPtr mask_nativeObj, int maxIters);
  12851. [DllImport(LIBNAME)]
  12852. private static extern IntPtr calib3d_Calib3d_findHomography_12(IntPtr srcPoints_mat_nativeObj, IntPtr dstPoints_mat_nativeObj, int method, double ransacReprojThreshold, IntPtr mask_nativeObj);
  12853. [DllImport(LIBNAME)]
  12854. private static extern IntPtr calib3d_Calib3d_findHomography_13(IntPtr srcPoints_mat_nativeObj, IntPtr dstPoints_mat_nativeObj, int method, double ransacReprojThreshold);
  12855. [DllImport(LIBNAME)]
  12856. private static extern IntPtr calib3d_Calib3d_findHomography_14(IntPtr srcPoints_mat_nativeObj, IntPtr dstPoints_mat_nativeObj, int method);
  12857. [DllImport(LIBNAME)]
  12858. private static extern IntPtr calib3d_Calib3d_findHomography_15(IntPtr srcPoints_mat_nativeObj, IntPtr dstPoints_mat_nativeObj);
  12859. // C++: Mat cv::findHomography(vector_Point2f srcPoints, vector_Point2f dstPoints, Mat& mask, UsacParams _params)
  12860. [DllImport(LIBNAME)]
  12861. private static extern IntPtr calib3d_Calib3d_findHomography_16(IntPtr srcPoints_mat_nativeObj, IntPtr dstPoints_mat_nativeObj, IntPtr mask_nativeObj, IntPtr _params_nativeObj);
  12862. // C++: Vec3d cv::RQDecomp3x3(Mat src, Mat& mtxR, Mat& mtxQ, Mat& Qx = Mat(), Mat& Qy = Mat(), Mat& Qz = Mat())
  12863. [DllImport(LIBNAME)]
  12864. private static extern void calib3d_Calib3d_RQDecomp3x3_10(IntPtr src_nativeObj, IntPtr mtxR_nativeObj, IntPtr mtxQ_nativeObj, IntPtr Qx_nativeObj, IntPtr Qy_nativeObj, IntPtr Qz_nativeObj, double[] retVal);
  12865. [DllImport(LIBNAME)]
  12866. private static extern void calib3d_Calib3d_RQDecomp3x3_11(IntPtr src_nativeObj, IntPtr mtxR_nativeObj, IntPtr mtxQ_nativeObj, IntPtr Qx_nativeObj, IntPtr Qy_nativeObj, double[] retVal);
  12867. [DllImport(LIBNAME)]
  12868. private static extern void calib3d_Calib3d_RQDecomp3x3_12(IntPtr src_nativeObj, IntPtr mtxR_nativeObj, IntPtr mtxQ_nativeObj, IntPtr Qx_nativeObj, double[] retVal);
  12869. [DllImport(LIBNAME)]
  12870. private static extern void calib3d_Calib3d_RQDecomp3x3_13(IntPtr src_nativeObj, IntPtr mtxR_nativeObj, IntPtr mtxQ_nativeObj, double[] retVal);
  12871. // C++: void cv::decomposeProjectionMatrix(Mat projMatrix, Mat& cameraMatrix, Mat& rotMatrix, Mat& transVect, Mat& rotMatrixX = Mat(), Mat& rotMatrixY = Mat(), Mat& rotMatrixZ = Mat(), Mat& eulerAngles = Mat())
  12872. [DllImport(LIBNAME)]
  12873. private static extern void calib3d_Calib3d_decomposeProjectionMatrix_10(IntPtr projMatrix_nativeObj, IntPtr cameraMatrix_nativeObj, IntPtr rotMatrix_nativeObj, IntPtr transVect_nativeObj, IntPtr rotMatrixX_nativeObj, IntPtr rotMatrixY_nativeObj, IntPtr rotMatrixZ_nativeObj, IntPtr eulerAngles_nativeObj);
  12874. [DllImport(LIBNAME)]
  12875. private static extern void calib3d_Calib3d_decomposeProjectionMatrix_11(IntPtr projMatrix_nativeObj, IntPtr cameraMatrix_nativeObj, IntPtr rotMatrix_nativeObj, IntPtr transVect_nativeObj, IntPtr rotMatrixX_nativeObj, IntPtr rotMatrixY_nativeObj, IntPtr rotMatrixZ_nativeObj);
  12876. [DllImport(LIBNAME)]
  12877. private static extern void calib3d_Calib3d_decomposeProjectionMatrix_12(IntPtr projMatrix_nativeObj, IntPtr cameraMatrix_nativeObj, IntPtr rotMatrix_nativeObj, IntPtr transVect_nativeObj, IntPtr rotMatrixX_nativeObj, IntPtr rotMatrixY_nativeObj);
  12878. [DllImport(LIBNAME)]
  12879. private static extern void calib3d_Calib3d_decomposeProjectionMatrix_13(IntPtr projMatrix_nativeObj, IntPtr cameraMatrix_nativeObj, IntPtr rotMatrix_nativeObj, IntPtr transVect_nativeObj, IntPtr rotMatrixX_nativeObj);
  12880. [DllImport(LIBNAME)]
  12881. private static extern void calib3d_Calib3d_decomposeProjectionMatrix_14(IntPtr projMatrix_nativeObj, IntPtr cameraMatrix_nativeObj, IntPtr rotMatrix_nativeObj, IntPtr transVect_nativeObj);
  12882. // C++: void cv::matMulDeriv(Mat A, Mat B, Mat& dABdA, Mat& dABdB)
  12883. [DllImport(LIBNAME)]
  12884. private static extern void calib3d_Calib3d_matMulDeriv_10(IntPtr A_nativeObj, IntPtr B_nativeObj, IntPtr dABdA_nativeObj, IntPtr dABdB_nativeObj);
  12885. // C++: void cv::composeRT(Mat rvec1, Mat tvec1, Mat rvec2, Mat tvec2, Mat& rvec3, Mat& tvec3, Mat& dr3dr1 = Mat(), Mat& dr3dt1 = Mat(), Mat& dr3dr2 = Mat(), Mat& dr3dt2 = Mat(), Mat& dt3dr1 = Mat(), Mat& dt3dt1 = Mat(), Mat& dt3dr2 = Mat(), Mat& dt3dt2 = Mat())
  12886. [DllImport(LIBNAME)]
  12887. private static extern void calib3d_Calib3d_composeRT_10(IntPtr rvec1_nativeObj, IntPtr tvec1_nativeObj, IntPtr rvec2_nativeObj, IntPtr tvec2_nativeObj, IntPtr rvec3_nativeObj, IntPtr tvec3_nativeObj, IntPtr dr3dr1_nativeObj, IntPtr dr3dt1_nativeObj, IntPtr dr3dr2_nativeObj, IntPtr dr3dt2_nativeObj, IntPtr dt3dr1_nativeObj, IntPtr dt3dt1_nativeObj, IntPtr dt3dr2_nativeObj, IntPtr dt3dt2_nativeObj);
  12888. [DllImport(LIBNAME)]
  12889. private static extern void calib3d_Calib3d_composeRT_11(IntPtr rvec1_nativeObj, IntPtr tvec1_nativeObj, IntPtr rvec2_nativeObj, IntPtr tvec2_nativeObj, IntPtr rvec3_nativeObj, IntPtr tvec3_nativeObj, IntPtr dr3dr1_nativeObj, IntPtr dr3dt1_nativeObj, IntPtr dr3dr2_nativeObj, IntPtr dr3dt2_nativeObj, IntPtr dt3dr1_nativeObj, IntPtr dt3dt1_nativeObj, IntPtr dt3dr2_nativeObj);
  12890. [DllImport(LIBNAME)]
  12891. private static extern void calib3d_Calib3d_composeRT_12(IntPtr rvec1_nativeObj, IntPtr tvec1_nativeObj, IntPtr rvec2_nativeObj, IntPtr tvec2_nativeObj, IntPtr rvec3_nativeObj, IntPtr tvec3_nativeObj, IntPtr dr3dr1_nativeObj, IntPtr dr3dt1_nativeObj, IntPtr dr3dr2_nativeObj, IntPtr dr3dt2_nativeObj, IntPtr dt3dr1_nativeObj, IntPtr dt3dt1_nativeObj);
  12892. [DllImport(LIBNAME)]
  12893. private static extern void calib3d_Calib3d_composeRT_13(IntPtr rvec1_nativeObj, IntPtr tvec1_nativeObj, IntPtr rvec2_nativeObj, IntPtr tvec2_nativeObj, IntPtr rvec3_nativeObj, IntPtr tvec3_nativeObj, IntPtr dr3dr1_nativeObj, IntPtr dr3dt1_nativeObj, IntPtr dr3dr2_nativeObj, IntPtr dr3dt2_nativeObj, IntPtr dt3dr1_nativeObj);
  12894. [DllImport(LIBNAME)]
  12895. private static extern void calib3d_Calib3d_composeRT_14(IntPtr rvec1_nativeObj, IntPtr tvec1_nativeObj, IntPtr rvec2_nativeObj, IntPtr tvec2_nativeObj, IntPtr rvec3_nativeObj, IntPtr tvec3_nativeObj, IntPtr dr3dr1_nativeObj, IntPtr dr3dt1_nativeObj, IntPtr dr3dr2_nativeObj, IntPtr dr3dt2_nativeObj);
  12896. [DllImport(LIBNAME)]
  12897. private static extern void calib3d_Calib3d_composeRT_15(IntPtr rvec1_nativeObj, IntPtr tvec1_nativeObj, IntPtr rvec2_nativeObj, IntPtr tvec2_nativeObj, IntPtr rvec3_nativeObj, IntPtr tvec3_nativeObj, IntPtr dr3dr1_nativeObj, IntPtr dr3dt1_nativeObj, IntPtr dr3dr2_nativeObj);
  12898. [DllImport(LIBNAME)]
  12899. private static extern void calib3d_Calib3d_composeRT_16(IntPtr rvec1_nativeObj, IntPtr tvec1_nativeObj, IntPtr rvec2_nativeObj, IntPtr tvec2_nativeObj, IntPtr rvec3_nativeObj, IntPtr tvec3_nativeObj, IntPtr dr3dr1_nativeObj, IntPtr dr3dt1_nativeObj);
  12900. [DllImport(LIBNAME)]
  12901. private static extern void calib3d_Calib3d_composeRT_17(IntPtr rvec1_nativeObj, IntPtr tvec1_nativeObj, IntPtr rvec2_nativeObj, IntPtr tvec2_nativeObj, IntPtr rvec3_nativeObj, IntPtr tvec3_nativeObj, IntPtr dr3dr1_nativeObj);
  12902. [DllImport(LIBNAME)]
  12903. private static extern void calib3d_Calib3d_composeRT_18(IntPtr rvec1_nativeObj, IntPtr tvec1_nativeObj, IntPtr rvec2_nativeObj, IntPtr tvec2_nativeObj, IntPtr rvec3_nativeObj, IntPtr tvec3_nativeObj);
  12904. // C++: void cv::projectPoints(vector_Point3f objectPoints, Mat rvec, Mat tvec, Mat cameraMatrix, vector_double distCoeffs, vector_Point2f& imagePoints, Mat& jacobian = Mat(), double aspectRatio = 0)
  12905. [DllImport(LIBNAME)]
  12906. private static extern void calib3d_Calib3d_projectPoints_10(IntPtr objectPoints_mat_nativeObj, IntPtr rvec_nativeObj, IntPtr tvec_nativeObj, IntPtr cameraMatrix_nativeObj, IntPtr distCoeffs_mat_nativeObj, IntPtr imagePoints_mat_nativeObj, IntPtr jacobian_nativeObj, double aspectRatio);
  12907. [DllImport(LIBNAME)]
  12908. private static extern void calib3d_Calib3d_projectPoints_11(IntPtr objectPoints_mat_nativeObj, IntPtr rvec_nativeObj, IntPtr tvec_nativeObj, IntPtr cameraMatrix_nativeObj, IntPtr distCoeffs_mat_nativeObj, IntPtr imagePoints_mat_nativeObj, IntPtr jacobian_nativeObj);
  12909. [DllImport(LIBNAME)]
  12910. private static extern void calib3d_Calib3d_projectPoints_12(IntPtr objectPoints_mat_nativeObj, IntPtr rvec_nativeObj, IntPtr tvec_nativeObj, IntPtr cameraMatrix_nativeObj, IntPtr distCoeffs_mat_nativeObj, IntPtr imagePoints_mat_nativeObj);
  12911. // C++: bool cv::solvePnP(vector_Point3f objectPoints, vector_Point2f imagePoints, Mat cameraMatrix, vector_double distCoeffs, Mat& rvec, Mat& tvec, bool useExtrinsicGuess = false, int flags = SOLVEPNP_ITERATIVE)
  12912. [DllImport(LIBNAME)]
  12913. [return: MarshalAs(UnmanagedType.U1)]
  12914. private static extern bool calib3d_Calib3d_solvePnP_10(IntPtr objectPoints_mat_nativeObj, IntPtr imagePoints_mat_nativeObj, IntPtr cameraMatrix_nativeObj, IntPtr distCoeffs_mat_nativeObj, IntPtr rvec_nativeObj, IntPtr tvec_nativeObj, [MarshalAs(UnmanagedType.U1)] bool useExtrinsicGuess, int flags);
  12915. [DllImport(LIBNAME)]
  12916. [return: MarshalAs(UnmanagedType.U1)]
  12917. private static extern bool calib3d_Calib3d_solvePnP_11(IntPtr objectPoints_mat_nativeObj, IntPtr imagePoints_mat_nativeObj, IntPtr cameraMatrix_nativeObj, IntPtr distCoeffs_mat_nativeObj, IntPtr rvec_nativeObj, IntPtr tvec_nativeObj, [MarshalAs(UnmanagedType.U1)] bool useExtrinsicGuess);
  12918. [DllImport(LIBNAME)]
  12919. [return: MarshalAs(UnmanagedType.U1)]
  12920. private static extern bool calib3d_Calib3d_solvePnP_12(IntPtr objectPoints_mat_nativeObj, IntPtr imagePoints_mat_nativeObj, IntPtr cameraMatrix_nativeObj, IntPtr distCoeffs_mat_nativeObj, IntPtr rvec_nativeObj, IntPtr tvec_nativeObj);
  12921. // C++: bool cv::solvePnPRansac(vector_Point3f objectPoints, vector_Point2f imagePoints, Mat cameraMatrix, vector_double distCoeffs, Mat& rvec, Mat& tvec, bool useExtrinsicGuess = false, int iterationsCount = 100, float reprojectionError = 8.0, double confidence = 0.99, Mat& inliers = Mat(), int flags = SOLVEPNP_ITERATIVE)
  12922. [DllImport(LIBNAME)]
  12923. [return: MarshalAs(UnmanagedType.U1)]
  12924. private static extern bool calib3d_Calib3d_solvePnPRansac_10(IntPtr objectPoints_mat_nativeObj, IntPtr imagePoints_mat_nativeObj, IntPtr cameraMatrix_nativeObj, IntPtr distCoeffs_mat_nativeObj, IntPtr rvec_nativeObj, IntPtr tvec_nativeObj, [MarshalAs(UnmanagedType.U1)] bool useExtrinsicGuess, int iterationsCount, float reprojectionError, double confidence, IntPtr inliers_nativeObj, int flags);
  12925. [DllImport(LIBNAME)]
  12926. [return: MarshalAs(UnmanagedType.U1)]
  12927. private static extern bool calib3d_Calib3d_solvePnPRansac_11(IntPtr objectPoints_mat_nativeObj, IntPtr imagePoints_mat_nativeObj, IntPtr cameraMatrix_nativeObj, IntPtr distCoeffs_mat_nativeObj, IntPtr rvec_nativeObj, IntPtr tvec_nativeObj, [MarshalAs(UnmanagedType.U1)] bool useExtrinsicGuess, int iterationsCount, float reprojectionError, double confidence, IntPtr inliers_nativeObj);
  12928. [DllImport(LIBNAME)]
  12929. [return: MarshalAs(UnmanagedType.U1)]
  12930. private static extern bool calib3d_Calib3d_solvePnPRansac_12(IntPtr objectPoints_mat_nativeObj, IntPtr imagePoints_mat_nativeObj, IntPtr cameraMatrix_nativeObj, IntPtr distCoeffs_mat_nativeObj, IntPtr rvec_nativeObj, IntPtr tvec_nativeObj, [MarshalAs(UnmanagedType.U1)] bool useExtrinsicGuess, int iterationsCount, float reprojectionError, double confidence);
  12931. [DllImport(LIBNAME)]
  12932. [return: MarshalAs(UnmanagedType.U1)]
  12933. private static extern bool calib3d_Calib3d_solvePnPRansac_13(IntPtr objectPoints_mat_nativeObj, IntPtr imagePoints_mat_nativeObj, IntPtr cameraMatrix_nativeObj, IntPtr distCoeffs_mat_nativeObj, IntPtr rvec_nativeObj, IntPtr tvec_nativeObj, [MarshalAs(UnmanagedType.U1)] bool useExtrinsicGuess, int iterationsCount, float reprojectionError);
  12934. [DllImport(LIBNAME)]
  12935. [return: MarshalAs(UnmanagedType.U1)]
  12936. private static extern bool calib3d_Calib3d_solvePnPRansac_14(IntPtr objectPoints_mat_nativeObj, IntPtr imagePoints_mat_nativeObj, IntPtr cameraMatrix_nativeObj, IntPtr distCoeffs_mat_nativeObj, IntPtr rvec_nativeObj, IntPtr tvec_nativeObj, [MarshalAs(UnmanagedType.U1)] bool useExtrinsicGuess, int iterationsCount);
  12937. [DllImport(LIBNAME)]
  12938. [return: MarshalAs(UnmanagedType.U1)]
  12939. private static extern bool calib3d_Calib3d_solvePnPRansac_15(IntPtr objectPoints_mat_nativeObj, IntPtr imagePoints_mat_nativeObj, IntPtr cameraMatrix_nativeObj, IntPtr distCoeffs_mat_nativeObj, IntPtr rvec_nativeObj, IntPtr tvec_nativeObj, [MarshalAs(UnmanagedType.U1)] bool useExtrinsicGuess);
  12940. [DllImport(LIBNAME)]
  12941. [return: MarshalAs(UnmanagedType.U1)]
  12942. private static extern bool calib3d_Calib3d_solvePnPRansac_16(IntPtr objectPoints_mat_nativeObj, IntPtr imagePoints_mat_nativeObj, IntPtr cameraMatrix_nativeObj, IntPtr distCoeffs_mat_nativeObj, IntPtr rvec_nativeObj, IntPtr tvec_nativeObj);
  12943. // C++: bool cv::solvePnPRansac(vector_Point3f objectPoints, vector_Point2f imagePoints, Mat& cameraMatrix, vector_double distCoeffs, Mat& rvec, Mat& tvec, Mat& inliers, UsacParams _params = UsacParams())
  12944. [DllImport(LIBNAME)]
  12945. [return: MarshalAs(UnmanagedType.U1)]
  12946. private static extern bool calib3d_Calib3d_solvePnPRansac_17(IntPtr objectPoints_mat_nativeObj, IntPtr imagePoints_mat_nativeObj, IntPtr cameraMatrix_nativeObj, IntPtr distCoeffs_mat_nativeObj, IntPtr rvec_nativeObj, IntPtr tvec_nativeObj, IntPtr inliers_nativeObj, IntPtr _params_nativeObj);
  12947. [DllImport(LIBNAME)]
  12948. [return: MarshalAs(UnmanagedType.U1)]
  12949. private static extern bool calib3d_Calib3d_solvePnPRansac_18(IntPtr objectPoints_mat_nativeObj, IntPtr imagePoints_mat_nativeObj, IntPtr cameraMatrix_nativeObj, IntPtr distCoeffs_mat_nativeObj, IntPtr rvec_nativeObj, IntPtr tvec_nativeObj, IntPtr inliers_nativeObj);
  12950. // C++: int cv::solveP3P(Mat objectPoints, Mat imagePoints, Mat cameraMatrix, Mat distCoeffs, vector_Mat& rvecs, vector_Mat& tvecs, int flags)
  12951. [DllImport(LIBNAME)]
  12952. private static extern int calib3d_Calib3d_solveP3P_10(IntPtr objectPoints_nativeObj, IntPtr imagePoints_nativeObj, IntPtr cameraMatrix_nativeObj, IntPtr distCoeffs_nativeObj, IntPtr rvecs_mat_nativeObj, IntPtr tvecs_mat_nativeObj, int flags);
  12953. // C++: void cv::solvePnPRefineLM(Mat objectPoints, Mat imagePoints, Mat cameraMatrix, Mat distCoeffs, Mat& rvec, Mat& tvec, TermCriteria criteria = TermCriteria(TermCriteria::EPS + TermCriteria::COUNT, 20, FLT_EPSILON))
  12954. [DllImport(LIBNAME)]
  12955. private static extern void calib3d_Calib3d_solvePnPRefineLM_10(IntPtr objectPoints_nativeObj, IntPtr imagePoints_nativeObj, IntPtr cameraMatrix_nativeObj, IntPtr distCoeffs_nativeObj, IntPtr rvec_nativeObj, IntPtr tvec_nativeObj, int criteria_type, int criteria_maxCount, double criteria_epsilon);
  12956. [DllImport(LIBNAME)]
  12957. private static extern void calib3d_Calib3d_solvePnPRefineLM_11(IntPtr objectPoints_nativeObj, IntPtr imagePoints_nativeObj, IntPtr cameraMatrix_nativeObj, IntPtr distCoeffs_nativeObj, IntPtr rvec_nativeObj, IntPtr tvec_nativeObj);
  12958. // C++: void cv::solvePnPRefineVVS(Mat objectPoints, Mat imagePoints, Mat cameraMatrix, Mat distCoeffs, Mat& rvec, Mat& tvec, TermCriteria criteria = TermCriteria(TermCriteria::EPS + TermCriteria::COUNT, 20, FLT_EPSILON), double VVSlambda = 1)
  12959. [DllImport(LIBNAME)]
  12960. private static extern void calib3d_Calib3d_solvePnPRefineVVS_10(IntPtr objectPoints_nativeObj, IntPtr imagePoints_nativeObj, IntPtr cameraMatrix_nativeObj, IntPtr distCoeffs_nativeObj, IntPtr rvec_nativeObj, IntPtr tvec_nativeObj, int criteria_type, int criteria_maxCount, double criteria_epsilon, double VVSlambda);
  12961. [DllImport(LIBNAME)]
  12962. private static extern void calib3d_Calib3d_solvePnPRefineVVS_11(IntPtr objectPoints_nativeObj, IntPtr imagePoints_nativeObj, IntPtr cameraMatrix_nativeObj, IntPtr distCoeffs_nativeObj, IntPtr rvec_nativeObj, IntPtr tvec_nativeObj, int criteria_type, int criteria_maxCount, double criteria_epsilon);
  12963. [DllImport(LIBNAME)]
  12964. private static extern void calib3d_Calib3d_solvePnPRefineVVS_12(IntPtr objectPoints_nativeObj, IntPtr imagePoints_nativeObj, IntPtr cameraMatrix_nativeObj, IntPtr distCoeffs_nativeObj, IntPtr rvec_nativeObj, IntPtr tvec_nativeObj);
  12965. // C++: int cv::solvePnPGeneric(Mat objectPoints, Mat imagePoints, Mat cameraMatrix, Mat distCoeffs, vector_Mat& rvecs, vector_Mat& tvecs, bool useExtrinsicGuess = false, SolvePnPMethod flags = SOLVEPNP_ITERATIVE, Mat rvec = Mat(), Mat tvec = Mat(), Mat& reprojectionError = Mat())
  12966. [DllImport(LIBNAME)]
  12967. private static extern int calib3d_Calib3d_solvePnPGeneric_10(IntPtr objectPoints_nativeObj, IntPtr imagePoints_nativeObj, IntPtr cameraMatrix_nativeObj, IntPtr distCoeffs_nativeObj, IntPtr rvecs_mat_nativeObj, IntPtr tvecs_mat_nativeObj, [MarshalAs(UnmanagedType.U1)] bool useExtrinsicGuess, int flags, IntPtr rvec_nativeObj, IntPtr tvec_nativeObj, IntPtr reprojectionError_nativeObj);
  12968. [DllImport(LIBNAME)]
  12969. private static extern int calib3d_Calib3d_solvePnPGeneric_11(IntPtr objectPoints_nativeObj, IntPtr imagePoints_nativeObj, IntPtr cameraMatrix_nativeObj, IntPtr distCoeffs_nativeObj, IntPtr rvecs_mat_nativeObj, IntPtr tvecs_mat_nativeObj, [MarshalAs(UnmanagedType.U1)] bool useExtrinsicGuess, int flags, IntPtr rvec_nativeObj, IntPtr tvec_nativeObj);
  12970. [DllImport(LIBNAME)]
  12971. private static extern int calib3d_Calib3d_solvePnPGeneric_12(IntPtr objectPoints_nativeObj, IntPtr imagePoints_nativeObj, IntPtr cameraMatrix_nativeObj, IntPtr distCoeffs_nativeObj, IntPtr rvecs_mat_nativeObj, IntPtr tvecs_mat_nativeObj, [MarshalAs(UnmanagedType.U1)] bool useExtrinsicGuess, int flags, IntPtr rvec_nativeObj);
  12972. [DllImport(LIBNAME)]
  12973. private static extern int calib3d_Calib3d_solvePnPGeneric_13(IntPtr objectPoints_nativeObj, IntPtr imagePoints_nativeObj, IntPtr cameraMatrix_nativeObj, IntPtr distCoeffs_nativeObj, IntPtr rvecs_mat_nativeObj, IntPtr tvecs_mat_nativeObj, [MarshalAs(UnmanagedType.U1)] bool useExtrinsicGuess, int flags);
  12974. [DllImport(LIBNAME)]
  12975. private static extern int calib3d_Calib3d_solvePnPGeneric_14(IntPtr objectPoints_nativeObj, IntPtr imagePoints_nativeObj, IntPtr cameraMatrix_nativeObj, IntPtr distCoeffs_nativeObj, IntPtr rvecs_mat_nativeObj, IntPtr tvecs_mat_nativeObj, [MarshalAs(UnmanagedType.U1)] bool useExtrinsicGuess);
  12976. [DllImport(LIBNAME)]
  12977. private static extern int calib3d_Calib3d_solvePnPGeneric_15(IntPtr objectPoints_nativeObj, IntPtr imagePoints_nativeObj, IntPtr cameraMatrix_nativeObj, IntPtr distCoeffs_nativeObj, IntPtr rvecs_mat_nativeObj, IntPtr tvecs_mat_nativeObj);
  12978. // C++: Mat cv::initCameraMatrix2D(vector_vector_Point3f objectPoints, vector_vector_Point2f imagePoints, Size imageSize, double aspectRatio = 1.0)
  12979. [DllImport(LIBNAME)]
  12980. private static extern IntPtr calib3d_Calib3d_initCameraMatrix2D_10(IntPtr objectPoints_mat_nativeObj, IntPtr imagePoints_mat_nativeObj, double imageSize_width, double imageSize_height, double aspectRatio);
  12981. [DllImport(LIBNAME)]
  12982. private static extern IntPtr calib3d_Calib3d_initCameraMatrix2D_11(IntPtr objectPoints_mat_nativeObj, IntPtr imagePoints_mat_nativeObj, double imageSize_width, double imageSize_height);
  12983. // C++: bool cv::findChessboardCorners(Mat image, Size patternSize, vector_Point2f& corners, int flags = CALIB_CB_ADAPTIVE_THRESH + CALIB_CB_NORMALIZE_IMAGE)
  12984. [DllImport(LIBNAME)]
  12985. [return: MarshalAs(UnmanagedType.U1)]
  12986. private static extern bool calib3d_Calib3d_findChessboardCorners_10(IntPtr image_nativeObj, double patternSize_width, double patternSize_height, IntPtr corners_mat_nativeObj, int flags);
  12987. [DllImport(LIBNAME)]
  12988. [return: MarshalAs(UnmanagedType.U1)]
  12989. private static extern bool calib3d_Calib3d_findChessboardCorners_11(IntPtr image_nativeObj, double patternSize_width, double patternSize_height, IntPtr corners_mat_nativeObj);
  12990. // C++: bool cv::checkChessboard(Mat img, Size size)
  12991. [DllImport(LIBNAME)]
  12992. [return: MarshalAs(UnmanagedType.U1)]
  12993. private static extern bool calib3d_Calib3d_checkChessboard_10(IntPtr img_nativeObj, double size_width, double size_height);
  12994. // C++: bool cv::findChessboardCornersSB(Mat image, Size patternSize, Mat& corners, int flags, Mat& meta)
  12995. [DllImport(LIBNAME)]
  12996. [return: MarshalAs(UnmanagedType.U1)]
  12997. private static extern bool calib3d_Calib3d_findChessboardCornersSBWithMeta_10(IntPtr image_nativeObj, double patternSize_width, double patternSize_height, IntPtr corners_nativeObj, int flags, IntPtr meta_nativeObj);
  12998. // C++: bool cv::findChessboardCornersSB(Mat image, Size patternSize, Mat& corners, int flags = 0)
  12999. [DllImport(LIBNAME)]
  13000. [return: MarshalAs(UnmanagedType.U1)]
  13001. private static extern bool calib3d_Calib3d_findChessboardCornersSB_10(IntPtr image_nativeObj, double patternSize_width, double patternSize_height, IntPtr corners_nativeObj, int flags);
  13002. [DllImport(LIBNAME)]
  13003. [return: MarshalAs(UnmanagedType.U1)]
  13004. private static extern bool calib3d_Calib3d_findChessboardCornersSB_11(IntPtr image_nativeObj, double patternSize_width, double patternSize_height, IntPtr corners_nativeObj);
  13005. // C++: Scalar cv::estimateChessboardSharpness(Mat image, Size patternSize, Mat corners, float rise_distance = 0.8F, bool vertical = false, Mat& sharpness = Mat())
  13006. [DllImport(LIBNAME)]
  13007. private static extern void calib3d_Calib3d_estimateChessboardSharpness_10(IntPtr image_nativeObj, double patternSize_width, double patternSize_height, IntPtr corners_nativeObj, float rise_distance, [MarshalAs(UnmanagedType.U1)] bool vertical, IntPtr sharpness_nativeObj, double[] retVal);
  13008. [DllImport(LIBNAME)]
  13009. private static extern void calib3d_Calib3d_estimateChessboardSharpness_11(IntPtr image_nativeObj, double patternSize_width, double patternSize_height, IntPtr corners_nativeObj, float rise_distance, [MarshalAs(UnmanagedType.U1)] bool vertical, double[] retVal);
  13010. [DllImport(LIBNAME)]
  13011. private static extern void calib3d_Calib3d_estimateChessboardSharpness_12(IntPtr image_nativeObj, double patternSize_width, double patternSize_height, IntPtr corners_nativeObj, float rise_distance, double[] retVal);
  13012. [DllImport(LIBNAME)]
  13013. private static extern void calib3d_Calib3d_estimateChessboardSharpness_13(IntPtr image_nativeObj, double patternSize_width, double patternSize_height, IntPtr corners_nativeObj, double[] retVal);
  13014. // C++: bool cv::find4QuadCornerSubpix(Mat img, Mat& corners, Size region_size)
  13015. [DllImport(LIBNAME)]
  13016. [return: MarshalAs(UnmanagedType.U1)]
  13017. private static extern bool calib3d_Calib3d_find4QuadCornerSubpix_10(IntPtr img_nativeObj, IntPtr corners_nativeObj, double region_size_width, double region_size_height);
  13018. // C++: void cv::drawChessboardCorners(Mat& image, Size patternSize, vector_Point2f corners, bool patternWasFound)
  13019. [DllImport(LIBNAME)]
  13020. private static extern void calib3d_Calib3d_drawChessboardCorners_10(IntPtr image_nativeObj, double patternSize_width, double patternSize_height, IntPtr corners_mat_nativeObj, [MarshalAs(UnmanagedType.U1)] bool patternWasFound);
  13021. // C++: void cv::drawFrameAxes(Mat& image, Mat cameraMatrix, Mat distCoeffs, Mat rvec, Mat tvec, float length, int thickness = 3)
  13022. [DllImport(LIBNAME)]
  13023. private static extern void calib3d_Calib3d_drawFrameAxes_10(IntPtr image_nativeObj, IntPtr cameraMatrix_nativeObj, IntPtr distCoeffs_nativeObj, IntPtr rvec_nativeObj, IntPtr tvec_nativeObj, float length, int thickness);
  13024. [DllImport(LIBNAME)]
  13025. private static extern void calib3d_Calib3d_drawFrameAxes_11(IntPtr image_nativeObj, IntPtr cameraMatrix_nativeObj, IntPtr distCoeffs_nativeObj, IntPtr rvec_nativeObj, IntPtr tvec_nativeObj, float length);
  13026. // C++: bool cv::findCirclesGrid(Mat image, Size patternSize, Mat& centers, int flags = CALIB_CB_SYMMETRIC_GRID, Ptr_FeatureDetector blobDetector = SimpleBlobDetector::create())
  13027. [DllImport(LIBNAME)]
  13028. [return: MarshalAs(UnmanagedType.U1)]
  13029. private static extern bool calib3d_Calib3d_findCirclesGrid_10(IntPtr image_nativeObj, double patternSize_width, double patternSize_height, IntPtr centers_nativeObj, int flags);
  13030. [DllImport(LIBNAME)]
  13031. [return: MarshalAs(UnmanagedType.U1)]
  13032. private static extern bool calib3d_Calib3d_findCirclesGrid_12(IntPtr image_nativeObj, double patternSize_width, double patternSize_height, IntPtr centers_nativeObj);
  13033. // C++: double cv::calibrateCamera(vector_Mat objectPoints, vector_Mat imagePoints, Size imageSize, Mat& cameraMatrix, Mat& distCoeffs, vector_Mat& rvecs, vector_Mat& tvecs, Mat& stdDeviationsIntrinsics, Mat& stdDeviationsExtrinsics, Mat& perViewErrors, int flags = 0, TermCriteria criteria = TermCriteria( TermCriteria::COUNT + TermCriteria::EPS, 30, DBL_EPSILON))
  13034. [DllImport(LIBNAME)]
  13035. private static extern double calib3d_Calib3d_calibrateCameraExtended_10(IntPtr objectPoints_mat_nativeObj, IntPtr imagePoints_mat_nativeObj, double imageSize_width, double imageSize_height, IntPtr cameraMatrix_nativeObj, IntPtr distCoeffs_nativeObj, IntPtr rvecs_mat_nativeObj, IntPtr tvecs_mat_nativeObj, IntPtr stdDeviationsIntrinsics_nativeObj, IntPtr stdDeviationsExtrinsics_nativeObj, IntPtr perViewErrors_nativeObj, int flags, int criteria_type, int criteria_maxCount, double criteria_epsilon);
  13036. [DllImport(LIBNAME)]
  13037. private static extern double calib3d_Calib3d_calibrateCameraExtended_11(IntPtr objectPoints_mat_nativeObj, IntPtr imagePoints_mat_nativeObj, double imageSize_width, double imageSize_height, IntPtr cameraMatrix_nativeObj, IntPtr distCoeffs_nativeObj, IntPtr rvecs_mat_nativeObj, IntPtr tvecs_mat_nativeObj, IntPtr stdDeviationsIntrinsics_nativeObj, IntPtr stdDeviationsExtrinsics_nativeObj, IntPtr perViewErrors_nativeObj, int flags);
  13038. [DllImport(LIBNAME)]
  13039. private static extern double calib3d_Calib3d_calibrateCameraExtended_12(IntPtr objectPoints_mat_nativeObj, IntPtr imagePoints_mat_nativeObj, double imageSize_width, double imageSize_height, IntPtr cameraMatrix_nativeObj, IntPtr distCoeffs_nativeObj, IntPtr rvecs_mat_nativeObj, IntPtr tvecs_mat_nativeObj, IntPtr stdDeviationsIntrinsics_nativeObj, IntPtr stdDeviationsExtrinsics_nativeObj, IntPtr perViewErrors_nativeObj);
  13040. // C++: double cv::calibrateCamera(vector_Mat objectPoints, vector_Mat imagePoints, Size imageSize, Mat& cameraMatrix, Mat& distCoeffs, vector_Mat& rvecs, vector_Mat& tvecs, int flags = 0, TermCriteria criteria = TermCriteria( TermCriteria::COUNT + TermCriteria::EPS, 30, DBL_EPSILON))
  13041. [DllImport(LIBNAME)]
  13042. private static extern double calib3d_Calib3d_calibrateCamera_10(IntPtr objectPoints_mat_nativeObj, IntPtr imagePoints_mat_nativeObj, double imageSize_width, double imageSize_height, IntPtr cameraMatrix_nativeObj, IntPtr distCoeffs_nativeObj, IntPtr rvecs_mat_nativeObj, IntPtr tvecs_mat_nativeObj, int flags, int criteria_type, int criteria_maxCount, double criteria_epsilon);
  13043. [DllImport(LIBNAME)]
  13044. private static extern double calib3d_Calib3d_calibrateCamera_11(IntPtr objectPoints_mat_nativeObj, IntPtr imagePoints_mat_nativeObj, double imageSize_width, double imageSize_height, IntPtr cameraMatrix_nativeObj, IntPtr distCoeffs_nativeObj, IntPtr rvecs_mat_nativeObj, IntPtr tvecs_mat_nativeObj, int flags);
  13045. [DllImport(LIBNAME)]
  13046. private static extern double calib3d_Calib3d_calibrateCamera_12(IntPtr objectPoints_mat_nativeObj, IntPtr imagePoints_mat_nativeObj, double imageSize_width, double imageSize_height, IntPtr cameraMatrix_nativeObj, IntPtr distCoeffs_nativeObj, IntPtr rvecs_mat_nativeObj, IntPtr tvecs_mat_nativeObj);
  13047. // C++: double cv::calibrateCameraRO(vector_Mat objectPoints, vector_Mat imagePoints, Size imageSize, int iFixedPoint, Mat& cameraMatrix, Mat& distCoeffs, vector_Mat& rvecs, vector_Mat& tvecs, Mat& newObjPoints, Mat& stdDeviationsIntrinsics, Mat& stdDeviationsExtrinsics, Mat& stdDeviationsObjPoints, Mat& perViewErrors, int flags = 0, TermCriteria criteria = TermCriteria( TermCriteria::COUNT + TermCriteria::EPS, 30, DBL_EPSILON))
  13048. [DllImport(LIBNAME)]
  13049. private static extern double calib3d_Calib3d_calibrateCameraROExtended_10(IntPtr objectPoints_mat_nativeObj, IntPtr imagePoints_mat_nativeObj, double imageSize_width, double imageSize_height, int iFixedPoint, IntPtr cameraMatrix_nativeObj, IntPtr distCoeffs_nativeObj, IntPtr rvecs_mat_nativeObj, IntPtr tvecs_mat_nativeObj, IntPtr newObjPoints_nativeObj, IntPtr stdDeviationsIntrinsics_nativeObj, IntPtr stdDeviationsExtrinsics_nativeObj, IntPtr stdDeviationsObjPoints_nativeObj, IntPtr perViewErrors_nativeObj, int flags, int criteria_type, int criteria_maxCount, double criteria_epsilon);
  13050. [DllImport(LIBNAME)]
  13051. private static extern double calib3d_Calib3d_calibrateCameraROExtended_11(IntPtr objectPoints_mat_nativeObj, IntPtr imagePoints_mat_nativeObj, double imageSize_width, double imageSize_height, int iFixedPoint, IntPtr cameraMatrix_nativeObj, IntPtr distCoeffs_nativeObj, IntPtr rvecs_mat_nativeObj, IntPtr tvecs_mat_nativeObj, IntPtr newObjPoints_nativeObj, IntPtr stdDeviationsIntrinsics_nativeObj, IntPtr stdDeviationsExtrinsics_nativeObj, IntPtr stdDeviationsObjPoints_nativeObj, IntPtr perViewErrors_nativeObj, int flags);
  13052. [DllImport(LIBNAME)]
  13053. private static extern double calib3d_Calib3d_calibrateCameraROExtended_12(IntPtr objectPoints_mat_nativeObj, IntPtr imagePoints_mat_nativeObj, double imageSize_width, double imageSize_height, int iFixedPoint, IntPtr cameraMatrix_nativeObj, IntPtr distCoeffs_nativeObj, IntPtr rvecs_mat_nativeObj, IntPtr tvecs_mat_nativeObj, IntPtr newObjPoints_nativeObj, IntPtr stdDeviationsIntrinsics_nativeObj, IntPtr stdDeviationsExtrinsics_nativeObj, IntPtr stdDeviationsObjPoints_nativeObj, IntPtr perViewErrors_nativeObj);
  13054. // C++: double cv::calibrateCameraRO(vector_Mat objectPoints, vector_Mat imagePoints, Size imageSize, int iFixedPoint, Mat& cameraMatrix, Mat& distCoeffs, vector_Mat& rvecs, vector_Mat& tvecs, Mat& newObjPoints, int flags = 0, TermCriteria criteria = TermCriteria( TermCriteria::COUNT + TermCriteria::EPS, 30, DBL_EPSILON))
  13055. [DllImport(LIBNAME)]
  13056. private static extern double calib3d_Calib3d_calibrateCameraRO_10(IntPtr objectPoints_mat_nativeObj, IntPtr imagePoints_mat_nativeObj, double imageSize_width, double imageSize_height, int iFixedPoint, IntPtr cameraMatrix_nativeObj, IntPtr distCoeffs_nativeObj, IntPtr rvecs_mat_nativeObj, IntPtr tvecs_mat_nativeObj, IntPtr newObjPoints_nativeObj, int flags, int criteria_type, int criteria_maxCount, double criteria_epsilon);
  13057. [DllImport(LIBNAME)]
  13058. private static extern double calib3d_Calib3d_calibrateCameraRO_11(IntPtr objectPoints_mat_nativeObj, IntPtr imagePoints_mat_nativeObj, double imageSize_width, double imageSize_height, int iFixedPoint, IntPtr cameraMatrix_nativeObj, IntPtr distCoeffs_nativeObj, IntPtr rvecs_mat_nativeObj, IntPtr tvecs_mat_nativeObj, IntPtr newObjPoints_nativeObj, int flags);
  13059. [DllImport(LIBNAME)]
  13060. private static extern double calib3d_Calib3d_calibrateCameraRO_12(IntPtr objectPoints_mat_nativeObj, IntPtr imagePoints_mat_nativeObj, double imageSize_width, double imageSize_height, int iFixedPoint, IntPtr cameraMatrix_nativeObj, IntPtr distCoeffs_nativeObj, IntPtr rvecs_mat_nativeObj, IntPtr tvecs_mat_nativeObj, IntPtr newObjPoints_nativeObj);
  13061. // C++: void cv::calibrationMatrixValues(Mat cameraMatrix, Size imageSize, double apertureWidth, double apertureHeight, double& fovx, double& fovy, double& focalLength, Point2d& principalPoint, double& aspectRatio)
  13062. [DllImport(LIBNAME)]
  13063. private static extern void calib3d_Calib3d_calibrationMatrixValues_10(IntPtr cameraMatrix_nativeObj, double imageSize_width, double imageSize_height, double apertureWidth, double apertureHeight, double[] fovx_out, double[] fovy_out, double[] focalLength_out, double[] principalPoint_out, double[] aspectRatio_out);
  13064. // C++: double cv::stereoCalibrate(vector_Mat objectPoints, vector_Mat imagePoints1, vector_Mat imagePoints2, Mat& cameraMatrix1, Mat& distCoeffs1, Mat& cameraMatrix2, Mat& distCoeffs2, Size imageSize, Mat& R, Mat& T, Mat& E, Mat& F, vector_Mat& rvecs, vector_Mat& tvecs, Mat& perViewErrors, int flags = CALIB_FIX_INTRINSIC, TermCriteria criteria = TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, 30, 1e-6))
  13065. [DllImport(LIBNAME)]
  13066. private static extern double calib3d_Calib3d_stereoCalibrateExtended_10(IntPtr objectPoints_mat_nativeObj, IntPtr imagePoints1_mat_nativeObj, IntPtr imagePoints2_mat_nativeObj, IntPtr cameraMatrix1_nativeObj, IntPtr distCoeffs1_nativeObj, IntPtr cameraMatrix2_nativeObj, IntPtr distCoeffs2_nativeObj, double imageSize_width, double imageSize_height, IntPtr R_nativeObj, IntPtr T_nativeObj, IntPtr E_nativeObj, IntPtr F_nativeObj, IntPtr rvecs_mat_nativeObj, IntPtr tvecs_mat_nativeObj, IntPtr perViewErrors_nativeObj, int flags, int criteria_type, int criteria_maxCount, double criteria_epsilon);
  13067. [DllImport(LIBNAME)]
  13068. private static extern double calib3d_Calib3d_stereoCalibrateExtended_11(IntPtr objectPoints_mat_nativeObj, IntPtr imagePoints1_mat_nativeObj, IntPtr imagePoints2_mat_nativeObj, IntPtr cameraMatrix1_nativeObj, IntPtr distCoeffs1_nativeObj, IntPtr cameraMatrix2_nativeObj, IntPtr distCoeffs2_nativeObj, double imageSize_width, double imageSize_height, IntPtr R_nativeObj, IntPtr T_nativeObj, IntPtr E_nativeObj, IntPtr F_nativeObj, IntPtr rvecs_mat_nativeObj, IntPtr tvecs_mat_nativeObj, IntPtr perViewErrors_nativeObj, int flags);
  13069. [DllImport(LIBNAME)]
  13070. private static extern double calib3d_Calib3d_stereoCalibrateExtended_12(IntPtr objectPoints_mat_nativeObj, IntPtr imagePoints1_mat_nativeObj, IntPtr imagePoints2_mat_nativeObj, IntPtr cameraMatrix1_nativeObj, IntPtr distCoeffs1_nativeObj, IntPtr cameraMatrix2_nativeObj, IntPtr distCoeffs2_nativeObj, double imageSize_width, double imageSize_height, IntPtr R_nativeObj, IntPtr T_nativeObj, IntPtr E_nativeObj, IntPtr F_nativeObj, IntPtr rvecs_mat_nativeObj, IntPtr tvecs_mat_nativeObj, IntPtr perViewErrors_nativeObj);
  13071. // C++: double cv::stereoCalibrate(vector_Mat objectPoints, vector_Mat imagePoints1, vector_Mat imagePoints2, Mat& cameraMatrix1, Mat& distCoeffs1, Mat& cameraMatrix2, Mat& distCoeffs2, Size imageSize, Mat& R, Mat& T, Mat& E, Mat& F, int flags = CALIB_FIX_INTRINSIC, TermCriteria criteria = TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, 30, 1e-6))
  13072. [DllImport(LIBNAME)]
  13073. private static extern double calib3d_Calib3d_stereoCalibrate_10(IntPtr objectPoints_mat_nativeObj, IntPtr imagePoints1_mat_nativeObj, IntPtr imagePoints2_mat_nativeObj, IntPtr cameraMatrix1_nativeObj, IntPtr distCoeffs1_nativeObj, IntPtr cameraMatrix2_nativeObj, IntPtr distCoeffs2_nativeObj, double imageSize_width, double imageSize_height, IntPtr R_nativeObj, IntPtr T_nativeObj, IntPtr E_nativeObj, IntPtr F_nativeObj, int flags, int criteria_type, int criteria_maxCount, double criteria_epsilon);
  13074. [DllImport(LIBNAME)]
  13075. private static extern double calib3d_Calib3d_stereoCalibrate_11(IntPtr objectPoints_mat_nativeObj, IntPtr imagePoints1_mat_nativeObj, IntPtr imagePoints2_mat_nativeObj, IntPtr cameraMatrix1_nativeObj, IntPtr distCoeffs1_nativeObj, IntPtr cameraMatrix2_nativeObj, IntPtr distCoeffs2_nativeObj, double imageSize_width, double imageSize_height, IntPtr R_nativeObj, IntPtr T_nativeObj, IntPtr E_nativeObj, IntPtr F_nativeObj, int flags);
  13076. [DllImport(LIBNAME)]
  13077. private static extern double calib3d_Calib3d_stereoCalibrate_12(IntPtr objectPoints_mat_nativeObj, IntPtr imagePoints1_mat_nativeObj, IntPtr imagePoints2_mat_nativeObj, IntPtr cameraMatrix1_nativeObj, IntPtr distCoeffs1_nativeObj, IntPtr cameraMatrix2_nativeObj, IntPtr distCoeffs2_nativeObj, double imageSize_width, double imageSize_height, IntPtr R_nativeObj, IntPtr T_nativeObj, IntPtr E_nativeObj, IntPtr F_nativeObj);
  13078. // C++: double cv::stereoCalibrate(vector_Mat objectPoints, vector_Mat imagePoints1, vector_Mat imagePoints2, Mat& cameraMatrix1, Mat& distCoeffs1, Mat& cameraMatrix2, Mat& distCoeffs2, Size imageSize, Mat& R, Mat& T, Mat& E, Mat& F, Mat& perViewErrors, int flags = CALIB_FIX_INTRINSIC, TermCriteria criteria = TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, 30, 1e-6))
  13079. [DllImport(LIBNAME)]
  13080. private static extern double calib3d_Calib3d_stereoCalibrate_13(IntPtr objectPoints_mat_nativeObj, IntPtr imagePoints1_mat_nativeObj, IntPtr imagePoints2_mat_nativeObj, IntPtr cameraMatrix1_nativeObj, IntPtr distCoeffs1_nativeObj, IntPtr cameraMatrix2_nativeObj, IntPtr distCoeffs2_nativeObj, double imageSize_width, double imageSize_height, IntPtr R_nativeObj, IntPtr T_nativeObj, IntPtr E_nativeObj, IntPtr F_nativeObj, IntPtr perViewErrors_nativeObj, int flags, int criteria_type, int criteria_maxCount, double criteria_epsilon);
  13081. [DllImport(LIBNAME)]
  13082. private static extern double calib3d_Calib3d_stereoCalibrate_14(IntPtr objectPoints_mat_nativeObj, IntPtr imagePoints1_mat_nativeObj, IntPtr imagePoints2_mat_nativeObj, IntPtr cameraMatrix1_nativeObj, IntPtr distCoeffs1_nativeObj, IntPtr cameraMatrix2_nativeObj, IntPtr distCoeffs2_nativeObj, double imageSize_width, double imageSize_height, IntPtr R_nativeObj, IntPtr T_nativeObj, IntPtr E_nativeObj, IntPtr F_nativeObj, IntPtr perViewErrors_nativeObj, int flags);
  13083. [DllImport(LIBNAME)]
  13084. private static extern double calib3d_Calib3d_stereoCalibrate_15(IntPtr objectPoints_mat_nativeObj, IntPtr imagePoints1_mat_nativeObj, IntPtr imagePoints2_mat_nativeObj, IntPtr cameraMatrix1_nativeObj, IntPtr distCoeffs1_nativeObj, IntPtr cameraMatrix2_nativeObj, IntPtr distCoeffs2_nativeObj, double imageSize_width, double imageSize_height, IntPtr R_nativeObj, IntPtr T_nativeObj, IntPtr E_nativeObj, IntPtr F_nativeObj, IntPtr perViewErrors_nativeObj);
  13085. // C++: void cv::stereoRectify(Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Size imageSize, Mat R, Mat T, Mat& R1, Mat& R2, Mat& P1, Mat& P2, Mat& Q, int flags = CALIB_ZERO_DISPARITY, double alpha = -1, Size newImageSize = Size(), Rect* validPixROI1 = 0, Rect* validPixROI2 = 0)
  13086. [DllImport(LIBNAME)]
  13087. private static extern void calib3d_Calib3d_stereoRectify_10(IntPtr cameraMatrix1_nativeObj, IntPtr distCoeffs1_nativeObj, IntPtr cameraMatrix2_nativeObj, IntPtr distCoeffs2_nativeObj, double imageSize_width, double imageSize_height, IntPtr R_nativeObj, IntPtr T_nativeObj, IntPtr R1_nativeObj, IntPtr R2_nativeObj, IntPtr P1_nativeObj, IntPtr P2_nativeObj, IntPtr Q_nativeObj, int flags, double alpha, double newImageSize_width, double newImageSize_height, double[] validPixROI1_out, double[] validPixROI2_out);
  13088. [DllImport(LIBNAME)]
  13089. private static extern void calib3d_Calib3d_stereoRectify_11(IntPtr cameraMatrix1_nativeObj, IntPtr distCoeffs1_nativeObj, IntPtr cameraMatrix2_nativeObj, IntPtr distCoeffs2_nativeObj, double imageSize_width, double imageSize_height, IntPtr R_nativeObj, IntPtr T_nativeObj, IntPtr R1_nativeObj, IntPtr R2_nativeObj, IntPtr P1_nativeObj, IntPtr P2_nativeObj, IntPtr Q_nativeObj, int flags, double alpha, double newImageSize_width, double newImageSize_height, double[] validPixROI1_out);
  13090. [DllImport(LIBNAME)]
  13091. private static extern void calib3d_Calib3d_stereoRectify_12(IntPtr cameraMatrix1_nativeObj, IntPtr distCoeffs1_nativeObj, IntPtr cameraMatrix2_nativeObj, IntPtr distCoeffs2_nativeObj, double imageSize_width, double imageSize_height, IntPtr R_nativeObj, IntPtr T_nativeObj, IntPtr R1_nativeObj, IntPtr R2_nativeObj, IntPtr P1_nativeObj, IntPtr P2_nativeObj, IntPtr Q_nativeObj, int flags, double alpha, double newImageSize_width, double newImageSize_height);
  13092. [DllImport(LIBNAME)]
  13093. private static extern void calib3d_Calib3d_stereoRectify_13(IntPtr cameraMatrix1_nativeObj, IntPtr distCoeffs1_nativeObj, IntPtr cameraMatrix2_nativeObj, IntPtr distCoeffs2_nativeObj, double imageSize_width, double imageSize_height, IntPtr R_nativeObj, IntPtr T_nativeObj, IntPtr R1_nativeObj, IntPtr R2_nativeObj, IntPtr P1_nativeObj, IntPtr P2_nativeObj, IntPtr Q_nativeObj, int flags, double alpha);
  13094. [DllImport(LIBNAME)]
  13095. private static extern void calib3d_Calib3d_stereoRectify_14(IntPtr cameraMatrix1_nativeObj, IntPtr distCoeffs1_nativeObj, IntPtr cameraMatrix2_nativeObj, IntPtr distCoeffs2_nativeObj, double imageSize_width, double imageSize_height, IntPtr R_nativeObj, IntPtr T_nativeObj, IntPtr R1_nativeObj, IntPtr R2_nativeObj, IntPtr P1_nativeObj, IntPtr P2_nativeObj, IntPtr Q_nativeObj, int flags);
  13096. [DllImport(LIBNAME)]
  13097. private static extern void calib3d_Calib3d_stereoRectify_15(IntPtr cameraMatrix1_nativeObj, IntPtr distCoeffs1_nativeObj, IntPtr cameraMatrix2_nativeObj, IntPtr distCoeffs2_nativeObj, double imageSize_width, double imageSize_height, IntPtr R_nativeObj, IntPtr T_nativeObj, IntPtr R1_nativeObj, IntPtr R2_nativeObj, IntPtr P1_nativeObj, IntPtr P2_nativeObj, IntPtr Q_nativeObj);
  13098. // C++: bool cv::stereoRectifyUncalibrated(Mat points1, Mat points2, Mat F, Size imgSize, Mat& H1, Mat& H2, double threshold = 5)
  13099. [DllImport(LIBNAME)]
  13100. [return: MarshalAs(UnmanagedType.U1)]
  13101. private static extern bool calib3d_Calib3d_stereoRectifyUncalibrated_10(IntPtr points1_nativeObj, IntPtr points2_nativeObj, IntPtr F_nativeObj, double imgSize_width, double imgSize_height, IntPtr H1_nativeObj, IntPtr H2_nativeObj, double threshold);
  13102. [DllImport(LIBNAME)]
  13103. [return: MarshalAs(UnmanagedType.U1)]
  13104. private static extern bool calib3d_Calib3d_stereoRectifyUncalibrated_11(IntPtr points1_nativeObj, IntPtr points2_nativeObj, IntPtr F_nativeObj, double imgSize_width, double imgSize_height, IntPtr H1_nativeObj, IntPtr H2_nativeObj);
  13105. // C++: float cv::rectify3Collinear(Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Mat cameraMatrix3, Mat distCoeffs3, vector_Mat imgpt1, vector_Mat imgpt3, Size imageSize, Mat R12, Mat T12, Mat R13, Mat T13, Mat& R1, Mat& R2, Mat& R3, Mat& P1, Mat& P2, Mat& P3, Mat& Q, double alpha, Size newImgSize, Rect* roi1, Rect* roi2, int flags)
  13106. [DllImport(LIBNAME)]
  13107. private static extern float calib3d_Calib3d_rectify3Collinear_10(IntPtr cameraMatrix1_nativeObj, IntPtr distCoeffs1_nativeObj, IntPtr cameraMatrix2_nativeObj, IntPtr distCoeffs2_nativeObj, IntPtr cameraMatrix3_nativeObj, IntPtr distCoeffs3_nativeObj, IntPtr imgpt1_mat_nativeObj, IntPtr imgpt3_mat_nativeObj, double imageSize_width, double imageSize_height, IntPtr R12_nativeObj, IntPtr T12_nativeObj, IntPtr R13_nativeObj, IntPtr T13_nativeObj, IntPtr R1_nativeObj, IntPtr R2_nativeObj, IntPtr R3_nativeObj, IntPtr P1_nativeObj, IntPtr P2_nativeObj, IntPtr P3_nativeObj, IntPtr Q_nativeObj, double alpha, double newImgSize_width, double newImgSize_height, double[] roi1_out, double[] roi2_out, int flags);
  13108. // C++: Mat cv::getOptimalNewCameraMatrix(Mat cameraMatrix, Mat distCoeffs, Size imageSize, double alpha, Size newImgSize = Size(), Rect* validPixROI = 0, bool centerPrincipalPoint = false)
  13109. [DllImport(LIBNAME)]
  13110. private static extern IntPtr calib3d_Calib3d_getOptimalNewCameraMatrix_10(IntPtr cameraMatrix_nativeObj, IntPtr distCoeffs_nativeObj, double imageSize_width, double imageSize_height, double alpha, double newImgSize_width, double newImgSize_height, double[] validPixROI_out, [MarshalAs(UnmanagedType.U1)] bool centerPrincipalPoint);
  13111. [DllImport(LIBNAME)]
  13112. private static extern IntPtr calib3d_Calib3d_getOptimalNewCameraMatrix_11(IntPtr cameraMatrix_nativeObj, IntPtr distCoeffs_nativeObj, double imageSize_width, double imageSize_height, double alpha, double newImgSize_width, double newImgSize_height, double[] validPixROI_out);
  13113. [DllImport(LIBNAME)]
  13114. private static extern IntPtr calib3d_Calib3d_getOptimalNewCameraMatrix_12(IntPtr cameraMatrix_nativeObj, IntPtr distCoeffs_nativeObj, double imageSize_width, double imageSize_height, double alpha, double newImgSize_width, double newImgSize_height);
  13115. [DllImport(LIBNAME)]
  13116. private static extern IntPtr calib3d_Calib3d_getOptimalNewCameraMatrix_13(IntPtr cameraMatrix_nativeObj, IntPtr distCoeffs_nativeObj, double imageSize_width, double imageSize_height, double alpha);
  13117. // C++: void cv::calibrateHandEye(vector_Mat R_gripper2base, vector_Mat t_gripper2base, vector_Mat R_target2cam, vector_Mat t_target2cam, Mat& R_cam2gripper, Mat& t_cam2gripper, HandEyeCalibrationMethod method = CALIB_HAND_EYE_TSAI)
  13118. [DllImport(LIBNAME)]
  13119. private static extern void calib3d_Calib3d_calibrateHandEye_10(IntPtr R_gripper2base_mat_nativeObj, IntPtr t_gripper2base_mat_nativeObj, IntPtr R_target2cam_mat_nativeObj, IntPtr t_target2cam_mat_nativeObj, IntPtr R_cam2gripper_nativeObj, IntPtr t_cam2gripper_nativeObj, int method);
  13120. [DllImport(LIBNAME)]
  13121. private static extern void calib3d_Calib3d_calibrateHandEye_11(IntPtr R_gripper2base_mat_nativeObj, IntPtr t_gripper2base_mat_nativeObj, IntPtr R_target2cam_mat_nativeObj, IntPtr t_target2cam_mat_nativeObj, IntPtr R_cam2gripper_nativeObj, IntPtr t_cam2gripper_nativeObj);
  13122. // C++: void cv::calibrateRobotWorldHandEye(vector_Mat R_world2cam, vector_Mat t_world2cam, vector_Mat R_base2gripper, vector_Mat t_base2gripper, Mat& R_base2world, Mat& t_base2world, Mat& R_gripper2cam, Mat& t_gripper2cam, RobotWorldHandEyeCalibrationMethod method = CALIB_ROBOT_WORLD_HAND_EYE_SHAH)
  13123. [DllImport(LIBNAME)]
  13124. private static extern void calib3d_Calib3d_calibrateRobotWorldHandEye_10(IntPtr R_world2cam_mat_nativeObj, IntPtr t_world2cam_mat_nativeObj, IntPtr R_base2gripper_mat_nativeObj, IntPtr t_base2gripper_mat_nativeObj, IntPtr R_base2world_nativeObj, IntPtr t_base2world_nativeObj, IntPtr R_gripper2cam_nativeObj, IntPtr t_gripper2cam_nativeObj, int method);
  13125. [DllImport(LIBNAME)]
  13126. private static extern void calib3d_Calib3d_calibrateRobotWorldHandEye_11(IntPtr R_world2cam_mat_nativeObj, IntPtr t_world2cam_mat_nativeObj, IntPtr R_base2gripper_mat_nativeObj, IntPtr t_base2gripper_mat_nativeObj, IntPtr R_base2world_nativeObj, IntPtr t_base2world_nativeObj, IntPtr R_gripper2cam_nativeObj, IntPtr t_gripper2cam_nativeObj);
  13127. // C++: void cv::convertPointsToHomogeneous(Mat src, Mat& dst)
  13128. [DllImport(LIBNAME)]
  13129. private static extern void calib3d_Calib3d_convertPointsToHomogeneous_10(IntPtr src_nativeObj, IntPtr dst_nativeObj);
  13130. // C++: void cv::convertPointsFromHomogeneous(Mat src, Mat& dst)
  13131. [DllImport(LIBNAME)]
  13132. private static extern void calib3d_Calib3d_convertPointsFromHomogeneous_10(IntPtr src_nativeObj, IntPtr dst_nativeObj);
  13133. // C++: Mat cv::findFundamentalMat(vector_Point2f points1, vector_Point2f points2, int method, double ransacReprojThreshold, double confidence, int maxIters, Mat& mask = Mat())
  13134. [DllImport(LIBNAME)]
  13135. private static extern IntPtr calib3d_Calib3d_findFundamentalMat_10(IntPtr points1_mat_nativeObj, IntPtr points2_mat_nativeObj, int method, double ransacReprojThreshold, double confidence, int maxIters, IntPtr mask_nativeObj);
  13136. [DllImport(LIBNAME)]
  13137. private static extern IntPtr calib3d_Calib3d_findFundamentalMat_11(IntPtr points1_mat_nativeObj, IntPtr points2_mat_nativeObj, int method, double ransacReprojThreshold, double confidence, int maxIters);
  13138. // C++: Mat cv::findFundamentalMat(vector_Point2f points1, vector_Point2f points2, int method = FM_RANSAC, double ransacReprojThreshold = 3., double confidence = 0.99, Mat& mask = Mat())
  13139. [DllImport(LIBNAME)]
  13140. private static extern IntPtr calib3d_Calib3d_findFundamentalMat_12(IntPtr points1_mat_nativeObj, IntPtr points2_mat_nativeObj, int method, double ransacReprojThreshold, double confidence, IntPtr mask_nativeObj);
  13141. [DllImport(LIBNAME)]
  13142. private static extern IntPtr calib3d_Calib3d_findFundamentalMat_13(IntPtr points1_mat_nativeObj, IntPtr points2_mat_nativeObj, int method, double ransacReprojThreshold, double confidence);
  13143. [DllImport(LIBNAME)]
  13144. private static extern IntPtr calib3d_Calib3d_findFundamentalMat_14(IntPtr points1_mat_nativeObj, IntPtr points2_mat_nativeObj, int method, double ransacReprojThreshold);
  13145. [DllImport(LIBNAME)]
  13146. private static extern IntPtr calib3d_Calib3d_findFundamentalMat_15(IntPtr points1_mat_nativeObj, IntPtr points2_mat_nativeObj, int method);
  13147. [DllImport(LIBNAME)]
  13148. private static extern IntPtr calib3d_Calib3d_findFundamentalMat_16(IntPtr points1_mat_nativeObj, IntPtr points2_mat_nativeObj);
  13149. // C++: Mat cv::findFundamentalMat(vector_Point2f points1, vector_Point2f points2, Mat& mask, UsacParams _params)
  13150. [DllImport(LIBNAME)]
  13151. private static extern IntPtr calib3d_Calib3d_findFundamentalMat_17(IntPtr points1_mat_nativeObj, IntPtr points2_mat_nativeObj, IntPtr mask_nativeObj, IntPtr _params_nativeObj);
  13152. // C++: Mat cv::findEssentialMat(Mat points1, Mat points2, Mat cameraMatrix, int method = RANSAC, double prob = 0.999, double threshold = 1.0, int maxIters = 1000, Mat& mask = Mat())
  13153. [DllImport(LIBNAME)]
  13154. private static extern IntPtr calib3d_Calib3d_findEssentialMat_10(IntPtr points1_nativeObj, IntPtr points2_nativeObj, IntPtr cameraMatrix_nativeObj, int method, double prob, double threshold, int maxIters, IntPtr mask_nativeObj);
  13155. [DllImport(LIBNAME)]
  13156. private static extern IntPtr calib3d_Calib3d_findEssentialMat_11(IntPtr points1_nativeObj, IntPtr points2_nativeObj, IntPtr cameraMatrix_nativeObj, int method, double prob, double threshold, int maxIters);
  13157. [DllImport(LIBNAME)]
  13158. private static extern IntPtr calib3d_Calib3d_findEssentialMat_12(IntPtr points1_nativeObj, IntPtr points2_nativeObj, IntPtr cameraMatrix_nativeObj, int method, double prob, double threshold);
  13159. [DllImport(LIBNAME)]
  13160. private static extern IntPtr calib3d_Calib3d_findEssentialMat_13(IntPtr points1_nativeObj, IntPtr points2_nativeObj, IntPtr cameraMatrix_nativeObj, int method, double prob);
  13161. [DllImport(LIBNAME)]
  13162. private static extern IntPtr calib3d_Calib3d_findEssentialMat_14(IntPtr points1_nativeObj, IntPtr points2_nativeObj, IntPtr cameraMatrix_nativeObj, int method);
  13163. [DllImport(LIBNAME)]
  13164. private static extern IntPtr calib3d_Calib3d_findEssentialMat_15(IntPtr points1_nativeObj, IntPtr points2_nativeObj, IntPtr cameraMatrix_nativeObj);
  13165. // C++: Mat cv::findEssentialMat(Mat points1, Mat points2, double focal = 1.0, Point2d pp = Point2d(0, 0), int method = RANSAC, double prob = 0.999, double threshold = 1.0, int maxIters = 1000, Mat& mask = Mat())
  13166. [DllImport(LIBNAME)]
  13167. private static extern IntPtr calib3d_Calib3d_findEssentialMat_16(IntPtr points1_nativeObj, IntPtr points2_nativeObj, double focal, double pp_x, double pp_y, int method, double prob, double threshold, int maxIters, IntPtr mask_nativeObj);
  13168. [DllImport(LIBNAME)]
  13169. private static extern IntPtr calib3d_Calib3d_findEssentialMat_17(IntPtr points1_nativeObj, IntPtr points2_nativeObj, double focal, double pp_x, double pp_y, int method, double prob, double threshold, int maxIters);
  13170. [DllImport(LIBNAME)]
  13171. private static extern IntPtr calib3d_Calib3d_findEssentialMat_18(IntPtr points1_nativeObj, IntPtr points2_nativeObj, double focal, double pp_x, double pp_y, int method, double prob, double threshold);
  13172. [DllImport(LIBNAME)]
  13173. private static extern IntPtr calib3d_Calib3d_findEssentialMat_19(IntPtr points1_nativeObj, IntPtr points2_nativeObj, double focal, double pp_x, double pp_y, int method, double prob);
  13174. [DllImport(LIBNAME)]
  13175. private static extern IntPtr calib3d_Calib3d_findEssentialMat_110(IntPtr points1_nativeObj, IntPtr points2_nativeObj, double focal, double pp_x, double pp_y, int method);
  13176. [DllImport(LIBNAME)]
  13177. private static extern IntPtr calib3d_Calib3d_findEssentialMat_111(IntPtr points1_nativeObj, IntPtr points2_nativeObj, double focal, double pp_x, double pp_y);
  13178. [DllImport(LIBNAME)]
  13179. private static extern IntPtr calib3d_Calib3d_findEssentialMat_112(IntPtr points1_nativeObj, IntPtr points2_nativeObj, double focal);
  13180. [DllImport(LIBNAME)]
  13181. private static extern IntPtr calib3d_Calib3d_findEssentialMat_113(IntPtr points1_nativeObj, IntPtr points2_nativeObj);
  13182. // C++: Mat cv::findEssentialMat(Mat points1, Mat points2, Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, int method = RANSAC, double prob = 0.999, double threshold = 1.0, Mat& mask = Mat())
  13183. [DllImport(LIBNAME)]
  13184. private static extern IntPtr calib3d_Calib3d_findEssentialMat_114(IntPtr points1_nativeObj, IntPtr points2_nativeObj, IntPtr cameraMatrix1_nativeObj, IntPtr distCoeffs1_nativeObj, IntPtr cameraMatrix2_nativeObj, IntPtr distCoeffs2_nativeObj, int method, double prob, double threshold, IntPtr mask_nativeObj);
  13185. [DllImport(LIBNAME)]
  13186. private static extern IntPtr calib3d_Calib3d_findEssentialMat_115(IntPtr points1_nativeObj, IntPtr points2_nativeObj, IntPtr cameraMatrix1_nativeObj, IntPtr distCoeffs1_nativeObj, IntPtr cameraMatrix2_nativeObj, IntPtr distCoeffs2_nativeObj, int method, double prob, double threshold);
  13187. [DllImport(LIBNAME)]
  13188. private static extern IntPtr calib3d_Calib3d_findEssentialMat_116(IntPtr points1_nativeObj, IntPtr points2_nativeObj, IntPtr cameraMatrix1_nativeObj, IntPtr distCoeffs1_nativeObj, IntPtr cameraMatrix2_nativeObj, IntPtr distCoeffs2_nativeObj, int method, double prob);
  13189. [DllImport(LIBNAME)]
  13190. private static extern IntPtr calib3d_Calib3d_findEssentialMat_117(IntPtr points1_nativeObj, IntPtr points2_nativeObj, IntPtr cameraMatrix1_nativeObj, IntPtr distCoeffs1_nativeObj, IntPtr cameraMatrix2_nativeObj, IntPtr distCoeffs2_nativeObj, int method);
  13191. [DllImport(LIBNAME)]
  13192. private static extern IntPtr calib3d_Calib3d_findEssentialMat_118(IntPtr points1_nativeObj, IntPtr points2_nativeObj, IntPtr cameraMatrix1_nativeObj, IntPtr distCoeffs1_nativeObj, IntPtr cameraMatrix2_nativeObj, IntPtr distCoeffs2_nativeObj);
  13193. // C++: Mat cv::findEssentialMat(Mat points1, Mat points2, Mat cameraMatrix1, Mat cameraMatrix2, Mat dist_coeff1, Mat dist_coeff2, Mat& mask, UsacParams _params)
  13194. [DllImport(LIBNAME)]
  13195. private static extern IntPtr calib3d_Calib3d_findEssentialMat_119(IntPtr points1_nativeObj, IntPtr points2_nativeObj, IntPtr cameraMatrix1_nativeObj, IntPtr cameraMatrix2_nativeObj, IntPtr dist_coeff1_nativeObj, IntPtr dist_coeff2_nativeObj, IntPtr mask_nativeObj, IntPtr _params_nativeObj);
  13196. // C++: void cv::decomposeEssentialMat(Mat E, Mat& R1, Mat& R2, Mat& t)
  13197. [DllImport(LIBNAME)]
  13198. private static extern void calib3d_Calib3d_decomposeEssentialMat_10(IntPtr E_nativeObj, IntPtr R1_nativeObj, IntPtr R2_nativeObj, IntPtr t_nativeObj);
  13199. // C++: int cv::recoverPose(Mat points1, Mat points2, Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Mat& E, Mat& R, Mat& t, int method = cv::RANSAC, double prob = 0.999, double threshold = 1.0, Mat& mask = Mat())
  13200. [DllImport(LIBNAME)]
  13201. private static extern int calib3d_Calib3d_recoverPose_10(IntPtr points1_nativeObj, IntPtr points2_nativeObj, IntPtr cameraMatrix1_nativeObj, IntPtr distCoeffs1_nativeObj, IntPtr cameraMatrix2_nativeObj, IntPtr distCoeffs2_nativeObj, IntPtr E_nativeObj, IntPtr R_nativeObj, IntPtr t_nativeObj, int method, double prob, double threshold, IntPtr mask_nativeObj);
  13202. [DllImport(LIBNAME)]
  13203. private static extern int calib3d_Calib3d_recoverPose_11(IntPtr points1_nativeObj, IntPtr points2_nativeObj, IntPtr cameraMatrix1_nativeObj, IntPtr distCoeffs1_nativeObj, IntPtr cameraMatrix2_nativeObj, IntPtr distCoeffs2_nativeObj, IntPtr E_nativeObj, IntPtr R_nativeObj, IntPtr t_nativeObj, int method, double prob, double threshold);
  13204. [DllImport(LIBNAME)]
  13205. private static extern int calib3d_Calib3d_recoverPose_12(IntPtr points1_nativeObj, IntPtr points2_nativeObj, IntPtr cameraMatrix1_nativeObj, IntPtr distCoeffs1_nativeObj, IntPtr cameraMatrix2_nativeObj, IntPtr distCoeffs2_nativeObj, IntPtr E_nativeObj, IntPtr R_nativeObj, IntPtr t_nativeObj, int method, double prob);
  13206. [DllImport(LIBNAME)]
  13207. private static extern int calib3d_Calib3d_recoverPose_13(IntPtr points1_nativeObj, IntPtr points2_nativeObj, IntPtr cameraMatrix1_nativeObj, IntPtr distCoeffs1_nativeObj, IntPtr cameraMatrix2_nativeObj, IntPtr distCoeffs2_nativeObj, IntPtr E_nativeObj, IntPtr R_nativeObj, IntPtr t_nativeObj, int method);
  13208. [DllImport(LIBNAME)]
  13209. private static extern int calib3d_Calib3d_recoverPose_14(IntPtr points1_nativeObj, IntPtr points2_nativeObj, IntPtr cameraMatrix1_nativeObj, IntPtr distCoeffs1_nativeObj, IntPtr cameraMatrix2_nativeObj, IntPtr distCoeffs2_nativeObj, IntPtr E_nativeObj, IntPtr R_nativeObj, IntPtr t_nativeObj);
  13210. // C++: int cv::recoverPose(Mat E, Mat points1, Mat points2, Mat cameraMatrix, Mat& R, Mat& t, Mat& mask = Mat())
  13211. [DllImport(LIBNAME)]
  13212. private static extern int calib3d_Calib3d_recoverPose_15(IntPtr E_nativeObj, IntPtr points1_nativeObj, IntPtr points2_nativeObj, IntPtr cameraMatrix_nativeObj, IntPtr R_nativeObj, IntPtr t_nativeObj, IntPtr mask_nativeObj);
  13213. [DllImport(LIBNAME)]
  13214. private static extern int calib3d_Calib3d_recoverPose_16(IntPtr E_nativeObj, IntPtr points1_nativeObj, IntPtr points2_nativeObj, IntPtr cameraMatrix_nativeObj, IntPtr R_nativeObj, IntPtr t_nativeObj);
  13215. // C++: int cv::recoverPose(Mat E, Mat points1, Mat points2, Mat& R, Mat& t, double focal = 1.0, Point2d pp = Point2d(0, 0), Mat& mask = Mat())
  13216. [DllImport(LIBNAME)]
  13217. private static extern int calib3d_Calib3d_recoverPose_17(IntPtr E_nativeObj, IntPtr points1_nativeObj, IntPtr points2_nativeObj, IntPtr R_nativeObj, IntPtr t_nativeObj, double focal, double pp_x, double pp_y, IntPtr mask_nativeObj);
  13218. [DllImport(LIBNAME)]
  13219. private static extern int calib3d_Calib3d_recoverPose_18(IntPtr E_nativeObj, IntPtr points1_nativeObj, IntPtr points2_nativeObj, IntPtr R_nativeObj, IntPtr t_nativeObj, double focal, double pp_x, double pp_y);
  13220. [DllImport(LIBNAME)]
  13221. private static extern int calib3d_Calib3d_recoverPose_19(IntPtr E_nativeObj, IntPtr points1_nativeObj, IntPtr points2_nativeObj, IntPtr R_nativeObj, IntPtr t_nativeObj, double focal);
  13222. [DllImport(LIBNAME)]
  13223. private static extern int calib3d_Calib3d_recoverPose_110(IntPtr E_nativeObj, IntPtr points1_nativeObj, IntPtr points2_nativeObj, IntPtr R_nativeObj, IntPtr t_nativeObj);
  13224. // C++: int cv::recoverPose(Mat E, Mat points1, Mat points2, Mat cameraMatrix, Mat& R, Mat& t, double distanceThresh, Mat& mask = Mat(), Mat& triangulatedPoints = Mat())
  13225. [DllImport(LIBNAME)]
  13226. private static extern int calib3d_Calib3d_recoverPose_111(IntPtr E_nativeObj, IntPtr points1_nativeObj, IntPtr points2_nativeObj, IntPtr cameraMatrix_nativeObj, IntPtr R_nativeObj, IntPtr t_nativeObj, double distanceThresh, IntPtr mask_nativeObj, IntPtr triangulatedPoints_nativeObj);
  13227. [DllImport(LIBNAME)]
  13228. private static extern int calib3d_Calib3d_recoverPose_112(IntPtr E_nativeObj, IntPtr points1_nativeObj, IntPtr points2_nativeObj, IntPtr cameraMatrix_nativeObj, IntPtr R_nativeObj, IntPtr t_nativeObj, double distanceThresh, IntPtr mask_nativeObj);
  13229. [DllImport(LIBNAME)]
  13230. private static extern int calib3d_Calib3d_recoverPose_113(IntPtr E_nativeObj, IntPtr points1_nativeObj, IntPtr points2_nativeObj, IntPtr cameraMatrix_nativeObj, IntPtr R_nativeObj, IntPtr t_nativeObj, double distanceThresh);
  13231. // C++: void cv::computeCorrespondEpilines(Mat points, int whichImage, Mat F, Mat& lines)
  13232. [DllImport(LIBNAME)]
  13233. private static extern void calib3d_Calib3d_computeCorrespondEpilines_10(IntPtr points_nativeObj, int whichImage, IntPtr F_nativeObj, IntPtr lines_nativeObj);
  13234. // C++: void cv::triangulatePoints(Mat projMatr1, Mat projMatr2, Mat projPoints1, Mat projPoints2, Mat& points4D)
  13235. [DllImport(LIBNAME)]
  13236. private static extern void calib3d_Calib3d_triangulatePoints_10(IntPtr projMatr1_nativeObj, IntPtr projMatr2_nativeObj, IntPtr projPoints1_nativeObj, IntPtr projPoints2_nativeObj, IntPtr points4D_nativeObj);
  13237. // C++: void cv::correctMatches(Mat F, Mat points1, Mat points2, Mat& newPoints1, Mat& newPoints2)
  13238. [DllImport(LIBNAME)]
  13239. private static extern void calib3d_Calib3d_correctMatches_10(IntPtr F_nativeObj, IntPtr points1_nativeObj, IntPtr points2_nativeObj, IntPtr newPoints1_nativeObj, IntPtr newPoints2_nativeObj);
  13240. // C++: void cv::filterSpeckles(Mat& img, double newVal, int maxSpeckleSize, double maxDiff, Mat& buf = Mat())
  13241. [DllImport(LIBNAME)]
  13242. private static extern void calib3d_Calib3d_filterSpeckles_10(IntPtr img_nativeObj, double newVal, int maxSpeckleSize, double maxDiff, IntPtr buf_nativeObj);
  13243. [DllImport(LIBNAME)]
  13244. private static extern void calib3d_Calib3d_filterSpeckles_11(IntPtr img_nativeObj, double newVal, int maxSpeckleSize, double maxDiff);
  13245. // C++: Rect cv::getValidDisparityROI(Rect roi1, Rect roi2, int minDisparity, int numberOfDisparities, int blockSize)
  13246. [DllImport(LIBNAME)]
  13247. private static extern void calib3d_Calib3d_getValidDisparityROI_10(int roi1_x, int roi1_y, int roi1_width, int roi1_height, int roi2_x, int roi2_y, int roi2_width, int roi2_height, int minDisparity, int numberOfDisparities, int blockSize, double[] retVal);
  13248. // C++: void cv::validateDisparity(Mat& disparity, Mat cost, int minDisparity, int numberOfDisparities, int disp12MaxDisp = 1)
  13249. [DllImport(LIBNAME)]
  13250. private static extern void calib3d_Calib3d_validateDisparity_10(IntPtr disparity_nativeObj, IntPtr cost_nativeObj, int minDisparity, int numberOfDisparities, int disp12MaxDisp);
  13251. [DllImport(LIBNAME)]
  13252. private static extern void calib3d_Calib3d_validateDisparity_11(IntPtr disparity_nativeObj, IntPtr cost_nativeObj, int minDisparity, int numberOfDisparities);
  13253. // C++: void cv::reprojectImageTo3D(Mat disparity, Mat& _3dImage, Mat Q, bool handleMissingValues = false, int ddepth = -1)
  13254. [DllImport(LIBNAME)]
  13255. private static extern void calib3d_Calib3d_reprojectImageTo3D_10(IntPtr disparity_nativeObj, IntPtr _3dImage_nativeObj, IntPtr Q_nativeObj, [MarshalAs(UnmanagedType.U1)] bool handleMissingValues, int ddepth);
  13256. [DllImport(LIBNAME)]
  13257. private static extern void calib3d_Calib3d_reprojectImageTo3D_11(IntPtr disparity_nativeObj, IntPtr _3dImage_nativeObj, IntPtr Q_nativeObj, [MarshalAs(UnmanagedType.U1)] bool handleMissingValues);
  13258. [DllImport(LIBNAME)]
  13259. private static extern void calib3d_Calib3d_reprojectImageTo3D_12(IntPtr disparity_nativeObj, IntPtr _3dImage_nativeObj, IntPtr Q_nativeObj);
  13260. // C++: double cv::sampsonDistance(Mat pt1, Mat pt2, Mat F)
  13261. [DllImport(LIBNAME)]
  13262. private static extern double calib3d_Calib3d_sampsonDistance_10(IntPtr pt1_nativeObj, IntPtr pt2_nativeObj, IntPtr F_nativeObj);
  13263. // C++: int cv::estimateAffine3D(Mat src, Mat dst, Mat& _out, Mat& inliers, double ransacThreshold = 3, double confidence = 0.99)
  13264. [DllImport(LIBNAME)]
  13265. private static extern int calib3d_Calib3d_estimateAffine3D_10(IntPtr src_nativeObj, IntPtr dst_nativeObj, IntPtr _out_nativeObj, IntPtr inliers_nativeObj, double ransacThreshold, double confidence);
  13266. [DllImport(LIBNAME)]
  13267. private static extern int calib3d_Calib3d_estimateAffine3D_11(IntPtr src_nativeObj, IntPtr dst_nativeObj, IntPtr _out_nativeObj, IntPtr inliers_nativeObj, double ransacThreshold);
  13268. [DllImport(LIBNAME)]
  13269. private static extern int calib3d_Calib3d_estimateAffine3D_12(IntPtr src_nativeObj, IntPtr dst_nativeObj, IntPtr _out_nativeObj, IntPtr inliers_nativeObj);
  13270. // C++: Mat cv::estimateAffine3D(Mat src, Mat dst, double* scale = nullptr, bool force_rotation = true)
  13271. [DllImport(LIBNAME)]
  13272. private static extern IntPtr calib3d_Calib3d_estimateAffine3D_13(IntPtr src_nativeObj, IntPtr dst_nativeObj, double[] scale_out, [MarshalAs(UnmanagedType.U1)] bool force_rotation);
  13273. [DllImport(LIBNAME)]
  13274. private static extern IntPtr calib3d_Calib3d_estimateAffine3D_14(IntPtr src_nativeObj, IntPtr dst_nativeObj, double[] scale_out);
  13275. [DllImport(LIBNAME)]
  13276. private static extern IntPtr calib3d_Calib3d_estimateAffine3D_15(IntPtr src_nativeObj, IntPtr dst_nativeObj);
  13277. // C++: int cv::estimateTranslation3D(Mat src, Mat dst, Mat& _out, Mat& inliers, double ransacThreshold = 3, double confidence = 0.99)
  13278. [DllImport(LIBNAME)]
  13279. private static extern int calib3d_Calib3d_estimateTranslation3D_10(IntPtr src_nativeObj, IntPtr dst_nativeObj, IntPtr _out_nativeObj, IntPtr inliers_nativeObj, double ransacThreshold, double confidence);
  13280. [DllImport(LIBNAME)]
  13281. private static extern int calib3d_Calib3d_estimateTranslation3D_11(IntPtr src_nativeObj, IntPtr dst_nativeObj, IntPtr _out_nativeObj, IntPtr inliers_nativeObj, double ransacThreshold);
  13282. [DllImport(LIBNAME)]
  13283. private static extern int calib3d_Calib3d_estimateTranslation3D_12(IntPtr src_nativeObj, IntPtr dst_nativeObj, IntPtr _out_nativeObj, IntPtr inliers_nativeObj);
  13284. // C++: Mat cv::estimateAffine2D(Mat from, Mat to, Mat& inliers = Mat(), int method = RANSAC, double ransacReprojThreshold = 3, size_t maxIters = 2000, double confidence = 0.99, size_t refineIters = 10)
  13285. [DllImport(LIBNAME)]
  13286. private static extern IntPtr calib3d_Calib3d_estimateAffine2D_10(IntPtr from_nativeObj, IntPtr to_nativeObj, IntPtr inliers_nativeObj, int method, double ransacReprojThreshold, long maxIters, double confidence, long refineIters);
  13287. [DllImport(LIBNAME)]
  13288. private static extern IntPtr calib3d_Calib3d_estimateAffine2D_11(IntPtr from_nativeObj, IntPtr to_nativeObj, IntPtr inliers_nativeObj, int method, double ransacReprojThreshold, long maxIters, double confidence);
  13289. [DllImport(LIBNAME)]
  13290. private static extern IntPtr calib3d_Calib3d_estimateAffine2D_12(IntPtr from_nativeObj, IntPtr to_nativeObj, IntPtr inliers_nativeObj, int method, double ransacReprojThreshold, long maxIters);
  13291. [DllImport(LIBNAME)]
  13292. private static extern IntPtr calib3d_Calib3d_estimateAffine2D_13(IntPtr from_nativeObj, IntPtr to_nativeObj, IntPtr inliers_nativeObj, int method, double ransacReprojThreshold);
  13293. [DllImport(LIBNAME)]
  13294. private static extern IntPtr calib3d_Calib3d_estimateAffine2D_14(IntPtr from_nativeObj, IntPtr to_nativeObj, IntPtr inliers_nativeObj, int method);
  13295. [DllImport(LIBNAME)]
  13296. private static extern IntPtr calib3d_Calib3d_estimateAffine2D_15(IntPtr from_nativeObj, IntPtr to_nativeObj, IntPtr inliers_nativeObj);
  13297. [DllImport(LIBNAME)]
  13298. private static extern IntPtr calib3d_Calib3d_estimateAffine2D_16(IntPtr from_nativeObj, IntPtr to_nativeObj);
  13299. // C++: Mat cv::estimateAffine2D(Mat pts1, Mat pts2, Mat& inliers, UsacParams _params)
  13300. [DllImport(LIBNAME)]
  13301. private static extern IntPtr calib3d_Calib3d_estimateAffine2D_17(IntPtr pts1_nativeObj, IntPtr pts2_nativeObj, IntPtr inliers_nativeObj, IntPtr _params_nativeObj);
  13302. // C++: Mat cv::estimateAffinePartial2D(Mat from, Mat to, Mat& inliers = Mat(), int method = RANSAC, double ransacReprojThreshold = 3, size_t maxIters = 2000, double confidence = 0.99, size_t refineIters = 10)
  13303. [DllImport(LIBNAME)]
  13304. private static extern IntPtr calib3d_Calib3d_estimateAffinePartial2D_10(IntPtr from_nativeObj, IntPtr to_nativeObj, IntPtr inliers_nativeObj, int method, double ransacReprojThreshold, long maxIters, double confidence, long refineIters);
  13305. [DllImport(LIBNAME)]
  13306. private static extern IntPtr calib3d_Calib3d_estimateAffinePartial2D_11(IntPtr from_nativeObj, IntPtr to_nativeObj, IntPtr inliers_nativeObj, int method, double ransacReprojThreshold, long maxIters, double confidence);
  13307. [DllImport(LIBNAME)]
  13308. private static extern IntPtr calib3d_Calib3d_estimateAffinePartial2D_12(IntPtr from_nativeObj, IntPtr to_nativeObj, IntPtr inliers_nativeObj, int method, double ransacReprojThreshold, long maxIters);
  13309. [DllImport(LIBNAME)]
  13310. private static extern IntPtr calib3d_Calib3d_estimateAffinePartial2D_13(IntPtr from_nativeObj, IntPtr to_nativeObj, IntPtr inliers_nativeObj, int method, double ransacReprojThreshold);
  13311. [DllImport(LIBNAME)]
  13312. private static extern IntPtr calib3d_Calib3d_estimateAffinePartial2D_14(IntPtr from_nativeObj, IntPtr to_nativeObj, IntPtr inliers_nativeObj, int method);
  13313. [DllImport(LIBNAME)]
  13314. private static extern IntPtr calib3d_Calib3d_estimateAffinePartial2D_15(IntPtr from_nativeObj, IntPtr to_nativeObj, IntPtr inliers_nativeObj);
  13315. [DllImport(LIBNAME)]
  13316. private static extern IntPtr calib3d_Calib3d_estimateAffinePartial2D_16(IntPtr from_nativeObj, IntPtr to_nativeObj);
  13317. // C++: int cv::decomposeHomographyMat(Mat H, Mat K, vector_Mat& rotations, vector_Mat& translations, vector_Mat& normals)
  13318. [DllImport(LIBNAME)]
  13319. private static extern int calib3d_Calib3d_decomposeHomographyMat_10(IntPtr H_nativeObj, IntPtr K_nativeObj, IntPtr rotations_mat_nativeObj, IntPtr translations_mat_nativeObj, IntPtr normals_mat_nativeObj);
  13320. // C++: void cv::filterHomographyDecompByVisibleRefpoints(vector_Mat rotations, vector_Mat normals, Mat beforePoints, Mat afterPoints, Mat& possibleSolutions, Mat pointsMask = Mat())
  13321. [DllImport(LIBNAME)]
  13322. private static extern void calib3d_Calib3d_filterHomographyDecompByVisibleRefpoints_10(IntPtr rotations_mat_nativeObj, IntPtr normals_mat_nativeObj, IntPtr beforePoints_nativeObj, IntPtr afterPoints_nativeObj, IntPtr possibleSolutions_nativeObj, IntPtr pointsMask_nativeObj);
  13323. [DllImport(LIBNAME)]
  13324. private static extern void calib3d_Calib3d_filterHomographyDecompByVisibleRefpoints_11(IntPtr rotations_mat_nativeObj, IntPtr normals_mat_nativeObj, IntPtr beforePoints_nativeObj, IntPtr afterPoints_nativeObj, IntPtr possibleSolutions_nativeObj);
  13325. // C++: void cv::undistort(Mat src, Mat& dst, Mat cameraMatrix, Mat distCoeffs, Mat newCameraMatrix = Mat())
  13326. [DllImport(LIBNAME)]
  13327. private static extern void calib3d_Calib3d_undistort_10(IntPtr src_nativeObj, IntPtr dst_nativeObj, IntPtr cameraMatrix_nativeObj, IntPtr distCoeffs_nativeObj, IntPtr newCameraMatrix_nativeObj);
  13328. [DllImport(LIBNAME)]
  13329. private static extern void calib3d_Calib3d_undistort_11(IntPtr src_nativeObj, IntPtr dst_nativeObj, IntPtr cameraMatrix_nativeObj, IntPtr distCoeffs_nativeObj);
  13330. // C++: void cv::initUndistortRectifyMap(Mat cameraMatrix, Mat distCoeffs, Mat R, Mat newCameraMatrix, Size size, int m1type, Mat& map1, Mat& map2)
  13331. [DllImport(LIBNAME)]
  13332. private static extern void calib3d_Calib3d_initUndistortRectifyMap_10(IntPtr cameraMatrix_nativeObj, IntPtr distCoeffs_nativeObj, IntPtr R_nativeObj, IntPtr newCameraMatrix_nativeObj, double size_width, double size_height, int m1type, IntPtr map1_nativeObj, IntPtr map2_nativeObj);
  13333. // C++: void cv::initInverseRectificationMap(Mat cameraMatrix, Mat distCoeffs, Mat R, Mat newCameraMatrix, Size size, int m1type, Mat& map1, Mat& map2)
  13334. [DllImport(LIBNAME)]
  13335. private static extern void calib3d_Calib3d_initInverseRectificationMap_10(IntPtr cameraMatrix_nativeObj, IntPtr distCoeffs_nativeObj, IntPtr R_nativeObj, IntPtr newCameraMatrix_nativeObj, double size_width, double size_height, int m1type, IntPtr map1_nativeObj, IntPtr map2_nativeObj);
  13336. // C++: Mat cv::getDefaultNewCameraMatrix(Mat cameraMatrix, Size imgsize = Size(), bool centerPrincipalPoint = false)
  13337. [DllImport(LIBNAME)]
  13338. private static extern IntPtr calib3d_Calib3d_getDefaultNewCameraMatrix_10(IntPtr cameraMatrix_nativeObj, double imgsize_width, double imgsize_height, [MarshalAs(UnmanagedType.U1)] bool centerPrincipalPoint);
  13339. [DllImport(LIBNAME)]
  13340. private static extern IntPtr calib3d_Calib3d_getDefaultNewCameraMatrix_11(IntPtr cameraMatrix_nativeObj, double imgsize_width, double imgsize_height);
  13341. [DllImport(LIBNAME)]
  13342. private static extern IntPtr calib3d_Calib3d_getDefaultNewCameraMatrix_12(IntPtr cameraMatrix_nativeObj);
  13343. // C++: void cv::undistortPoints(vector_Point2f src, vector_Point2f& dst, Mat cameraMatrix, Mat distCoeffs, Mat R = Mat(), Mat P = Mat())
  13344. [DllImport(LIBNAME)]
  13345. private static extern void calib3d_Calib3d_undistortPoints_10(IntPtr src_mat_nativeObj, IntPtr dst_mat_nativeObj, IntPtr cameraMatrix_nativeObj, IntPtr distCoeffs_nativeObj, IntPtr R_nativeObj, IntPtr P_nativeObj);
  13346. [DllImport(LIBNAME)]
  13347. private static extern void calib3d_Calib3d_undistortPoints_11(IntPtr src_mat_nativeObj, IntPtr dst_mat_nativeObj, IntPtr cameraMatrix_nativeObj, IntPtr distCoeffs_nativeObj, IntPtr R_nativeObj);
  13348. [DllImport(LIBNAME)]
  13349. private static extern void calib3d_Calib3d_undistortPoints_12(IntPtr src_mat_nativeObj, IntPtr dst_mat_nativeObj, IntPtr cameraMatrix_nativeObj, IntPtr distCoeffs_nativeObj);
  13350. // C++: void cv::undistortPoints(Mat src, Mat& dst, Mat cameraMatrix, Mat distCoeffs, Mat R, Mat P, TermCriteria criteria)
  13351. [DllImport(LIBNAME)]
  13352. private static extern void calib3d_Calib3d_undistortPointsIter_10(IntPtr src_nativeObj, IntPtr dst_nativeObj, IntPtr cameraMatrix_nativeObj, IntPtr distCoeffs_nativeObj, IntPtr R_nativeObj, IntPtr P_nativeObj, int criteria_type, int criteria_maxCount, double criteria_epsilon);
  13353. // C++: void cv::undistortImagePoints(Mat src, Mat& dst, Mat cameraMatrix, Mat distCoeffs, TermCriteria arg1 = TermCriteria(TermCriteria::MAX_ITER + TermCriteria::EPS, 5, 0.01))
  13354. [DllImport(LIBNAME)]
  13355. private static extern void calib3d_Calib3d_undistortImagePoints_10(IntPtr src_nativeObj, IntPtr dst_nativeObj, IntPtr cameraMatrix_nativeObj, IntPtr distCoeffs_nativeObj, int arg1_type, int arg1_maxCount, double arg1_epsilon);
  13356. [DllImport(LIBNAME)]
  13357. private static extern void calib3d_Calib3d_undistortImagePoints_11(IntPtr src_nativeObj, IntPtr dst_nativeObj, IntPtr cameraMatrix_nativeObj, IntPtr distCoeffs_nativeObj);
  13358. // C++: void cv::fisheye::projectPoints(Mat objectPoints, Mat& imagePoints, Mat rvec, Mat tvec, Mat K, Mat D, double alpha = 0, Mat& jacobian = Mat())
  13359. [DllImport(LIBNAME)]
  13360. private static extern void calib3d_Calib3d_fisheye_1projectPoints_10(IntPtr objectPoints_nativeObj, IntPtr imagePoints_nativeObj, IntPtr rvec_nativeObj, IntPtr tvec_nativeObj, IntPtr K_nativeObj, IntPtr D_nativeObj, double alpha, IntPtr jacobian_nativeObj);
  13361. [DllImport(LIBNAME)]
  13362. private static extern void calib3d_Calib3d_fisheye_1projectPoints_11(IntPtr objectPoints_nativeObj, IntPtr imagePoints_nativeObj, IntPtr rvec_nativeObj, IntPtr tvec_nativeObj, IntPtr K_nativeObj, IntPtr D_nativeObj, double alpha);
  13363. [DllImport(LIBNAME)]
  13364. private static extern void calib3d_Calib3d_fisheye_1projectPoints_12(IntPtr objectPoints_nativeObj, IntPtr imagePoints_nativeObj, IntPtr rvec_nativeObj, IntPtr tvec_nativeObj, IntPtr K_nativeObj, IntPtr D_nativeObj);
  13365. // C++: void cv::fisheye::distortPoints(Mat undistorted, Mat& distorted, Mat K, Mat D, double alpha = 0)
  13366. [DllImport(LIBNAME)]
  13367. private static extern void calib3d_Calib3d_fisheye_1distortPoints_10(IntPtr undistorted_nativeObj, IntPtr distorted_nativeObj, IntPtr K_nativeObj, IntPtr D_nativeObj, double alpha);
  13368. [DllImport(LIBNAME)]
  13369. private static extern void calib3d_Calib3d_fisheye_1distortPoints_11(IntPtr undistorted_nativeObj, IntPtr distorted_nativeObj, IntPtr K_nativeObj, IntPtr D_nativeObj);
  13370. // C++: void cv::fisheye::undistortPoints(Mat distorted, Mat& undistorted, Mat K, Mat D, Mat R = Mat(), Mat P = Mat(), TermCriteria criteria = TermCriteria(TermCriteria::MAX_ITER + TermCriteria::EPS, 10, 1e-8))
  13371. [DllImport(LIBNAME)]
  13372. private static extern void calib3d_Calib3d_fisheye_1undistortPoints_10(IntPtr distorted_nativeObj, IntPtr undistorted_nativeObj, IntPtr K_nativeObj, IntPtr D_nativeObj, IntPtr R_nativeObj, IntPtr P_nativeObj, int criteria_type, int criteria_maxCount, double criteria_epsilon);
  13373. [DllImport(LIBNAME)]
  13374. private static extern void calib3d_Calib3d_fisheye_1undistortPoints_11(IntPtr distorted_nativeObj, IntPtr undistorted_nativeObj, IntPtr K_nativeObj, IntPtr D_nativeObj, IntPtr R_nativeObj, IntPtr P_nativeObj);
  13375. [DllImport(LIBNAME)]
  13376. private static extern void calib3d_Calib3d_fisheye_1undistortPoints_12(IntPtr distorted_nativeObj, IntPtr undistorted_nativeObj, IntPtr K_nativeObj, IntPtr D_nativeObj, IntPtr R_nativeObj);
  13377. [DllImport(LIBNAME)]
  13378. private static extern void calib3d_Calib3d_fisheye_1undistortPoints_13(IntPtr distorted_nativeObj, IntPtr undistorted_nativeObj, IntPtr K_nativeObj, IntPtr D_nativeObj);
  13379. // C++: void cv::fisheye::initUndistortRectifyMap(Mat K, Mat D, Mat R, Mat P, Size size, int m1type, Mat& map1, Mat& map2)
  13380. [DllImport(LIBNAME)]
  13381. private static extern void calib3d_Calib3d_fisheye_1initUndistortRectifyMap_10(IntPtr K_nativeObj, IntPtr D_nativeObj, IntPtr R_nativeObj, IntPtr P_nativeObj, double size_width, double size_height, int m1type, IntPtr map1_nativeObj, IntPtr map2_nativeObj);
  13382. // C++: void cv::fisheye::undistortImage(Mat distorted, Mat& undistorted, Mat K, Mat D, Mat Knew = cv::Mat(), Size new_size = Size())
  13383. [DllImport(LIBNAME)]
  13384. private static extern void calib3d_Calib3d_fisheye_1undistortImage_10(IntPtr distorted_nativeObj, IntPtr undistorted_nativeObj, IntPtr K_nativeObj, IntPtr D_nativeObj, IntPtr Knew_nativeObj, double new_size_width, double new_size_height);
  13385. [DllImport(LIBNAME)]
  13386. private static extern void calib3d_Calib3d_fisheye_1undistortImage_11(IntPtr distorted_nativeObj, IntPtr undistorted_nativeObj, IntPtr K_nativeObj, IntPtr D_nativeObj, IntPtr Knew_nativeObj);
  13387. [DllImport(LIBNAME)]
  13388. private static extern void calib3d_Calib3d_fisheye_1undistortImage_12(IntPtr distorted_nativeObj, IntPtr undistorted_nativeObj, IntPtr K_nativeObj, IntPtr D_nativeObj);
  13389. // C++: void cv::fisheye::estimateNewCameraMatrixForUndistortRectify(Mat K, Mat D, Size image_size, Mat R, Mat& P, double balance = 0.0, Size new_size = Size(), double fov_scale = 1.0)
  13390. [DllImport(LIBNAME)]
  13391. private static extern void calib3d_Calib3d_fisheye_1estimateNewCameraMatrixForUndistortRectify_10(IntPtr K_nativeObj, IntPtr D_nativeObj, double image_size_width, double image_size_height, IntPtr R_nativeObj, IntPtr P_nativeObj, double balance, double new_size_width, double new_size_height, double fov_scale);
  13392. [DllImport(LIBNAME)]
  13393. private static extern void calib3d_Calib3d_fisheye_1estimateNewCameraMatrixForUndistortRectify_11(IntPtr K_nativeObj, IntPtr D_nativeObj, double image_size_width, double image_size_height, IntPtr R_nativeObj, IntPtr P_nativeObj, double balance, double new_size_width, double new_size_height);
  13394. [DllImport(LIBNAME)]
  13395. private static extern void calib3d_Calib3d_fisheye_1estimateNewCameraMatrixForUndistortRectify_12(IntPtr K_nativeObj, IntPtr D_nativeObj, double image_size_width, double image_size_height, IntPtr R_nativeObj, IntPtr P_nativeObj, double balance);
  13396. [DllImport(LIBNAME)]
  13397. private static extern void calib3d_Calib3d_fisheye_1estimateNewCameraMatrixForUndistortRectify_13(IntPtr K_nativeObj, IntPtr D_nativeObj, double image_size_width, double image_size_height, IntPtr R_nativeObj, IntPtr P_nativeObj);
  13398. // C++: double cv::fisheye::calibrate(vector_Mat objectPoints, vector_Mat imagePoints, Size image_size, Mat& K, Mat& D, vector_Mat& rvecs, vector_Mat& tvecs, int flags = 0, TermCriteria criteria = TermCriteria(TermCriteria::COUNT + TermCriteria::EPS, 100, DBL_EPSILON))
  13399. [DllImport(LIBNAME)]
  13400. private static extern double calib3d_Calib3d_fisheye_1calibrate_10(IntPtr objectPoints_mat_nativeObj, IntPtr imagePoints_mat_nativeObj, double image_size_width, double image_size_height, IntPtr K_nativeObj, IntPtr D_nativeObj, IntPtr rvecs_mat_nativeObj, IntPtr tvecs_mat_nativeObj, int flags, int criteria_type, int criteria_maxCount, double criteria_epsilon);
  13401. [DllImport(LIBNAME)]
  13402. private static extern double calib3d_Calib3d_fisheye_1calibrate_11(IntPtr objectPoints_mat_nativeObj, IntPtr imagePoints_mat_nativeObj, double image_size_width, double image_size_height, IntPtr K_nativeObj, IntPtr D_nativeObj, IntPtr rvecs_mat_nativeObj, IntPtr tvecs_mat_nativeObj, int flags);
  13403. [DllImport(LIBNAME)]
  13404. private static extern double calib3d_Calib3d_fisheye_1calibrate_12(IntPtr objectPoints_mat_nativeObj, IntPtr imagePoints_mat_nativeObj, double image_size_width, double image_size_height, IntPtr K_nativeObj, IntPtr D_nativeObj, IntPtr rvecs_mat_nativeObj, IntPtr tvecs_mat_nativeObj);
  13405. // C++: void cv::fisheye::stereoRectify(Mat K1, Mat D1, Mat K2, Mat D2, Size imageSize, Mat R, Mat tvec, Mat& R1, Mat& R2, Mat& P1, Mat& P2, Mat& Q, int flags, Size newImageSize = Size(), double balance = 0.0, double fov_scale = 1.0)
  13406. [DllImport(LIBNAME)]
  13407. private static extern void calib3d_Calib3d_fisheye_1stereoRectify_10(IntPtr K1_nativeObj, IntPtr D1_nativeObj, IntPtr K2_nativeObj, IntPtr D2_nativeObj, double imageSize_width, double imageSize_height, IntPtr R_nativeObj, IntPtr tvec_nativeObj, IntPtr R1_nativeObj, IntPtr R2_nativeObj, IntPtr P1_nativeObj, IntPtr P2_nativeObj, IntPtr Q_nativeObj, int flags, double newImageSize_width, double newImageSize_height, double balance, double fov_scale);
  13408. [DllImport(LIBNAME)]
  13409. private static extern void calib3d_Calib3d_fisheye_1stereoRectify_11(IntPtr K1_nativeObj, IntPtr D1_nativeObj, IntPtr K2_nativeObj, IntPtr D2_nativeObj, double imageSize_width, double imageSize_height, IntPtr R_nativeObj, IntPtr tvec_nativeObj, IntPtr R1_nativeObj, IntPtr R2_nativeObj, IntPtr P1_nativeObj, IntPtr P2_nativeObj, IntPtr Q_nativeObj, int flags, double newImageSize_width, double newImageSize_height, double balance);
  13410. [DllImport(LIBNAME)]
  13411. private static extern void calib3d_Calib3d_fisheye_1stereoRectify_12(IntPtr K1_nativeObj, IntPtr D1_nativeObj, IntPtr K2_nativeObj, IntPtr D2_nativeObj, double imageSize_width, double imageSize_height, IntPtr R_nativeObj, IntPtr tvec_nativeObj, IntPtr R1_nativeObj, IntPtr R2_nativeObj, IntPtr P1_nativeObj, IntPtr P2_nativeObj, IntPtr Q_nativeObj, int flags, double newImageSize_width, double newImageSize_height);
  13412. [DllImport(LIBNAME)]
  13413. private static extern void calib3d_Calib3d_fisheye_1stereoRectify_13(IntPtr K1_nativeObj, IntPtr D1_nativeObj, IntPtr K2_nativeObj, IntPtr D2_nativeObj, double imageSize_width, double imageSize_height, IntPtr R_nativeObj, IntPtr tvec_nativeObj, IntPtr R1_nativeObj, IntPtr R2_nativeObj, IntPtr P1_nativeObj, IntPtr P2_nativeObj, IntPtr Q_nativeObj, int flags);
  13414. // C++: double cv::fisheye::stereoCalibrate(vector_Mat objectPoints, vector_Mat imagePoints1, vector_Mat imagePoints2, Mat& K1, Mat& D1, Mat& K2, Mat& D2, Size imageSize, Mat& R, Mat& T, vector_Mat& rvecs, vector_Mat& tvecs, int flags = fisheye::CALIB_FIX_INTRINSIC, TermCriteria criteria = TermCriteria(TermCriteria::COUNT + TermCriteria::EPS, 100, DBL_EPSILON))
  13415. [DllImport(LIBNAME)]
  13416. private static extern double calib3d_Calib3d_fisheye_1stereoCalibrate_10(IntPtr objectPoints_mat_nativeObj, IntPtr imagePoints1_mat_nativeObj, IntPtr imagePoints2_mat_nativeObj, IntPtr K1_nativeObj, IntPtr D1_nativeObj, IntPtr K2_nativeObj, IntPtr D2_nativeObj, double imageSize_width, double imageSize_height, IntPtr R_nativeObj, IntPtr T_nativeObj, IntPtr rvecs_mat_nativeObj, IntPtr tvecs_mat_nativeObj, int flags, int criteria_type, int criteria_maxCount, double criteria_epsilon);
  13417. [DllImport(LIBNAME)]
  13418. private static extern double calib3d_Calib3d_fisheye_1stereoCalibrate_11(IntPtr objectPoints_mat_nativeObj, IntPtr imagePoints1_mat_nativeObj, IntPtr imagePoints2_mat_nativeObj, IntPtr K1_nativeObj, IntPtr D1_nativeObj, IntPtr K2_nativeObj, IntPtr D2_nativeObj, double imageSize_width, double imageSize_height, IntPtr R_nativeObj, IntPtr T_nativeObj, IntPtr rvecs_mat_nativeObj, IntPtr tvecs_mat_nativeObj, int flags);
  13419. [DllImport(LIBNAME)]
  13420. private static extern double calib3d_Calib3d_fisheye_1stereoCalibrate_12(IntPtr objectPoints_mat_nativeObj, IntPtr imagePoints1_mat_nativeObj, IntPtr imagePoints2_mat_nativeObj, IntPtr K1_nativeObj, IntPtr D1_nativeObj, IntPtr K2_nativeObj, IntPtr D2_nativeObj, double imageSize_width, double imageSize_height, IntPtr R_nativeObj, IntPtr T_nativeObj, IntPtr rvecs_mat_nativeObj, IntPtr tvecs_mat_nativeObj);
  13421. // C++: double cv::fisheye::stereoCalibrate(vector_Mat objectPoints, vector_Mat imagePoints1, vector_Mat imagePoints2, Mat& K1, Mat& D1, Mat& K2, Mat& D2, Size imageSize, Mat& R, Mat& T, int flags = fisheye::CALIB_FIX_INTRINSIC, TermCriteria criteria = TermCriteria(TermCriteria::COUNT + TermCriteria::EPS, 100, DBL_EPSILON))
  13422. [DllImport(LIBNAME)]
  13423. private static extern double calib3d_Calib3d_fisheye_1stereoCalibrate_13(IntPtr objectPoints_mat_nativeObj, IntPtr imagePoints1_mat_nativeObj, IntPtr imagePoints2_mat_nativeObj, IntPtr K1_nativeObj, IntPtr D1_nativeObj, IntPtr K2_nativeObj, IntPtr D2_nativeObj, double imageSize_width, double imageSize_height, IntPtr R_nativeObj, IntPtr T_nativeObj, int flags, int criteria_type, int criteria_maxCount, double criteria_epsilon);
  13424. [DllImport(LIBNAME)]
  13425. private static extern double calib3d_Calib3d_fisheye_1stereoCalibrate_14(IntPtr objectPoints_mat_nativeObj, IntPtr imagePoints1_mat_nativeObj, IntPtr imagePoints2_mat_nativeObj, IntPtr K1_nativeObj, IntPtr D1_nativeObj, IntPtr K2_nativeObj, IntPtr D2_nativeObj, double imageSize_width, double imageSize_height, IntPtr R_nativeObj, IntPtr T_nativeObj, int flags);
  13426. [DllImport(LIBNAME)]
  13427. private static extern double calib3d_Calib3d_fisheye_1stereoCalibrate_15(IntPtr objectPoints_mat_nativeObj, IntPtr imagePoints1_mat_nativeObj, IntPtr imagePoints2_mat_nativeObj, IntPtr K1_nativeObj, IntPtr D1_nativeObj, IntPtr K2_nativeObj, IntPtr D2_nativeObj, double imageSize_width, double imageSize_height, IntPtr R_nativeObj, IntPtr T_nativeObj);
  13428. }
  13429. }