{"id":15043487,"url":"https://github.com/meiqua/shape_based_matching","last_synced_at":"2025-05-15T22:06:55.830Z","repository":{"id":37375959,"uuid":"140246937","full_name":"meiqua/shape_based_matching","owner":"meiqua","description":"try to implement halcon shape based matching, refer to machine vision algorithms and applications, page 317 3.11.5, written by halcon engineers","archived":false,"fork":false,"pushed_at":"2024-07-16T04:27:57.000Z","size":36760,"stargazers_count":1296,"open_issues_count":148,"forks_count":492,"subscribers_count":58,"default_branch":"master","last_synced_at":"2025-04-08T09:05:46.954Z","etag":null,"topics":["based","halcon","linemod","matching","opencv","shape","shape-based"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/meiqua.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-07-09T07:23:53.000Z","updated_at":"2025-04-07T14:15:30.000Z","dependencies_parsed_at":"2024-07-16T07:12:52.482Z","dependency_job_id":null,"html_url":"https://github.com/meiqua/shape_based_matching","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meiqua%2Fshape_based_matching","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meiqua%2Fshape_based_matching/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meiqua%2Fshape_based_matching/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meiqua%2Fshape_based_matching/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/meiqua","download_url":"https://codeload.github.com/meiqua/shape_based_matching/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254430330,"owners_count":22069909,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["based","halcon","linemod","matching","opencv","shape","shape-based"],"created_at":"2024-09-24T20:49:08.439Z","updated_at":"2025-05-15T22:06:55.777Z","avatar_url":"https://github.com/meiqua.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# shape_based_matching  \n\nupdate:   \n**[fusion implementation to run faster!](https://github.com/meiqua/shape_based_matching/issues/77)**  \n**[icp is also refined to be faster and easier to use](https://github.com/meiqua/shape_based_matching/issues/100)**  \n\n[Transforms in shape-based matching](./Transforms%20in%20shape-based%20matching.pdf)  \n[pose refine with icp branch](https://github.com/meiqua/shape_based_matching/tree/icp2D), 0.1-0.5 degree accuracy   \n[icp + subpixel branch](https://github.com/meiqua/shape_based_matching/tree/subpixel), \u003c 0.1 degree accuracy  \n[icp + subpixel + sim3(previous is so3) branch](https://github.com/meiqua/shape_based_matching/tree/sim3), deal with scale error  \n\ntry to implement halcon shape based matching, refer to machine vision algorithms and applications, page 317 3.11.5, written by halcon engineers  \nWe find that shape based matching is the same as linemod. [linemod pdf](Gradient%20Response%20Maps%20for%20Real-TimeDetection%20of%20Textureless%20Objects.pdf)  \n\nhalcon match solution guide for how to select matching methods([halcon documentation](https://www.mvtec.com/products/halcon/documentation/#reference_manual)):  \n![match](./match.png)  \n\n## steps\n\n1. change test.cpp line 9 prefix to top level folder\n\n2. in cmakeList line 23, change /opt/ros/kinetic to somewhere opencv3 can be found(if opencv3 is installed in default env then don't need to)\n\n3. cmake make \u0026 run. To learn usage, see different tests in test.cpp. Particularly, scale_test are fully commented.\n\nNOTE: On windows, it's confirmed that visual studio 17 works fine, but there are some problems with MIPP in vs13. You may want old codes without [MIPP](https://github.com/aff3ct/MIPP): [old commit](https://github.com/meiqua/shape_based_matching/tree/fc3560a1a3bc7c6371eacecdb6822244baac17ba)  \n\n## thoughts about the method\n\nThe key of shape based matching, or linemod, is using gradient orientation only. Though both edge and orientation are resistant to disturbance,\nedge have only 1bit info(there is an edge or not), so it's hard to dig wanted shapes out if there are too many edges, but we have to have as many edges as possible if we want to find all the target shapes. It's quite a dilemma.  \n\nHowever, gradient orientation has much more info than edge, so we can easily match shape orientation in the overwhelming img orientation by template matching across the img.  \n\nSpeed is also important. Thanks to the speeding up magic in linemod, we can handle 1000 templates in 20ms or so.  \n\n[Chinese blog about the thoughts](https://www.zhihu.com/question/39513724/answer/441677905)  \n\n## improvment\n\nComparing to opencv linemod src, we improve from 6 aspects:  \n\n1. delete depth modality so we don't need virtual func, this may speed up  \n\n2. opencv linemod can't use more than 63 features. Now wo can have up to 8191  \n\n3. simple codes for rotating and scaling img for training. see test.cpp for examples  \n\n4. nms for accurate edge selection  \n\n5. one channel orientation extraction to save time, slightly faster for gray img\n\n6. use [MIPP](https://github.com/aff3ct/MIPP) for multiple platforms SIMD, for example, x86 SSE AVX, arm neon.\n   To have better performance, we have extended MIPP to uint8_t for some instructions.(Otherwise we can only use\n   half feature points to avoid int8_t overflow)  \n\n7. rotate features directly to speed up template extractions; selectScatteredFeatures more \nevenly; exautive select all features if not enough rather than abort templates(but features \u003c= 4 will abort)\n\n## some test\n\n### Example for circle shape  \n\n#### You can imagine how many circles we will find if use edges  \n![circle1](test/case0/1.jpg)\n![circle1](test/case0/result/1.png)  \n\n#### Not that circular  \n![circle2](test/case0/2.jpg)\n![circle2](test/case0/result/2.png)  \n\n#### Blur  \n![circle3](test/case0/3.png)\n![circle3](test/case0/result/3.png)  \n\n### circle template before and after nms  \n\n#### before nms\n\n![before](test/case0/features/no_nms_templ.png)\n\n#### after nms\n\n![after](test/case0/features/nms_templ.png)  \n\n### Simple example for arbitary shape\n\nWell, the example is too simple to show the robustness  \nrunning time: 1024x1024, 60ms to construct response map, 7ms for 360 templates  \n\ntest img \u0026 templ features  \n![test](./test/case1/result.png)  \n![templ](test/case1/templ.png)  \n\n\n### noise test  \n\n![test2](test/case2/result/together.png)  \n\n## some issues you may want to know  \nWell, issues are not clearly classified and many questions are discussed in one issue sometimes. For better reference, some typical discussions are pasted here.  \n\n[object too small?](https://github.com/meiqua/shape_based_matching/issues/13#issuecomment-474780205)  \n[failure case?](https://github.com/meiqua/shape_based_matching/issues/19#issuecomment-481153907)  \n[how to run even faster?](https://github.com/meiqua/shape_based_matching/issues/21#issuecomment-489664586)  \n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeiqua%2Fshape_based_matching","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmeiqua%2Fshape_based_matching","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeiqua%2Fshape_based_matching/lists"}