├── LICENSE ├── README.md ├── image ├── 0.jpg └── 0.png ├── mask_to_poly.py ├── misc ├── __pycache__ │ ├── __init__.cpython-36.pyc │ ├── __init__.cpython-37.pyc │ ├── __init__.cpython-38.pyc │ ├── colors.cpython-36.pyc │ ├── colors.cpython-37.pyc │ ├── colors.cpython-38.pyc │ ├── figures.cpython-36.pyc │ ├── figures.cpython-37.pyc │ ├── figures.cpython-38.pyc │ └── panorama.cpython-36.pyc ├── colors.py ├── figures.py ├── panorama.py ├── test.py └── utils.py ├── raster_to_json.py ├── read_dd.py ├── run.py └── sample_output └── 0.json /LICENSE: -------------------------------------------------------------------------------- 1 | ******************************************************************** 2 | ********* THIS CODE CAN ONLY BE USED FOR RESEARCH PURPOSES ********* 3 | ******************************************************************** 4 | 5 | GNU GENERAL PUBLIC LICENSE 6 | Version 3, 29 June 2007 7 | 8 | Copyright (C) 2007 Free Software Foundation, Inc. 9 | Everyone is permitted to copy and distribute verbatim copies 10 | of this license document, but changing it is not allowed. 11 | 12 | Preamble 13 | 14 | The GNU General Public License is a free, copyleft license for 15 | software and other kinds of works. 16 | 17 | The licenses for most software and other practical works are designed 18 | to take away your freedom to share and change the works. By contrast, 19 | the GNU General Public License is intended to guarantee your freedom to 20 | share and change all versions of a program--to make sure it remains free 21 | software for all its users. We, the Free Software Foundation, use the 22 | GNU General Public License for most of our software; it applies also to 23 | any other work released this way by its authors. You can apply it to 24 | your programs, too. 25 | 26 | When we speak of free software, we are referring to freedom, not 27 | price. Our General Public Licenses are designed to make sure that you 28 | have the freedom to distribute copies of free software (and charge for 29 | them if you wish), that you receive source code or can get it if you 30 | want it, that you can change the software or use pieces of it in new 31 | free programs, and that you know you can do these things. 32 | 33 | To protect your rights, we need to prevent others from denying you 34 | these rights or asking you to surrender the rights. Therefore, you have 35 | certain responsibilities if you distribute copies of the software, or if 36 | you modify it: responsibilities to respect the freedom of others. 37 | 38 | For example, if you distribute copies of such a program, whether 39 | gratis or for a fee, you must pass on to the recipients the same 40 | freedoms that you received. You must make sure that they, too, receive 41 | or can get the source code. And you must show them these terms so they 42 | know their rights. 43 | 44 | Developers that use the GNU GPL protect your rights with two steps: 45 | (1) assert copyright on the software, and (2) offer you this License 46 | giving you legal permission to copy, distribute and/or modify it. 47 | 48 | For the developers' and authors' protection, the GPL clearly explains 49 | that there is no warranty for this free software. For both users' and 50 | authors' sake, the GPL requires that modified versions be marked as 51 | changed, so that their problems will not be attributed erroneously to 52 | authors of previous versions. 53 | 54 | Some devices are designed to deny users access to install or run 55 | modified versions of the software inside them, although the manufacturer 56 | can do so. This is fundamentally incompatible with the aim of 57 | protecting users' freedom to change the software. The systematic 58 | pattern of such abuse occurs in the area of products for individuals to 59 | use, which is precisely where it is most unacceptable. Therefore, we 60 | have designed this version of the GPL to prohibit the practice for those 61 | products. If such problems arise substantially in other domains, we 62 | stand ready to extend this provision to those domains in future versions 63 | of the GPL, as needed to protect the freedom of users. 64 | 65 | Finally, every program is threatened constantly by software patents. 66 | States should not allow patents to restrict development and use of 67 | software on general-purpose computers, but in those that do, we wish to 68 | avoid the special danger that patents applied to a free program could 69 | make it effectively proprietary. To prevent this, the GPL assures that 70 | patents cannot be used to render the program non-free. 71 | 72 | The precise terms and conditions for copying, distribution and 73 | modification follow. 74 | 75 | TERMS AND CONDITIONS 76 | 77 | 0. Definitions. 78 | 79 | "This License" refers to version 3 of the GNU General Public License. 80 | 81 | "Copyright" also means copyright-like laws that apply to other kinds of 82 | works, such as semiconductor masks. 83 | 84 | "The Program" refers to any copyrightable work licensed under this 85 | License. Each licensee is addressed as "you". "Licensees" and 86 | "recipients" may be individuals or organizations. 87 | 88 | To "modify" a work means to copy from or adapt all or part of the work 89 | in a fashion requiring copyright permission, other than the making of an 90 | exact copy. The resulting work is called a "modified version" of the 91 | earlier work or a work "based on" the earlier work. 92 | 93 | A "covered work" means either the unmodified Program or a work based 94 | on the Program. 95 | 96 | To "propagate" a work means to do anything with it that, without 97 | permission, would make you directly or secondarily liable for 98 | infringement under applicable copyright law, except executing it on a 99 | computer or modifying a private copy. Propagation includes copying, 100 | distribution (with or without modification), making available to the 101 | public, and in some countries other activities as well. 102 | 103 | To "convey" a work means any kind of propagation that enables other 104 | parties to make or receive copies. Mere interaction with a user through 105 | a computer network, with no transfer of a copy, is not conveying. 106 | 107 | An interactive user interface displays "Appropriate Legal Notices" 108 | to the extent that it includes a convenient and prominently visible 109 | feature that (1) displays an appropriate copyright notice, and (2) 110 | tells the user that there is no warranty for the work (except to the 111 | extent that warranties are provided), that licensees may convey the 112 | work under this License, and how to view a copy of this License. If 113 | the interface presents a list of user commands or options, such as a 114 | menu, a prominent item in the list meets this criterion. 115 | 116 | 1. Source Code. 117 | 118 | The "source code" for a work means the preferred form of the work 119 | for making modifications to it. "Object code" means any non-source 120 | form of a work. 121 | 122 | A "Standard Interface" means an interface that either is an official 123 | standard defined by a recognized standards body, or, in the case of 124 | interfaces specified for a particular programming language, one that 125 | is widely used among developers working in that language. 126 | 127 | The "System Libraries" of an executable work include anything, other 128 | than the work as a whole, that (a) is included in the normal form of 129 | packaging a Major Component, but which is not part of that Major 130 | Component, and (b) serves only to enable use of the work with that 131 | Major Component, or to implement a Standard Interface for which an 132 | implementation is available to the public in source code form. A 133 | "Major Component", in this context, means a major essential component 134 | (kernel, window system, and so on) of the specific operating system 135 | (if any) on which the executable work runs, or a compiler used to 136 | produce the work, or an object code interpreter used to run it. 137 | 138 | The "Corresponding Source" for a work in object code form means all 139 | the source code needed to generate, install, and (for an executable 140 | work) run the object code and to modify the work, including scripts to 141 | control those activities. However, it does not include the work's 142 | System Libraries, or general-purpose tools or generally available free 143 | programs which are used unmodified in performing those activities but 144 | which are not part of the work. For example, Corresponding Source 145 | includes interface definition files associated with source files for 146 | the work, and the source code for shared libraries and dynamically 147 | linked subprograms that the work is specifically designed to require, 148 | such as by intimate data communication or control flow between those 149 | subprograms and other parts of the work. 150 | 151 | The Corresponding Source need not include anything that users 152 | can regenerate automatically from other parts of the Corresponding 153 | Source. 154 | 155 | The Corresponding Source for a work in source code form is that 156 | same work. 157 | 158 | 2. Basic Permissions. 159 | 160 | All rights granted under this License are granted for the term of 161 | copyright on the Program, and are irrevocable provided the stated 162 | conditions are met. This License explicitly affirms your unlimited 163 | permission to run the unmodified Program. The output from running a 164 | covered work is covered by this License only if the output, given its 165 | content, constitutes a covered work. This License acknowledges your 166 | rights of fair use or other equivalent, as provided by copyright law. 167 | 168 | You may make, run and propagate covered works that you do not 169 | convey, without conditions so long as your license otherwise remains 170 | in force. You may convey covered works to others for the sole purpose 171 | of having them make modifications exclusively for you, or provide you 172 | with facilities for running those works, provided that you comply with 173 | the terms of this License in conveying all material for which you do 174 | not control copyright. Those thus making or running the covered works 175 | for you must do so exclusively on your behalf, under your direction 176 | and control, on terms that prohibit them from making any copies of 177 | your copyrighted material outside their relationship with you. 178 | 179 | Conveying under any other circumstances is permitted solely under 180 | the conditions stated below. Sublicensing is not allowed; section 10 181 | makes it unnecessary. 182 | 183 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 184 | 185 | No covered work shall be deemed part of an effective technological 186 | measure under any applicable law fulfilling obligations under article 187 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 188 | similar laws prohibiting or restricting circumvention of such 189 | measures. 190 | 191 | When you convey a covered work, you waive any legal power to forbid 192 | circumvention of technological measures to the extent such circumvention 193 | is effected by exercising rights under this License with respect to 194 | the covered work, and you disclaim any intention to limit operation or 195 | modification of the work as a means of enforcing, against the work's 196 | users, your or third parties' legal rights to forbid circumvention of 197 | technological measures. 198 | 199 | 4. Conveying Verbatim Copies. 200 | 201 | You may convey verbatim copies of the Program's source code as you 202 | receive it, in any medium, provided that you conspicuously and 203 | appropriately publish on each copy an appropriate copyright notice; 204 | keep intact all notices stating that this License and any 205 | non-permissive terms added in accord with section 7 apply to the code; 206 | keep intact all notices of the absence of any warranty; and give all 207 | recipients a copy of this License along with the Program. 208 | 209 | You may charge any price or no price for each copy that you convey, 210 | and you may offer support or warranty protection for a fee. 211 | 212 | 5. Conveying Modified Source Versions. 213 | 214 | You may convey a work based on the Program, or the modifications to 215 | produce it from the Program, in the form of source code under the 216 | terms of section 4, provided that you also meet all of these conditions: 217 | 218 | a) The work must carry prominent notices stating that you modified 219 | it, and giving a relevant date. 220 | 221 | b) The work must carry prominent notices stating that it is 222 | released under this License and any conditions added under section 223 | 7. This requirement modifies the requirement in section 4 to 224 | "keep intact all notices". 225 | 226 | c) You must license the entire work, as a whole, under this 227 | License to anyone who comes into possession of a copy. This 228 | License will therefore apply, along with any applicable section 7 229 | additional terms, to the whole of the work, and all its parts, 230 | regardless of how they are packaged. This License gives no 231 | permission to license the work in any other way, but it does not 232 | invalidate such permission if you have separately received it. 233 | 234 | d) If the work has interactive user interfaces, each must display 235 | Appropriate Legal Notices; however, if the Program has interactive 236 | interfaces that do not display Appropriate Legal Notices, your 237 | work need not make them do so. 238 | 239 | A compilation of a covered work with other separate and independent 240 | works, which are not by their nature extensions of the covered work, 241 | and which are not combined with it such as to form a larger program, 242 | in or on a volume of a storage or distribution medium, is called an 243 | "aggregate" if the compilation and its resulting copyright are not 244 | used to limit the access or legal rights of the compilation's users 245 | beyond what the individual works permit. Inclusion of a covered work 246 | in an aggregate does not cause this License to apply to the other 247 | parts of the aggregate. 248 | 249 | 6. Conveying Non-Source Forms. 250 | 251 | You may convey a covered work in object code form under the terms 252 | of sections 4 and 5, provided that you also convey the 253 | machine-readable Corresponding Source under the terms of this License, 254 | in one of these ways: 255 | 256 | a) Convey the object code in, or embodied in, a physical product 257 | (including a physical distribution medium), accompanied by the 258 | Corresponding Source fixed on a durable physical medium 259 | customarily used for software interchange. 260 | 261 | b) Convey the object code in, or embodied in, a physical product 262 | (including a physical distribution medium), accompanied by a 263 | written offer, valid for at least three years and valid for as 264 | long as you offer spare parts or customer support for that product 265 | model, to give anyone who possesses the object code either (1) a 266 | copy of the Corresponding Source for all the software in the 267 | product that is covered by this License, on a durable physical 268 | medium customarily used for software interchange, for a price no 269 | more than your reasonable cost of physically performing this 270 | conveying of source, or (2) access to copy the 271 | Corresponding Source from a network server at no charge. 272 | 273 | c) Convey individual copies of the object code with a copy of the 274 | written offer to provide the Corresponding Source. This 275 | alternative is allowed only occasionally and noncommercially, and 276 | only if you received the object code with such an offer, in accord 277 | with subsection 6b. 278 | 279 | d) Convey the object code by offering access from a designated 280 | place (gratis or for a charge), and offer equivalent access to the 281 | Corresponding Source in the same way through the same place at no 282 | further charge. You need not require recipients to copy the 283 | Corresponding Source along with the object code. If the place to 284 | copy the object code is a network server, the Corresponding Source 285 | may be on a different server (operated by you or a third party) 286 | that supports equivalent copying facilities, provided you maintain 287 | clear directions next to the object code saying where to find the 288 | Corresponding Source. Regardless of what server hosts the 289 | Corresponding Source, you remain obligated to ensure that it is 290 | available for as long as needed to satisfy these requirements. 291 | 292 | e) Convey the object code using peer-to-peer transmission, provided 293 | you inform other peers where the object code and Corresponding 294 | Source of the work are being offered to the general public at no 295 | charge under subsection 6d. 296 | 297 | A separable portion of the object code, whose source code is excluded 298 | from the Corresponding Source as a System Library, need not be 299 | included in conveying the object code work. 300 | 301 | A "User Product" is either (1) a "consumer product", which means any 302 | tangible personal property which is normally used for personal, family, 303 | or household purposes, or (2) anything designed or sold for incorporation 304 | into a dwelling. In determining whether a product is a consumer product, 305 | doubtful cases shall be resolved in favor of coverage. For a particular 306 | product received by a particular user, "normally used" refers to a 307 | typical or common use of that class of product, regardless of the status 308 | of the particular user or of the way in which the particular user 309 | actually uses, or expects or is expected to use, the product. A product 310 | is a consumer product regardless of whether the product has substantial 311 | commercial, industrial or non-consumer uses, unless such uses represent 312 | the only significant mode of use of the product. 313 | 314 | "Installation Information" for a User Product means any methods, 315 | procedures, authorization keys, or other information required to install 316 | and execute modified versions of a covered work in that User Product from 317 | a modified version of its Corresponding Source. The information must 318 | suffice to ensure that the continued functioning of the modified object 319 | code is in no case prevented or interfered with solely because 320 | modification has been made. 321 | 322 | If you convey an object code work under this section in, or with, or 323 | specifically for use in, a User Product, and the conveying occurs as 324 | part of a transaction in which the right of possession and use of the 325 | User Product is transferred to the recipient in perpetuity or for a 326 | fixed term (regardless of how the transaction is characterized), the 327 | Corresponding Source conveyed under this section must be accompanied 328 | by the Installation Information. But this requirement does not apply 329 | if neither you nor any third party retains the ability to install 330 | modified object code on the User Product (for example, the work has 331 | been installed in ROM). 332 | 333 | The requirement to provide Installation Information does not include a 334 | requirement to continue to provide support service, warranty, or updates 335 | for a work that has been modified or installed by the recipient, or for 336 | the User Product in which it has been modified or installed. Access to a 337 | network may be denied when the modification itself materially and 338 | adversely affects the operation of the network or violates the rules and 339 | protocols for communication across the network. 340 | 341 | Corresponding Source conveyed, and Installation Information provided, 342 | in accord with this section must be in a format that is publicly 343 | documented (and with an implementation available to the public in 344 | source code form), and must require no special password or key for 345 | unpacking, reading or copying. 346 | 347 | 7. Additional Terms. 348 | 349 | "Additional permissions" are terms that supplement the terms of this 350 | License by making exceptions from one or more of its conditions. 351 | Additional permissions that are applicable to the entire Program shall 352 | be treated as though they were included in this License, to the extent 353 | that they are valid under applicable law. If additional permissions 354 | apply only to part of the Program, that part may be used separately 355 | under those permissions, but the entire Program remains governed by 356 | this License without regard to the additional permissions. 357 | 358 | When you convey a copy of a covered work, you may at your option 359 | remove any additional permissions from that copy, or from any part of 360 | it. (Additional permissions may be written to require their own 361 | removal in certain cases when you modify the work.) You may place 362 | additional permissions on material, added by you to a covered work, 363 | for which you have or can give appropriate copyright permission. 364 | 365 | Notwithstanding any other provision of this License, for material you 366 | add to a covered work, you may (if authorized by the copyright holders of 367 | that material) supplement the terms of this License with terms: 368 | 369 | a) Disclaiming warranty or limiting liability differently from the 370 | terms of sections 15 and 16 of this License; or 371 | 372 | b) Requiring preservation of specified reasonable legal notices or 373 | author attributions in that material or in the Appropriate Legal 374 | Notices displayed by works containing it; or 375 | 376 | c) Prohibiting misrepresentation of the origin of that material, or 377 | requiring that modified versions of such material be marked in 378 | reasonable ways as different from the original version; or 379 | 380 | d) Limiting the use for publicity purposes of names of licensors or 381 | authors of the material; or 382 | 383 | e) Declining to grant rights under trademark law for use of some 384 | trade names, trademarks, or service marks; or 385 | 386 | f) Requiring indemnification of licensors and authors of that 387 | material by anyone who conveys the material (or modified versions of 388 | it) with contractual assumptions of liability to the recipient, for 389 | any liability that these contractual assumptions directly impose on 390 | those licensors and authors. 391 | 392 | All other non-permissive additional terms are considered "further 393 | restrictions" within the meaning of section 10. If the Program as you 394 | received it, or any part of it, contains a notice stating that it is 395 | governed by this License along with a term that is a further 396 | restriction, you may remove that term. If a license document contains 397 | a further restriction but permits relicensing or conveying under this 398 | License, you may add to a covered work material governed by the terms 399 | of that license document, provided that the further restriction does 400 | not survive such relicensing or conveying. 401 | 402 | If you add terms to a covered work in accord with this section, you 403 | must place, in the relevant source files, a statement of the 404 | additional terms that apply to those files, or a notice indicating 405 | where to find the applicable terms. 406 | 407 | Additional terms, permissive or non-permissive, may be stated in the 408 | form of a separately written license, or stated as exceptions; 409 | the above requirements apply either way. 410 | 411 | 8. Termination. 412 | 413 | You may not propagate or modify a covered work except as expressly 414 | provided under this License. Any attempt otherwise to propagate or 415 | modify it is void, and will automatically terminate your rights under 416 | this License (including any patent licenses granted under the third 417 | paragraph of section 11). 418 | 419 | However, if you cease all violation of this License, then your 420 | license from a particular copyright holder is reinstated (a) 421 | provisionally, unless and until the copyright holder explicitly and 422 | finally terminates your license, and (b) permanently, if the copyright 423 | holder fails to notify you of the violation by some reasonable means 424 | prior to 60 days after the cessation. 425 | 426 | Moreover, your license from a particular copyright holder is 427 | reinstated permanently if the copyright holder notifies you of the 428 | violation by some reasonable means, this is the first time you have 429 | received notice of violation of this License (for any work) from that 430 | copyright holder, and you cure the violation prior to 30 days after 431 | your receipt of the notice. 432 | 433 | Termination of your rights under this section does not terminate the 434 | licenses of parties who have received copies or rights from you under 435 | this License. If your rights have been terminated and not permanently 436 | reinstated, you do not qualify to receive new licenses for the same 437 | material under section 10. 438 | 439 | 9. Acceptance Not Required for Having Copies. 440 | 441 | You are not required to accept this License in order to receive or 442 | run a copy of the Program. Ancillary propagation of a covered work 443 | occurring solely as a consequence of using peer-to-peer transmission 444 | to receive a copy likewise does not require acceptance. However, 445 | nothing other than this License grants you permission to propagate or 446 | modify any covered work. These actions infringe copyright if you do 447 | not accept this License. Therefore, by modifying or propagating a 448 | covered work, you indicate your acceptance of this License to do so. 449 | 450 | 10. Automatic Licensing of Downstream Recipients. 451 | 452 | Each time you convey a covered work, the recipient automatically 453 | receives a license from the original licensors, to run, modify and 454 | propagate that work, subject to this License. You are not responsible 455 | for enforcing compliance by third parties with this License. 456 | 457 | An "entity transaction" is a transaction transferring control of an 458 | organization, or substantially all assets of one, or subdividing an 459 | organization, or merging organizations. If propagation of a covered 460 | work results from an entity transaction, each party to that 461 | transaction who receives a copy of the work also receives whatever 462 | licenses to the work the party's predecessor in interest had or could 463 | give under the previous paragraph, plus a right to possession of the 464 | Corresponding Source of the work from the predecessor in interest, if 465 | the predecessor has it or can get it with reasonable efforts. 466 | 467 | You may not impose any further restrictions on the exercise of the 468 | rights granted or affirmed under this License. For example, you may 469 | not impose a license fee, royalty, or other charge for exercise of 470 | rights granted under this License, and you may not initiate litigation 471 | (including a cross-claim or counterclaim in a lawsuit) alleging that 472 | any patent claim is infringed by making, using, selling, offering for 473 | sale, or importing the Program or any portion of it. 474 | 475 | 11. Patents. 476 | 477 | A "contributor" is a copyright holder who authorizes use under this 478 | License of the Program or a work on which the Program is based. The 479 | work thus licensed is called the contributor's "contributor version". 480 | 481 | A contributor's "essential patent claims" are all patent claims 482 | owned or controlled by the contributor, whether already acquired or 483 | hereafter acquired, that would be infringed by some manner, permitted 484 | by this License, of making, using, or selling its contributor version, 485 | but do not include claims that would be infringed only as a 486 | consequence of further modification of the contributor version. For 487 | purposes of this definition, "control" includes the right to grant 488 | patent sublicenses in a manner consistent with the requirements of 489 | this License. 490 | 491 | Each contributor grants you a non-exclusive, worldwide, royalty-free 492 | patent license under the contributor's essential patent claims, to 493 | make, use, sell, offer for sale, import and otherwise run, modify and 494 | propagate the contents of its contributor version. 495 | 496 | In the following three paragraphs, a "patent license" is any express 497 | agreement or commitment, however denominated, not to enforce a patent 498 | (such as an express permission to practice a patent or covenant not to 499 | sue for patent infringement). To "grant" such a patent license to a 500 | party means to make such an agreement or commitment not to enforce a 501 | patent against the party. 502 | 503 | If you convey a covered work, knowingly relying on a patent license, 504 | and the Corresponding Source of the work is not available for anyone 505 | to copy, free of charge and under the terms of this License, through a 506 | publicly available network server or other readily accessible means, 507 | then you must either (1) cause the Corresponding Source to be so 508 | available, or (2) arrange to deprive yourself of the benefit of the 509 | patent license for this particular work, or (3) arrange, in a manner 510 | consistent with the requirements of this License, to extend the patent 511 | license to downstream recipients. "Knowingly relying" means you have 512 | actual knowledge that, but for the patent license, your conveying the 513 | covered work in a country, or your recipient's use of the covered work 514 | in a country, would infringe one or more identifiable patents in that 515 | country that you have reason to believe are valid. 516 | 517 | If, pursuant to or in connection with a single transaction or 518 | arrangement, you convey, or propagate by procuring conveyance of, a 519 | covered work, and grant a patent license to some of the parties 520 | receiving the covered work authorizing them to use, propagate, modify 521 | or convey a specific copy of the covered work, then the patent license 522 | you grant is automatically extended to all recipients of the covered 523 | work and works based on it. 524 | 525 | A patent license is "discriminatory" if it does not include within 526 | the scope of its coverage, prohibits the exercise of, or is 527 | conditioned on the non-exercise of one or more of the rights that are 528 | specifically granted under this License. You may not convey a covered 529 | work if you are a party to an arrangement with a third party that is 530 | in the business of distributing software, under which you make payment 531 | to the third party based on the extent of your activity of conveying 532 | the work, and under which the third party grants, to any of the 533 | parties who would receive the covered work from you, a discriminatory 534 | patent license (a) in connection with copies of the covered work 535 | conveyed by you (or copies made from those copies), or (b) primarily 536 | for and in connection with specific products or compilations that 537 | contain the covered work, unless you entered into that arrangement, 538 | or that patent license was granted, prior to 28 March 2007. 539 | 540 | Nothing in this License shall be construed as excluding or limiting 541 | any implied license or other defenses to infringement that may 542 | otherwise be available to you under applicable patent law. 543 | 544 | 12. No Surrender of Others' Freedom. 545 | 546 | If conditions are imposed on you (whether by court order, agreement or 547 | otherwise) that contradict the conditions of this License, they do not 548 | excuse you from the conditions of this License. If you cannot convey a 549 | covered work so as to satisfy simultaneously your obligations under this 550 | License and any other pertinent obligations, then as a consequence you may 551 | not convey it at all. For example, if you agree to terms that obligate you 552 | to collect a royalty for further conveying from those to whom you convey 553 | the Program, the only way you could satisfy both those terms and this 554 | License would be to refrain entirely from conveying the Program. 555 | 556 | 13. Use with the GNU Affero General Public License. 557 | 558 | Notwithstanding any other provision of this License, you have 559 | permission to link or combine any covered work with a work licensed 560 | under version 3 of the GNU Affero General Public License into a single 561 | combined work, and to convey the resulting work. The terms of this 562 | License will continue to apply to the part which is the covered work, 563 | but the special requirements of the GNU Affero General Public License, 564 | section 13, concerning interaction through a network will apply to the 565 | combination as such. 566 | 567 | 14. Revised Versions of this License. 568 | 569 | The Free Software Foundation may publish revised and/or new versions of 570 | the GNU General Public License from time to time. Such new versions will 571 | be similar in spirit to the present version, but may differ in detail to 572 | address new problems or concerns. 573 | 574 | Each version is given a distinguishing version number. If the 575 | Program specifies that a certain numbered version of the GNU General 576 | Public License "or any later version" applies to it, you have the 577 | option of following the terms and conditions either of that numbered 578 | version or of any later version published by the Free Software 579 | Foundation. If the Program does not specify a version number of the 580 | GNU General Public License, you may choose any version ever published 581 | by the Free Software Foundation. 582 | 583 | If the Program specifies that a proxy can decide which future 584 | versions of the GNU General Public License can be used, that proxy's 585 | public statement of acceptance of a version permanently authorizes you 586 | to choose that version for the Program. 587 | 588 | Later license versions may give you additional or different 589 | permissions. However, no additional obligations are imposed on any 590 | author or copyright holder as a result of your choosing to follow a 591 | later version. 592 | 593 | 15. Disclaimer of Warranty. 594 | 595 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 596 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 597 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 598 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 599 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 600 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 601 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 602 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 603 | 604 | 16. Limitation of Liability. 605 | 606 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 607 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 608 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 609 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 610 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 611 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 612 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 613 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 614 | SUCH DAMAGES. 615 | 616 | 17. Interpretation of Sections 15 and 16. 617 | 618 | If the disclaimer of warranty and limitation of liability provided 619 | above cannot be given local legal effect according to their terms, 620 | reviewing courts shall apply local law that most closely approximates 621 | an absolute waiver of all civil liability in connection with the 622 | Program, unless a warranty or assumption of liability accompanies a 623 | copy of the Program in return for a fee. 624 | 625 | END OF TERMS AND CONDITIONS 626 | 627 | How to Apply These Terms to Your New Programs 628 | 629 | If you develop a new program, and you want it to be of the greatest 630 | possible use to the public, the best way to achieve this is to make it 631 | free software which everyone can redistribute and change under these terms. 632 | 633 | To do so, attach the following notices to the program. It is safest 634 | to attach them to the start of each source file to most effectively 635 | state the exclusion of warranty; and each file should have at least 636 | the "copyright" line and a pointer to where the full notice is found. 637 | 638 | 639 | Copyright (C) 640 | 641 | This program is free software: you can redistribute it and/or modify 642 | it under the terms of the GNU General Public License as published by 643 | the Free Software Foundation, either version 3 of the License, or 644 | (at your option) any later version. 645 | 646 | This program is distributed in the hope that it will be useful, 647 | but WITHOUT ANY WARRANTY; without even the implied warranty of 648 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 649 | GNU General Public License for more details. 650 | 651 | You should have received a copy of the GNU General Public License 652 | along with this program. If not, see . 653 | 654 | Also add information on how to contact you by electronic and paper mail. 655 | 656 | If the program does terminal interaction, make it output a short 657 | notice like this when it starts in an interactive mode: 658 | 659 | Copyright (C) 660 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 661 | This is free software, and you are welcome to redistribute it 662 | under certain conditions; type `show c' for details. 663 | 664 | The hypothetical commands `show w' and `show c' should show the appropriate 665 | parts of the General Public License. Of course, your program's commands 666 | might be different; for a GUI interface, you would use an "about box". 667 | 668 | You should also get your employer (if you work as a programmer) or school, 669 | if any, to sign a "copyright disclaimer" for the program, if necessary. 670 | For more information on this, and how to apply and follow the GNU GPL, see 671 | . 672 | 673 | The GNU General Public License does not permit incorporating your program 674 | into proprietary programs. If your program is a subroutine library, you 675 | may consider it more useful to permit linking proprietary applications with 676 | the library. If this is what you want to do, use the GNU Lesser General 677 | Public License instead of this License. But first, please read 678 | . 679 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # House-GAN++ (data-reader) 2 | 3 | 4 | Code and instructions for converting rplan dataset (raster images) to [housegan++](https://github.com/ennauata/houseganpp) data format. 5 | [House-GAN++: Generative Adversarial Layout Refinement Network towards Intelligent Computational Agent for Professional Architects](https://arxiv.org/abs/2103.02574), CVPR 2021. 6 | Project [website](https://ennauata.github.io/houseganpp/page.html). 7 | 8 | 9 | 10 | 11 | Input Data 12 | ------ 13 | ![alt text](https://github.com/sepidsh/Housegan-data-reader/blob/main/image/0.jpg "Sample") 14 |
15 | Data: [RPLAN dataset](http://staff.ustc.edu.cn/~fuxm/projects/DeepLayout/index.html), which offers 60k vector-graphics floorplans designed by professional architects. 16 |
17 | 18 | Requirtments 19 | ------ 20 | 21 | ``` 22 | pip install argparse 23 | pip install numpy 24 | pip install matplotlib 25 | pip install shapely 26 | pip install descartes 27 | 28 | ``` 29 | 30 | How to run 31 | ------ 32 | 33 | ```python raster_to_json.py --path #rplan_dataset/#image_number.png``` 34 | 35 | Output data format 36 | ------ 37 | 38 | The data file (e.g., /sample_output/0.json). 39 | 40 | ``` 41 | ROOM_CLASS = {"living_room": 1, "kitchen": 2, "bedroom": 3, "bathroom": 4, "balcony": 5, "entrance": 6, "dining room": 7, "study room": 8, 42 | "storage": 10 , "front door": 15, "unknown": 16, "interior_door": 17} 43 | 44 | 45 | # having room type in it 46 | "room_type": [3, 4, 1, 3 ] 47 | 48 | #bounding boxes per room 49 | "boxes: [[72.0, 161.0, 124.0, 220.0], [72.0, 130.0, 107.0, 157.0], [111.0, 28.0, 184.0, 203.0], [72.0, 87.0, 124.0, 126.0]] 50 | 51 | #first four entry are per list are rooms edges and 4th and 6th are showing what room type is on each side of edge 52 | "edges":[72.0, 161.0, 72.0, 220.0, 3, 0], ...,[107.0, 130.0, 72.0, 130.0, 4, 0], [148.0, 28.0, 148.0, 87.0, 1, 2]] 53 | 54 | #room indexes that are on each side of the edges 55 | "ed_rm":[0], [0], [0], [0, 2], ..., [2], [2, 3], [2, 1], [2, 0], [2]] 56 | ``` 57 | 58 | 59 | 60 | Citation 61 | ------ 62 | Please consider citing our work. 63 | ``` 64 | @inproceedings{nauata2021house, 65 | title={House-GAN++: Generative Adversarial Layout Refinement Network towards Intelligent Computational Agent for Professional Architects}, 66 | author={Nauata, Nelson and Hosseini, Sepidehsadat and Chang, Kai-Hung and Chu, Hang and Cheng, Chin-Yi and Furukawa, Yasutaka}, 67 | booktitle={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition}, 68 | pages={13632--13641}, 69 | year={2021} 70 | } 71 | ``` 72 | 73 | Contact 74 | ------ 75 | If you have any question, feel free to contact me at sepidh@sfu.ca 76 | 77 | Acknowledgement 78 | ------ 79 | This research is partially supported by NSERC Discovery Grants, NSERC Discovery Grants Accelerator Supplements, DND/NSERC Discovery Grant Supplement, and Autodesk. We would like to thank architects and students for participating in our user study. 80 | 81 | -------------------------------------------------------------------------------- /image/0.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sepidsh/Housegan-data-reader/ff0046ea3c2cc25876f536879ce662c07f71928c/image/0.jpg -------------------------------------------------------------------------------- /image/0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sepidsh/Housegan-data-reader/ff0046ea3c2cc25876f536879ce662c07f71928c/image/0.png -------------------------------------------------------------------------------- /mask_to_poly.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from shapely import geometry as geo 3 | 4 | cts = [[[1,1,0],[1,1,0],[0,0,0]], [[1,1,1],[1,1,1],[1,1,0]], [[0,0,1],[0,1,1],[0,1,1]], [[0,0,0],[0,1,1],[1,1,1]]] 5 | cts = [[np.rot90(c, 0), np.rot90(c,1), np.rot90(c,2), np.rot90(c,3)] for c in cts] 6 | cts = np.array(cts) 7 | def is_contour(tmp, x): 8 | c = tmp[x[0]-1:x[0]+2, x[1]-1:x[1]+2] 9 | if(np.sum(c) not in [4,5,8]): 10 | return False 11 | for i in range(4): 12 | for j in range(4): 13 | if(np.array_equal(c , cts[j,i,:,:])): 14 | return True 15 | return False 16 | 17 | def corner_type(tmp, c): 18 | c = tmp[c[0]-1:c[0]+2, c[1]-1:c[1]+2] 19 | 20 | for i in range(4): 21 | if(np.array_equal(c, cts[0,i])): 22 | return (i+2)%4 23 | for i in range(4): 24 | if(np.array_equal(c, cts[1,i])): 25 | return (i+1)%4 26 | for i in range(4): 27 | if(np.array_equal(c, cts[2,i])): 28 | return (i)%4 29 | for i in range(4): 30 | if(np.array_equal(c, cts[3,i])): 31 | return (i)%4 32 | assert False, "Corner type is not supported" 33 | 34 | def preprocess(tmp): 35 | p1 = np.array([[0,1,1],[0,1,0],[0,0,0]]) 36 | p2 = np.array([[1,1,0],[0,1,0],[0,0,0]]) 37 | p3 = np.array([[1,1,1],[0,1,1],[0,0,1]]) 38 | p4 = np.array([[1,1,1],[1,1,1],[1,0,1]]) 39 | pts = np.transpose(np.where(tmp > 0)) 40 | for p in pts: 41 | c = tmp[p[0]-1:p[0]+2, p[1]-1:p[1]+2] 42 | if(np.sum(c) not in [3,8,6]): 43 | continue 44 | for i in range(4): 45 | if(np.array_equal(c, np.rot90(p1,i))): 46 | tmp[p[0],p[1]]=0 47 | elif(np.array_equal(c, np.rot90(p2,i))): 48 | tmp[p[0],p[1]]=0 49 | elif(np.array_equal(c, np.rot90(p3,i))): 50 | tmp[p[0],p[1]]=0 51 | elif(np.array_equal(c, np.rot90(p4,i))): 52 | tmp[p[0]-1:p[0]+2, p[1]-1:p[1]+2] = 1 53 | 54 | def sort_points(tmp, pts): 55 | points = [pts[0]] 56 | temp = pts[0] 57 | while(len(pts)>len(points)): 58 | ct = corner_type(tmp, temp) 59 | offset = [0,0] 60 | if(ct==3): 61 | candids = [p for p in pts if(p[0]==temp[0] and p[1]temp[0])] 68 | diff = np.array([p[0]-temp[0] for p in candids]) 69 | candid = candids[np.argmin(diff)] 70 | if(candid[1]-temp[1]!=0): 71 | offset[1] = temp[1] - candid[1] 72 | if(ct==1): 73 | candids = [p for p in pts if(p[0]==temp[0] and p[1]>temp[1])] 74 | diff = np.array([p[1]-temp[1] for p in candids]) 75 | candid = candids[np.argmin(diff)] 76 | if(candid[0]-temp[0]!=0): 77 | offset[0] = temp[0] - candid[0] 78 | if(ct==2): 79 | candids = [p for p in pts if(p[1]==temp[1] and p[0]0)) 93 | #print("point is",pts) 94 | pts = [x for x in pts if is_contour(mask, x)] 95 | pts = sort_points(mask, pts) 96 | poly = geo.Polygon(pts) 97 | return poly 98 | 99 | -------------------------------------------------------------------------------- /misc/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sepidsh/Housegan-data-reader/ff0046ea3c2cc25876f536879ce662c07f71928c/misc/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /misc/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sepidsh/Housegan-data-reader/ff0046ea3c2cc25876f536879ce662c07f71928c/misc/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /misc/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sepidsh/Housegan-data-reader/ff0046ea3c2cc25876f536879ce662c07f71928c/misc/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /misc/__pycache__/colors.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sepidsh/Housegan-data-reader/ff0046ea3c2cc25876f536879ce662c07f71928c/misc/__pycache__/colors.cpython-36.pyc -------------------------------------------------------------------------------- /misc/__pycache__/colors.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sepidsh/Housegan-data-reader/ff0046ea3c2cc25876f536879ce662c07f71928c/misc/__pycache__/colors.cpython-37.pyc -------------------------------------------------------------------------------- /misc/__pycache__/colors.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sepidsh/Housegan-data-reader/ff0046ea3c2cc25876f536879ce662c07f71928c/misc/__pycache__/colors.cpython-38.pyc -------------------------------------------------------------------------------- /misc/__pycache__/figures.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sepidsh/Housegan-data-reader/ff0046ea3c2cc25876f536879ce662c07f71928c/misc/__pycache__/figures.cpython-36.pyc -------------------------------------------------------------------------------- /misc/__pycache__/figures.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sepidsh/Housegan-data-reader/ff0046ea3c2cc25876f536879ce662c07f71928c/misc/__pycache__/figures.cpython-37.pyc -------------------------------------------------------------------------------- /misc/__pycache__/figures.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sepidsh/Housegan-data-reader/ff0046ea3c2cc25876f536879ce662c07f71928c/misc/__pycache__/figures.cpython-38.pyc -------------------------------------------------------------------------------- /misc/__pycache__/panorama.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sepidsh/Housegan-data-reader/ff0046ea3c2cc25876f536879ce662c07f71928c/misc/__pycache__/panorama.cpython-36.pyc -------------------------------------------------------------------------------- /misc/colors.py: -------------------------------------------------------------------------------- 1 | semantics_cmap = { 2 | 'living room': '#e6194b', 3 | 'kitchen': '#3cb44b', 4 | 'bedroom': '#ffe119', 5 | 'bathroom': '#0082c8', 6 | 'balcony': '#f58230', 7 | 'corridor': '#911eb4', 8 | 'dining room': '#46f0f0', 9 | 'study': '#f032e6', 10 | 'studio': '#d2f53c', 11 | 'store room': '#fabebe', 12 | 'garden': '#008080', 13 | 'laundry room': '#e6beff', 14 | 'office': '#aa6e28', 15 | 'basement': '#fffac8', 16 | 'garage': '#800000', 17 | 'undefined': '#aaffc3', 18 | 'door': '#808000', 19 | 'window': '#ffd7b4', 20 | 'outwall': '#000000', 21 | } 22 | 23 | 24 | colormap_255 = [ 25 | [230, 25, 75], 26 | [ 60, 180, 75], 27 | [255, 225, 25], 28 | [ 0, 130, 200], 29 | [245, 130, 48], 30 | [145, 30, 180], 31 | [ 70, 240, 240], 32 | [240, 50, 230], 33 | [210, 245, 60], 34 | [250, 190, 190], 35 | [ 0, 128, 128], 36 | [230, 190, 255], 37 | [170, 110, 40], 38 | [255, 250, 200], 39 | [128, 0, 0], 40 | [170, 255, 195], 41 | [128, 128, 0], 42 | [255, 215, 180], 43 | [ 0, 0, 128], 44 | [128, 128, 128], 45 | [255, 255, 255], 46 | [ 0, 0, 0] 47 | ] 48 | -------------------------------------------------------------------------------- /misc/figures.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copy from https://github.com/Toblerity/Shapely/blob/master/docs/code/figures.py 3 | """ 4 | 5 | from math import sqrt 6 | from shapely import affinity 7 | 8 | GM = (sqrt(5)-1.0)/2.0 9 | W = 8.0 10 | H = W*GM 11 | SIZE = (W, H) 12 | 13 | BLUE = '#6699cc' 14 | GRAY = '#999999' 15 | DARKGRAY = '#333333' 16 | YELLOW = '#ffcc33' 17 | GREEN = '#339933' 18 | RED = '#ff3333' 19 | BLACK = '#000000' 20 | 21 | COLOR_ISVALID = { 22 | True: BLUE, 23 | False: RED, 24 | } 25 | 26 | 27 | def plot_line(ax, ob, color=GRAY, zorder=1, linewidth=3, alpha=1): 28 | x, y = ob.xy 29 | ax.plot(x, y, color=color, linewidth=linewidth, solid_capstyle='round', zorder=zorder, alpha=alpha) 30 | 31 | 32 | def plot_coords(ax, ob, color=BLACK, zorder=1, alpha=1): 33 | x, y = ob.xy 34 | ax.plot(x, y, color=color, zorder=zorder, alpha=alpha) 35 | 36 | 37 | def color_isvalid(ob, valid=BLUE, invalid=RED): 38 | if ob.is_valid: 39 | return valid 40 | else: 41 | return invalid 42 | 43 | 44 | def color_issimple(ob, simple=BLUE, complex=YELLOW): 45 | if ob.is_simple: 46 | return simple 47 | else: 48 | return complex 49 | 50 | 51 | def plot_line_isvalid(ax, ob, **kwargs): 52 | kwargs["color"] = color_isvalid(ob) 53 | plot_line(ax, ob, **kwargs) 54 | 55 | 56 | def plot_line_issimple(ax, ob, **kwargs): 57 | kwargs["color"] = color_issimple(ob) 58 | plot_line(ax, ob, **kwargs) 59 | 60 | 61 | def plot_bounds(ax, ob, zorder=1, alpha=1): 62 | x, y = zip(*list((p.x, p.y) for p in ob.boundary)) 63 | ax.plot(x, y, 'o', color=BLACK, zorder=zorder, alpha=alpha) 64 | 65 | 66 | def add_origin(ax, geom, origin): 67 | x, y = xy = affinity.interpret_origin(geom, origin, 2) 68 | ax.plot(x, y, 'o', color=GRAY, zorder=1) 69 | ax.annotate(str(xy), xy=xy, ha='center', 70 | textcoords='offset points', xytext=(0, 8)) 71 | 72 | 73 | def set_limits(ax, x0, xN, y0, yN): 74 | ax.set_xlim(x0, xN) 75 | ax.set_xticks(range(x0, xN+1)) 76 | ax.set_ylim(y0, yN) 77 | ax.set_yticks(range(y0, yN+1)) 78 | ax.set_aspect("equal") 79 | -------------------------------------------------------------------------------- /misc/panorama.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copy 3 | from https://github.com/sunset1995/pytorch-layoutnet/blob/master/pano.py 4 | """ 5 | 6 | import numpy as np 7 | import numpy.matlib as matlib 8 | 9 | 10 | def xyz_2_coorxy(xs, ys, zs, H=512, W=1024): 11 | us = np.arctan2(xs, ys) 12 | vs = -np.arctan(zs / np.sqrt(xs**2 + ys**2)) 13 | coorx = (us / (2 * np.pi) + 0.5) * W 14 | coory = (vs / np.pi + 0.5) * H 15 | return coorx, coory 16 | 17 | 18 | def coords2uv(coords, width, height): 19 | """ 20 | Image coordinates (xy) to uv 21 | """ 22 | middleX = width / 2 + 0.5 23 | middleY = height / 2 + 0.5 24 | uv = np.hstack([ 25 | (coords[:, [0]] - middleX) / width * 2 * np.pi, 26 | -(coords[:, [1]] - middleY) / height * np.pi]) 27 | return uv 28 | 29 | 30 | def uv2xyzN(uv, planeID=1): 31 | ID1 = (int(planeID) - 1 + 0) % 3 32 | ID2 = (int(planeID) - 1 + 1) % 3 33 | ID3 = (int(planeID) - 1 + 2) % 3 34 | xyz = np.zeros((uv.shape[0], 3)) 35 | xyz[:, ID1] = np.cos(uv[:, 1]) * np.sin(uv[:, 0]) 36 | xyz[:, ID2] = np.cos(uv[:, 1]) * np.cos(uv[:, 0]) 37 | xyz[:, ID3] = np.sin(uv[:, 1]) 38 | return xyz 39 | 40 | 41 | def uv2xyzN_vec(uv, planeID): 42 | """ 43 | vectorization version of uv2xyzN 44 | @uv N x 2 45 | @planeID N 46 | """ 47 | assert (planeID.astype(int) != planeID).sum() == 0 48 | planeID = planeID.astype(int) 49 | ID1 = (planeID - 1 + 0) % 3 50 | ID2 = (planeID - 1 + 1) % 3 51 | ID3 = (planeID - 1 + 2) % 3 52 | ID = np.arange(len(uv)) 53 | xyz = np.zeros((len(uv), 3)) 54 | xyz[ID, ID1] = np.cos(uv[:, 1]) * np.sin(uv[:, 0]) 55 | xyz[ID, ID2] = np.cos(uv[:, 1]) * np.cos(uv[:, 0]) 56 | xyz[ID, ID3] = np.sin(uv[:, 1]) 57 | return xyz 58 | 59 | 60 | def xyz2uvN(xyz, planeID=1): 61 | ID1 = (int(planeID) - 1 + 0) % 3 62 | ID2 = (int(planeID) - 1 + 1) % 3 63 | ID3 = (int(planeID) - 1 + 2) % 3 64 | normXY = np.sqrt(xyz[:, [ID1]] ** 2 + xyz[:, [ID2]] ** 2) 65 | normXY[normXY < 0.000001] = 0.000001 66 | normXYZ = np.sqrt(xyz[:, [ID1]] ** 2 + xyz[:, [ID2]] ** 2 + xyz[:, [ID3]] ** 2) 67 | v = np.arcsin(xyz[:, [ID3]] / normXYZ) 68 | u = np.arcsin(xyz[:, [ID1]] / normXY) 69 | valid = (xyz[:, [ID2]] < 0) & (u >= 0) 70 | u[valid] = np.pi - u[valid] 71 | valid = (xyz[:, [ID2]] < 0) & (u <= 0) 72 | u[valid] = -np.pi - u[valid] 73 | uv = np.hstack([u, v]) 74 | uv[np.isnan(uv[:, 0]), 0] = 0 75 | return uv 76 | 77 | 78 | def computeUVN(n, in_, planeID): 79 | """ 80 | compute v given u and normal. 81 | """ 82 | if planeID == 2: 83 | n = np.array([n[1], n[2], n[0]]) 84 | elif planeID == 3: 85 | n = np.array([n[2], n[0], n[1]]) 86 | bc = n[0] * np.sin(in_) + n[1] * np.cos(in_) 87 | bs = n[2] 88 | out = np.arctan(-bc / (bs + 1e-9)) 89 | return out 90 | 91 | 92 | def computeUVN_vec(n, in_, planeID): 93 | """ 94 | vectorization version of computeUVN 95 | @n N x 3 96 | @in_ MN x 1 97 | @planeID N 98 | """ 99 | n = n.copy() 100 | if (planeID == 2).sum(): 101 | n[planeID == 2] = np.roll(n[planeID == 2], 2, axis=1) 102 | if (planeID == 3).sum(): 103 | n[planeID == 3] = np.roll(n[planeID == 3], 1, axis=1) 104 | n = np.repeat(n, in_.shape[0] // n.shape[0], axis=0) 105 | assert n.shape[0] == in_.shape[0] 106 | bc = n[:, [0]] * np.sin(in_) + n[:, [1]] * np.cos(in_) 107 | bs = n[:, [2]] 108 | out = np.arctan(-bc / (bs + 1e-9)) 109 | return out 110 | 111 | 112 | def lineFromTwoPoint(pt1, pt2): 113 | """ 114 | Generate line segment based on two points on panorama 115 | pt1, pt2: two points on panorama 116 | line: 117 | 1~3-th dim: normal of the line 118 | 4-th dim: the projection dimension ID 119 | 5~6-th dim: the u of line segment endpoints in projection plane 120 | """ 121 | numLine = pt1.shape[0] 122 | lines = np.zeros((numLine, 6)) 123 | n = np.cross(pt1, pt2) 124 | n = n / (matlib.repmat(np.sqrt(np.sum(n ** 2, 1, keepdims=True)), 1, 3) + 1e-9) 125 | lines[:, 0:3] = n 126 | 127 | areaXY = np.abs(np.sum(n * matlib.repmat([0, 0, 1], numLine, 1), 1, keepdims=True)) 128 | areaYZ = np.abs(np.sum(n * matlib.repmat([1, 0, 0], numLine, 1), 1, keepdims=True)) 129 | areaZX = np.abs(np.sum(n * matlib.repmat([0, 1, 0], numLine, 1), 1, keepdims=True)) 130 | planeIDs = np.argmax(np.hstack([areaXY, areaYZ, areaZX]), axis=1) + 1 131 | lines[:, 3] = planeIDs 132 | 133 | for i in range(numLine): 134 | uv = xyz2uvN(np.vstack([pt1[i, :], pt2[i, :]]), lines[i, 3]) 135 | umax = uv[:, 0].max() + np.pi 136 | umin = uv[:, 0].min() + np.pi 137 | if umax - umin > np.pi: 138 | lines[i, 4:6] = np.array([umax, umin]) / 2 / np.pi 139 | else: 140 | lines[i, 4:6] = np.array([umin, umax]) / 2 / np.pi 141 | 142 | return lines 143 | 144 | 145 | def lineIdxFromCors(cor_all, im_w, im_h): 146 | assert len(cor_all) % 2 == 0 147 | uv = coords2uv(cor_all, im_w, im_h) 148 | xyz = uv2xyzN(uv) 149 | lines = lineFromTwoPoint(xyz[0::2], xyz[1::2]) 150 | num_sample = max(im_h, im_w) 151 | 152 | cs, rs = [], [] 153 | for i in range(lines.shape[0]): 154 | n = lines[i, 0:3] 155 | sid = lines[i, 4] * 2 * np.pi 156 | eid = lines[i, 5] * 2 * np.pi 157 | if eid < sid: 158 | x = np.linspace(sid, eid + 2 * np.pi, num_sample) 159 | x = x % (2 * np.pi) 160 | else: 161 | x = np.linspace(sid, eid, num_sample) 162 | 163 | u = -np.pi + x.reshape(-1, 1) 164 | v = computeUVN(n, u, lines[i, 3]) 165 | xyz = uv2xyzN(np.hstack([u, v]), lines[i, 3]) 166 | uv = xyz2uvN(xyz, 1) 167 | 168 | r = np.minimum(np.floor((uv[:, 0] + np.pi) / (2 * np.pi) * im_w) + 1, 169 | im_w).astype(np.int32) 170 | c = np.minimum(np.floor((np.pi / 2 - uv[:, 1]) / np.pi * im_h) + 1, 171 | im_h).astype(np.int32) 172 | cs.extend(r - 1) 173 | rs.extend(c - 1) 174 | return rs, cs 175 | 176 | 177 | def draw_boundary_from_cor_id(cor_id, img_src): 178 | im_h, im_w = img_src.shape[:2] 179 | cor_all = [cor_id] 180 | for i in range(len(cor_id)): 181 | cor_all.append(cor_id[i, :]) 182 | cor_all.append(cor_id[(i+2) % len(cor_id), :]) 183 | cor_all = np.vstack(cor_all) 184 | 185 | rs, cs = lineIdxFromCors(cor_all, im_w, im_h) 186 | rs = np.array(rs) 187 | cs = np.array(cs) 188 | 189 | panoEdgeC = img_src.astype(np.uint8) 190 | for dx, dy in [[-1, 0], [1, 0], [0, 0], [0, 1], [0, -1]]: 191 | panoEdgeC[np.clip(rs + dx, 0, im_h - 1), np.clip(cs + dy, 0, im_w - 1), 0] = 0 192 | panoEdgeC[np.clip(rs + dx, 0, im_h - 1), np.clip(cs + dy, 0, im_w - 1), 1] = 0 193 | panoEdgeC[np.clip(rs + dx, 0, im_h - 1), np.clip(cs + dy, 0, im_w - 1), 2] = 255 194 | 195 | return panoEdgeC 196 | 197 | 198 | def coorx2u(x, w=1024): 199 | return ((x + 0.5) / w - 0.5) * 2 * np.pi 200 | 201 | 202 | def coory2v(y, h=512): 203 | return ((y + 0.5) / h - 0.5) * np.pi 204 | 205 | 206 | def u2coorx(u, w=1024): 207 | return (u / (2 * np.pi) + 0.5) * w - 0.5 208 | 209 | 210 | def v2coory(v, h=512): 211 | return (v / np.pi + 0.5) * h - 0.5 212 | 213 | 214 | def uv2xy(u, v, z=-50): 215 | c = z / np.tan(v) 216 | x = c * np.cos(u) 217 | y = c * np.sin(u) 218 | return x, y 219 | 220 | 221 | def pano_connect_points(p1, p2, z=-50, w=1024, h=512): 222 | u1 = coorx2u(p1[0], w) 223 | v1 = coory2v(p1[1], h) 224 | u2 = coorx2u(p2[0], w) 225 | v2 = coory2v(p2[1], h) 226 | 227 | x1, y1 = uv2xy(u1, v1, z) 228 | x2, y2 = uv2xy(u2, v2, z) 229 | 230 | if abs(p1[0] - p2[0]) < w / 2: 231 | pstart = np.ceil(min(p1[0], p2[0])) 232 | pend = np.floor(max(p1[0], p2[0])) 233 | else: 234 | pstart = np.ceil(max(p1[0], p2[0])) 235 | pend = np.floor(min(p1[0], p2[0]) + w) 236 | coorxs = (np.arange(pstart, pend + 1) % w).astype(np.float64) 237 | vx = x2 - x1 238 | vy = y2 - y1 239 | us = coorx2u(coorxs, w) 240 | ps = (np.tan(us) * x1 - y1) / (vy - np.tan(us) * vx) 241 | cs = np.sqrt((x1 + ps * vx) ** 2 + (y1 + ps * vy) ** 2) 242 | vs = np.arctan2(z, cs) 243 | coorys = v2coory(vs) 244 | 245 | return np.stack([coorxs, coorys], axis=-1) 246 | -------------------------------------------------------------------------------- /misc/test.py: -------------------------------------------------------------------------------- 1 | import torch 2 | import torch.nn as nn 3 | import torch.optim as optim 4 | from sklearn.metrics import roc_auc_score 5 | from sklearn.preprocessing import StandardScaler 6 | from sklearn.model_selection import train_test_split 7 | 8 | # Define a deeper autoencoder for outlier detection 9 | class DeepAutoencoder(nn.Module): 10 | def __init__(self, input_dim): 11 | super(DeepAutoencoder, self).__init__() 12 | self.encoder = nn.Sequential( 13 | nn.Linear(input_dim, 128), 14 | nn.ReLU(), 15 | nn.Linear(128, 64), 16 | nn.ReLU(), 17 | nn.Linear(64, 32), 18 | nn.ReLU(), 19 | nn.Linear(32, 16), 20 | nn.ReLU() 21 | ) 22 | self.decoder = nn.Sequential( 23 | nn.Linear(16, 32), 24 | nn.ReLU(), 25 | nn.Linear(32, 64), 26 | nn.ReLU(), 27 | nn.Linear(64, 128), 28 | nn.ReLU(), 29 | nn.Linear(128, input_dim), 30 | nn.Sigmoid() 31 | ) 32 | 33 | def forward(self, x): 34 | x = self.encoder(x) 35 | x = self.decoder(x) 36 | return x 37 | 38 | # Load and preprocess data 39 | # Assuming X, y are your data 40 | X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42) 41 | 42 | scaler = StandardScaler() 43 | X_train_scaled = scaler.fit_transform(X_train) 44 | X_test_scaled = scaler.transform(X_test) 45 | 46 | X_train_tensor = torch.tensor(X_train_scaled).float() 47 | X_test_tensor = torch.tensor(X_test_scaled).float() 48 | 49 | # Train the autoencoder for outlier detection 50 | autoencoder = DeepAutoencoder(input_dim=X_train_tensor.shape[1]) 51 | 52 | criterion = nn.MSELoss() 53 | optimizer = optim.Adam(autoencoder.parameters(), lr=0.001) 54 | 55 | epochs = 10 56 | for epoch in range(epochs): 57 | optimizer.zero_grad() 58 | outputs = autoencoder(X_train_tensor) 59 | loss = criterion(outputs, X_train_tensor) 60 | loss.backward() 61 | optimizer.step() 62 | 63 | # Use reconstruction error as outlier scores 64 | with torch.no_grad(): 65 | X_train_reconstructed = autoencoder(X_train_tensor) 66 | X_test_reconstructed = autoencoder(X_test_tensor) 67 | reconstruction_errors_train = torch.mean((X_train_tensor - X_train_reconstructed)**2, dim=1) 68 | reconstruction_errors_test = torch.mean((X_test_tensor - X_test_reconstructed)**2, dim=1) 69 | 70 | # Concatenate original features with reconstruction errors 71 | X_train_combined = torch.cat((X_train_tensor, reconstruction_errors_train.unsqueeze(1)), dim=1) 72 | X_test_combined = torch.cat((X_test_tensor, reconstruction_errors_test.unsqueeze(1)), dim=1) 73 | 74 | # Define a simple neural network for classification 75 | class Classifier(nn.Module): 76 | def __init__(self, input_dim): 77 | super(Classifier, self).__init__() 78 | self.fc1 = nn.Linear(input_dim, 64) 79 | self.fc2 = nn.Linear(64, 32) 80 | self.fc3 = nn.Linear(32, 1) 81 | self.sigmoid = nn.Sigmoid() 82 | 83 | def forward(self, x): 84 | x = torch.relu(self.fc1(x)) 85 | x = torch.relu(self.fc2(x)) 86 | x = self.sigmoid(self.fc3(x)) 87 | return x 88 | 89 | # Train a classifier on the combined feature set 90 | input_dim_combined = X_train_combined.shape[1] 91 | classifier = Classifier(input_dim_combined) 92 | 93 | criterion_classifier = nn.BCELoss() 94 | optimizer_classifier = optim.Adam(classifier.parameters(), lr=0.001) 95 | 96 | epochs_classifier = 10 97 | for epoch in range(epochs_classifier): 98 | optimizer_classifier.zero_grad() 99 | outputs_classifier = classifier(X_train_combined) 100 | loss_classifier = criterion_classifier(outputs_classifier, y_train.view(-1, 1).float()) 101 | loss_classifier.backward() 102 | optimizer_classifier.step() 103 | 104 | # Evaluate the classifier on the test set 105 | classifier.eval() 106 | with torch.no_grad(): 107 | outputs_test = classifier(X_test_combined) 108 | y_pred_test = (outputs_test > 0.5).float() 109 | 110 | auc_score_test = roc_auc_score(y_test, y_pred_test) 111 | print("AUC Score on Test Set:", auc_score_test) 112 | -------------------------------------------------------------------------------- /misc/utils.py: -------------------------------------------------------------------------------- 1 | """ 2 | Adapted from https://github.com/thusiyuan/cooperative_scene_parsing/blob/master/utils/sunrgbd_utils.py 3 | """ 4 | import numpy as np 5 | 6 | 7 | def normalize(vector): 8 | return vector / np.linalg.norm(vector) 9 | 10 | 11 | def parse_camera_info(camera_info, height, width): 12 | """ extract intrinsic and extrinsic matrix 13 | """ 14 | lookat = normalize(camera_info[3:6]) 15 | up = normalize(camera_info[6:9]) 16 | 17 | W = lookat 18 | U = np.cross(W, up) 19 | V = -np.cross(W, U) 20 | 21 | rot = np.vstack((U, V, W)) 22 | trans = camera_info[:3] 23 | 24 | xfov = camera_info[9] 25 | yfov = camera_info[10] 26 | 27 | K = np.diag([1, 1, 1]) 28 | 29 | K[0, 2] = width / 2 30 | K[1, 2] = height / 2 31 | 32 | K[0, 0] = K[0, 2] / np.tan(xfov) 33 | K[1, 1] = K[1, 2] / np.tan(yfov) 34 | 35 | return rot, trans, K 36 | 37 | 38 | def flip_towards_viewer(normals, points): 39 | points = points / np.linalg.norm(points) 40 | proj = points.dot(normals[:2, :].T) 41 | flip = np.where(proj > 0) 42 | normals[flip, :] = -normals[flip, :] 43 | return normals 44 | 45 | 46 | def get_corners_of_bb3d(basis, coeffs, centroid): 47 | corners = np.zeros((8, 3)) 48 | # order the basis 49 | index = np.argsort(np.abs(basis[:, 0]))[::-1] 50 | # the case that two same value appear the same time 51 | if index[2] != 2: 52 | index[1:] = index[1:][::-1] 53 | basis = basis[index, :] 54 | coeffs = coeffs[index] 55 | # Now, we know the basis vectors are orders X, Y, Z. Next, flip the basis vectors towards the viewer 56 | basis = flip_towards_viewer(basis, centroid) 57 | coeffs = np.abs(coeffs) 58 | corners[0, :] = -basis[0, :] * coeffs[0] + basis[1, :] * coeffs[1] + basis[2, :] * coeffs[2] 59 | corners[1, :] = basis[0, :] * coeffs[0] + basis[1, :] * coeffs[1] + basis[2, :] * coeffs[2] 60 | corners[2, :] = basis[0, :] * coeffs[0] + -basis[1, :] * coeffs[1] + basis[2, :] * coeffs[2] 61 | corners[3, :] = -basis[0, :] * coeffs[0] + -basis[1, :] * coeffs[1] + basis[2, :] * coeffs[2] 62 | 63 | corners[4, :] = -basis[0, :] * coeffs[0] + basis[1, :] * coeffs[1] + -basis[2, :] * coeffs[2] 64 | corners[5, :] = basis[0, :] * coeffs[0] + basis[1, :] * coeffs[1] + -basis[2, :] * coeffs[2] 65 | corners[6, :] = basis[0, :] * coeffs[0] + -basis[1, :] * coeffs[1] + -basis[2, :] * coeffs[2] 66 | corners[7, :] = -basis[0, :] * coeffs[0] + -basis[1, :] * coeffs[1] + -basis[2, :] * coeffs[2] 67 | corners = corners + np.tile(centroid, (8, 1)) 68 | return corners 69 | 70 | 71 | def get_corners_of_bb3d_no_index(basis, coeffs, centroid): 72 | corners = np.zeros((8, 3)) 73 | coeffs = np.abs(coeffs) 74 | corners[0, :] = -basis[0, :] * coeffs[0] + basis[1, :] * coeffs[1] + basis[2, :] * coeffs[2] 75 | corners[1, :] = basis[0, :] * coeffs[0] + basis[1, :] * coeffs[1] + basis[2, :] * coeffs[2] 76 | corners[2, :] = basis[0, :] * coeffs[0] + -basis[1, :] * coeffs[1] + basis[2, :] * coeffs[2] 77 | corners[3, :] = -basis[0, :] * coeffs[0] + -basis[1, :] * coeffs[1] + basis[2, :] * coeffs[2] 78 | 79 | corners[4, :] = -basis[0, :] * coeffs[0] + basis[1, :] * coeffs[1] + -basis[2, :] * coeffs[2] 80 | corners[5, :] = basis[0, :] * coeffs[0] + basis[1, :] * coeffs[1] + -basis[2, :] * coeffs[2] 81 | corners[6, :] = basis[0, :] * coeffs[0] + -basis[1, :] * coeffs[1] + -basis[2, :] * coeffs[2] 82 | corners[7, :] = -basis[0, :] * coeffs[0] + -basis[1, :] * coeffs[1] + -basis[2, :] * coeffs[2] 83 | 84 | corners = corners + np.tile(centroid, (8, 1)) 85 | return corners 86 | 87 | 88 | def project_3d_points_to_2d(points3d, R_ex, K): 89 | """ 90 | Project 3d points from camera-centered coordinate to 2D image plane 91 | Parameters 92 | ---------- 93 | points3d: numpy array 94 | 3d location of point 95 | R_ex: numpy array 96 | extrinsic camera parameter 97 | K: numpy array 98 | intrinsic camera parameter 99 | Returns 100 | ------- 101 | points2d: numpy array 102 | 2d location of the point 103 | """ 104 | points3d = R_ex.dot(points3d.T).T 105 | x3 = points3d[:, 0] 106 | y3 = -points3d[:, 1] 107 | z3 = np.abs(points3d[:, 2]) 108 | xx = x3 * K[0, 0] / z3 + K[0, 2] 109 | yy = y3 * K[1, 1] / z3 + K[1, 2] 110 | points2d = np.vstack((xx, yy)) 111 | return points2d 112 | 113 | 114 | def project_struct_bdb_to_2d(basis, coeffs, center, R_ex, K): 115 | """ 116 | Project 3d bounding box to 2d bounding box 117 | Parameters 118 | ---------- 119 | basis, coeffs, center, R_ex, K 120 | : K is the intrinsic camera parameter matrix 121 | : Rtilt is the extrinsic camera parameter matrix in right hand coordinates 122 | Returns 123 | ------- 124 | bdb2d: dict 125 | Keys: {'x1', 'x2', 'y1', 'y2'} 126 | The (x1, y1) position is at the top left corner, 127 | the (x2, y2) position is at the bottom right corner 128 | """ 129 | corners3d = get_corners_of_bb3d(basis, coeffs, center) 130 | corners = project_3d_points_to_2d(corners3d, R_ex, K) 131 | bdb2d = dict() 132 | bdb2d['x1'] = int(max(np.min(corners[0, :]), 1)) # x1 133 | bdb2d['y1'] = int(max(np.min(corners[1, :]), 1)) # y1 134 | bdb2d['x2'] = int(min(np.max(corners[0, :]), 2*K[0, 2])) # x2 135 | bdb2d['y2'] = int(min(np.max(corners[1, :]), 2*K[1, 2])) # y2 136 | # if not check_bdb(bdb2d, 2*K[0, 2], 2*K[1, 2]): 137 | # bdb2d = None 138 | return bdb2d 139 | -------------------------------------------------------------------------------- /raster_to_json.py: -------------------------------------------------------------------------------- 1 | import json 2 | import argparse 3 | import numpy as np 4 | # import matplotlib.pyplot as plt 5 | from shapely.geometry import Polygon 6 | # from descartes.patch import PolygonPatch 7 | from read_dd import read_data 8 | 9 | import warnings 10 | 11 | 12 | def raster_to_json(line, print_door_warning): 13 | """ convert extracted data from rasters to housegan ++ data format : extract rooms type, bbox, doors, edges and neigbour rooms 14 | 15 | """ 16 | # fig = plt.figure() 17 | # ax = fig.add_subplot(1, 1, 1) 18 | bbox_x1=[] 19 | bbox_y1=[] 20 | bbox_x2=[] 21 | bbox_y2=[] 22 | walls=[] 23 | 24 | room_type,poly,doors_, walls,out=read_data(line) 25 | 26 | d=[] 27 | all_doors=[] 28 | for i in range(1,len(doors_)+1): 29 | if((i)%4==0 ) & (i+1!=1): 30 | d.append(doors_[i-1]) 31 | all_doors.append(d) 32 | d=[] 33 | elif(i==1): 34 | d=[] 35 | if(i%4!=0): 36 | d.append(doors_[i-1]) 37 | kh=0 38 | al_dr=0 39 | for hd in range(len(all_doors)): 40 | dr_t=[] 41 | dr_in=[] 42 | doors=all_doors[hd] 43 | d_t=2 44 | t_x=abs(doors[0][1]-doors[1][1]) 45 | t_y=abs(doors[0][0]-doors[3][0]) 46 | ss=t_x 47 | if(t_x>t_y): 48 | d_t=1 49 | ss=t_y 50 | elif(t_xr): 63 | t=l 64 | l=r 65 | r=t 66 | l_=walls[nw][1] 67 | r_=walls[nw][3] 68 | if(l_>r_): 69 | t=l_ 70 | l_=r_ 71 | r_=t 72 | if (((r-r_)<=pmc )& (pmc>=(l_-l))) : 73 | if(len(dr_in)<2): 74 | if(walls[nw][6] not in dr_t): 75 | dr_t.append(walls[nw][6]) 76 | dr_in.append(nw) 77 | 78 | elif (d_t>=2)& (doors[dw][1]-doors[dw][3]<=1)& (walls[nw][1]-walls[nw][3]<=1) &(abs(doors[dw][1]-walls[nw][1])<=(ss-1)) & (abs(doors[dw][3]-walls[nw][3])<=(ss-1)): 79 | l=doors[dw][0] 80 | r=doors[dw][2] 81 | if(l>r): 82 | t=l 83 | l=r 84 | r=t 85 | l_=walls[nw][0] 86 | r_=walls[nw][2] 87 | if(l_>r_): 88 | t=l_ 89 | l_=r_ 90 | r_=t 91 | if(((r-r_)<=pmc )& (pmc>=(l_-l))): 92 | if(len(dr_in)<2): 93 | if(walls[nw][6] not in dr_t): 94 | dr_t.append(walls[nw][6]) 95 | dr_in.append(nw) 96 | if(len(dr_t)==2): 97 | walls[dr_in[0]][8]=walls[dr_in[1]][5] 98 | walls[dr_in[0]][7]=walls[dr_in[1]][6] 99 | walls[dr_in[1]][8]=walls[dr_in[0]][5] 100 | walls[dr_in[1]][7]=walls[dr_in[0]][6] 101 | al_dr=al_dr+1 102 | 103 | else: 104 | if print_door_warning: 105 | print("sometime not 2 dooor",hd,doors) 106 | 107 | assert(len(dr_t)<=2) 108 | 109 | 110 | assert(al_dr==(len(all_doors)-1)) 111 | 112 | 113 | omn=[] 114 | tr=0 115 | en_pp=0 116 | for nw in range(len(walls)-(len(all_doors)*4),len(walls)): 117 | if(tr%4==0): 118 | omn=[] 119 | tr=tr+1 120 | for kw in range(len(walls)-(len(all_doors)*4)+1): 121 | if(walls[kw][5]==17)&(walls[nw][5]==17): 122 | continue 123 | if(walls[kw][5]==15)&(walls[nw][5]==15): 124 | continue 125 | if(walls[kw][5]==15)&(walls[nw][5]==17): 126 | continue 127 | for pmc in range (5): 128 | if(abs(walls[kw][0]-walls[nw][0])<=(ss-1)) & (abs(walls[kw][2]-walls[nw][2])<=(ss-1)): 129 | l=walls[kw][1] 130 | r=walls[kw][3] 131 | if(l>r): 132 | t=l 133 | l=r 134 | r=t 135 | l_=walls[nw][1] 136 | r_=walls[nw][3] 137 | if(l_>r_): 138 | t=l_ 139 | l_=r_ 140 | r_=t 141 | if(pmc>=r_-r )& (l-l_<=pmc) &( nw!=kw): 142 | if(walls[nw][5]==17) &(walls[nw][8]==0)& (walls[kw][6] not in omn): 143 | walls[nw][8]=walls[kw][5] 144 | walls[nw][7]=walls[kw][6] 145 | omn.append(walls[kw][6]) 146 | if(walls[nw][5]==15) &(walls[nw][8]==0): 147 | walls[nw][8]=walls[kw][5] 148 | walls[nw][7]=walls[kw][6] 149 | en_pp=1 150 | 151 | if(abs(walls[kw][1]-walls[nw][1])<=(ss-1)) & (abs(walls[kw][3]-walls[nw][3])<=(ss-1)): 152 | l=walls[kw][0] 153 | r=walls[kw][2] 154 | if(l>r): 155 | t=l 156 | l=r 157 | r=t 158 | l_=walls[nw][0] 159 | r_=walls[nw][2] 160 | if(l_>r_): 161 | t=l_ 162 | l_=r_ 163 | r_=t 164 | if(pmc>=r_-r )& (l-l_<=pmc) &( nw!=kw): 165 | if(walls[nw][5]==17) & (walls[nw][8]==0)& (walls[kw][6] not in omn): 166 | walls[nw][8]=walls[kw][5] 167 | walls[nw][7]=walls[kw][6] 168 | omn.append(walls[kw][6]) 169 | 170 | if(walls[nw][5]==15) & (walls[nw][8]==0): 171 | walls[nw][8]=walls[kw][5] 172 | walls[nw][7]=walls[kw][6] 173 | en_pp=1 174 | 175 | 176 | for i in range(1): 177 | for iw in range(len(walls)): 178 | tp_out=-1 179 | dif_x=10 180 | dif_y=10 181 | 182 | type_out=0 183 | for jw in range(len(walls)): 184 | if(walls[iw][0]==walls[iw][2]): 185 | if (walls[jw][0]!=walls[jw][2]): 186 | continue 187 | if ((walls[iw][0]-walls[jw][0])==(walls[iw][2]- walls[jw][2])): 188 | rnp=walls[jw][1] 189 | fnp=walls[jw][3] 190 | rmp=walls[iw][1] 191 | fmp=walls[iw][3] 192 | if( rnpabs(dif_x_temp)) & (iw!=jw): 203 | dif_x=dif_x_temp 204 | tp_out=walls[jw][6] 205 | type_out=walls[jw][5] 206 | 207 | elif(walls[iw][1]==walls[iw][3]): 208 | if ((walls[iw][1]-walls[jw][1])==(walls[iw][3]- walls[jw][3])) : 209 | rnp=walls[jw][0] 210 | fnp=walls[jw][2] 211 | rmp=walls[iw][0] 212 | fmp=walls[iw][2] 213 | if( rnpabs(dif_y_temp))&( iw!=jw ): 224 | dif_y=dif_y_temp 225 | tp_out=walls[jw][6] 226 | type_out=walls[jw][5] 227 | 228 | km=0 229 | assert(en_pp==1) #throwing out really strange layouts 230 | 231 | 232 | lenx=1.0 233 | leny=1.0 234 | min_x=0.0 235 | min_y=0.0 236 | bboxes=[] 237 | edges=[] 238 | ed_rm=[] 239 | info=dict() 240 | 241 | # The edges for the graph 242 | for w_i in range(len(walls)): 243 | edges.append([((walls[w_i][0]-min_x)/lenx),((walls[w_i][1]-min_y)/leny),((walls[w_i][2]-min_x)/lenx),((walls[w_i][3]-min_y)/leny),walls[w_i][5],walls[w_i][8]]) 244 | if(walls[w_i][6]==-1): 245 | ed_rm.append([walls[w_i][7]]) 246 | elif(walls[w_i][7]==-1): 247 | ed_rm.append([walls[w_i][6]]) 248 | else: 249 | ed_rm.append([walls[w_i][6],walls[w_i][7]]) 250 | 251 | # The bbox for room masks 252 | for i in range(len(poly)): 253 | p=poly[i] 254 | pm=[] 255 | for p_i in range((p)): 256 | pm.append(([edges[km+p_i][0],edges[km+p_i][1]])) 257 | km=km+p 258 | polygon = Polygon(pm) 259 | # plot_coords(ax, polygon.exterior, alpha=0) 260 | bbox=np.asarray(polygon.bounds) 261 | bboxes.append(bbox.tolist()) 262 | 263 | 264 | # patch = PolygonPatch(polygon, facecolor=semantics_cmap["bedroom"], alpha=0.7) 265 | # ax.add_patch(patch) 266 | 267 | info['room_type'] = room_type 268 | info['boxes'] = bboxes 269 | info['edges'] = edges 270 | info['ed_rm'] = ed_rm 271 | 272 | # print(bboxes) 273 | 274 | fp_id = line.split("/")[-1].split(".")[0] 275 | 276 | ### saving json files 277 | with open(f"rplan_json/{fp_id}.json","w") as f: 278 | json.dump(info, f) 279 | 280 | 281 | 282 | 283 | def parse_args(): 284 | parser = argparse.ArgumentParser(description="Structured3D 3D Visualization") 285 | parser.add_argument("--path", required=True, 286 | help="dataset path", metavar="DIR") 287 | return parser.parse_args() 288 | 289 | 290 | def main(): 291 | args = parse_args() 292 | line=args.path 293 | 294 | try: 295 | raster_to_json(line, print_door_warning=False) 296 | except (AssertionError, ValueError, IndexError) as e: 297 | fp_id = line.split("/")[-1].split(".")[0] 298 | 299 | with open(f"failed_rplan_json/{fp_id}", "w") as f: 300 | f.write(str(e)) 301 | 302 | if __name__ == "__main__": 303 | 304 | with warnings.catch_warnings(): 305 | warnings.simplefilter("ignore") 306 | main() 307 | -------------------------------------------------------------------------------- /read_dd.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from PIL import Image 3 | import mask_to_poly as mr 4 | 5 | def read_door(door_img,img,tmp_diff): 6 | tmp3=door_img.copy() 7 | tmp4=door_img.copy() 8 | for k in range(256): 9 | for h in range(256): 10 | has=[] 11 | for knm in range(10): 12 | has.append(0) 13 | if(tmp4[k][h]==1): 14 | p=img[k-tmp_diff-4:k+tmp_diff+4,h-tmp_diff-4:h+tmp_diff+4,2] 15 | s=p[np.nonzero(p)] 16 | if(len(s)==0): 17 | continue 18 | r=[] 19 | kmmmm=s[0] 20 | for t in range(len(s)): 21 | if(t==0): 22 | r.append(s[t]) 23 | elif(s[t] not in r): 24 | r.append(s[t]) 25 | if(len(r)>=3): 26 | tmp3[k][h]=0 27 | elif(len(r)==2): 28 | has[r[0]]=1 29 | has[r[1]]=1 30 | tmp3[k][h]= has[0]*1+has[1]*2+has[3]*4+has[4]*8+has[5]*16+has[6]*32+has[7]*64+has[8]*128+has[9]*256 31 | s=np.unique(tmp3) 32 | tmp4=tmp3.copy() 33 | for ks in range(len(s)): 34 | for k in range(256): 35 | for h in range(256): 36 | if(tmp3[k][h]==s[ks]): 37 | tmp4[k][h]=int(ks) 38 | return tmp4 39 | 40 | 41 | 42 | def sort_corners(corners ,k_d): 43 | coords=[] 44 | ind=[] 45 | if(k_d==0): 46 | for j in range(len(corners)): 47 | ind.append(0) 48 | for i in range(len(corners)): 49 | if (i==0): 50 | coords.append(corners[0]) 51 | ind[i]=1 52 | 53 | elif(i%2==1): 54 | k=coords[i-1][0] 55 | for j in range(len(corners)): 56 | if(corners[j][0]==k)& ( ind[j]!=1): 57 | coords.append(corners[j]) 58 | ind[j]=1 59 | break 60 | elif(i%2==0): 61 | k=coords[i-1][1] 62 | for j in range(len(corners)): 63 | if(corners[j][1]==k)& (ind[j]!=1): 64 | coords.append(corners[j]) 65 | ind[j]=1 66 | break 67 | 68 | if(k_d==1): 69 | for s in range(len(corners)): 70 | ind.append(0) 71 | p=0 72 | for i in range(len(corners)): 73 | if (i%4==0): 74 | coords.append(corners[i]) 75 | ind[i]=1 76 | p=p+1 77 | elif(i%2==1): 78 | k=coords[i-1][0] 79 | tk=coords[i-1][1] 80 | pp=0 81 | for j in range(len(corners)): 82 | if(corners[j][0]==k)& (ind[j]!=1): 83 | if(pp==0) : 84 | pp=pp+1 85 | coords.append(corners[j]) 86 | fn=j 87 | else: 88 | if (abs(corners[j][1]-tk)<=abs(coords[i][1]-tk)) &(abs(corners[j][1]-tk)!=0): 89 | coords[i]=corners[j] 90 | fn=j 91 | ind[fn]=ind[fn]+1 92 | fn=-1 93 | p=p+1 94 | elif(i%2==0)& (i%4!=0): 95 | p=p+1 96 | k=coords[i-1][1] 97 | tk=coords[i-1][0] 98 | pp=0 99 | for j in range(len(corners)): 100 | if(corners[j][1]==k) & (ind[j]!=1): 101 | if(pp==0): 102 | pp=pp+1 103 | coords.append(corners[j]) 104 | fn=j 105 | else: 106 | if (abs(corners[j][0]-tk)<=abs(coords[i][0]-tk)) &(abs(corners[j][0]-tk)!=0): 107 | coords[i]=corners[j] 108 | fn=j 109 | ind[fn]=ind[fn]+1 110 | fn=-1 111 | return coords 112 | 113 | def read_data(line): 114 | poly=[] 115 | img = np.asarray(Image.open(line)) 116 | dec=0 117 | img_room_type=img[:,:,1] 118 | img_room_number=img[:,:,2] 119 | wall_img=np.zeros((256, 256)) 120 | for k in range(256): 121 | for h in range(256): 122 | if(img_room_type[k][h]==16): 123 | wall_img[k][h]=16 124 | if(img_room_type[k][h]==17): 125 | wall_img[k][h]=10 126 | room_no=img_room_number.max() 127 | room_imgs=[] 128 | rm_types=[] 129 | for i in range(room_no): 130 | room_img=np.zeros((256, 256)) 131 | for k in range(256): 132 | for h in range(256): 133 | if(img_room_number[k][h]==i+1): 134 | room_img[k][h]=1 135 | k_=k 136 | h_=h 137 | rm_t=img_room_type[k_][h_] 138 | 139 | #changing rplan rooms_type to housegan++ rooms_type 140 | if(rm_t==0): 141 | rm_types.append(1) 142 | elif(rm_t==1): 143 | rm_types.append(3) 144 | elif(rm_t==2): 145 | rm_types.append(2) 146 | elif(rm_t==3): 147 | rm_types.append(4) 148 | elif(rm_t==4): 149 | rm_types.append(7) 150 | elif(rm_t==5): 151 | rm_types.append(3) 152 | elif(rm_t==6): 153 | rm_types.append(8) 154 | elif(rm_t==7): 155 | rm_types.append(3) 156 | elif(rm_t==8): 157 | rm_types.append(3) 158 | elif(rm_t==9): 159 | rm_types.append(5) 160 | elif(rm_t==10): 161 | rm_types.append(6) 162 | elif(rm_t==11): 163 | rm_types.append(10) 164 | else: 165 | rm_types.append(16) 166 | room_imgs.append(room_img) 167 | 168 | walls=[] 169 | doors=[] 170 | rm_type=rm_types 171 | for t in range(len(room_imgs)): 172 | tmp=room_imgs[t] 173 | for k in range(254): 174 | for h in range(254): 175 | if(tmp[k][h]==1) & (tmp[k+1][h]==0) & (tmp[k+2][h]==1): 176 | tmp[k+1][h] =1 177 | for k in range(254): 178 | for h in range(254): 179 | if(tmp[h][k]==1) & (tmp[h][k+1]==0) & (tmp[h][k+2]==1): 180 | tmp[h][k+1] =1 181 | for k in range(254): 182 | for h in range(254): 183 | if(tmp[k][h]==0) & (tmp[k+1][h]==1) & (tmp[k+2][h]==0): 184 | tmp[k+1][h] =0 185 | for k in range(254): 186 | for h in range(254): 187 | if(tmp[h][k]==0) & (tmp[h][k+1]==1) & (tmp[h][k+2]==0): 188 | tmp[h][k+1] =0 189 | 190 | room_imgs[t]=tmp 191 | poly2=mr.get_polygon(room_imgs[t]) 192 | coords_1=list(poly2.exterior.coords) 193 | coords=[] 194 | for kn in range(len(coords_1)): 195 | coords.append([list(coords_1[kn])[1],list(coords_1[kn])[0],0,0,t,rm_type[t]]) 196 | p=0 197 | for c in range(len(coords)-1): 198 | walls.append([coords[c][0],coords[c][1],coords[c+1][0],coords[c+1][1],-1,coords[c][5],coords[c][4],-1,0]) 199 | p=len(coords)-1 200 | poly.append(p) 201 | tmp=img[:,:,1] 202 | 203 | 204 | door_img=np.zeros((256, 256)) 205 | doors_img=[] 206 | for k in range(256): 207 | for h in range(256): 208 | if(tmp[k][h]==17): 209 | door_img[k][h]=1 210 | 211 | tmp=door_img 212 | rms_type=rm_type 213 | coords=[] 214 | for k in range(2,254): 215 | for h in range(2,254): 216 | if(tmp[k][h]==1): 217 | if((tmp[k-1][h]==0) & (tmp[k-1][h-1]==0)&(tmp[k][h-1]==0)): 218 | coords.append([h,k,0,0]) 219 | elif (tmp[k+1][h]==0)&(tmp[k+1][h-1]==0)&(tmp[k][h-1]==0): 220 | coords.append([h,k,0,0]) 221 | elif (tmp[k+1][h]==0)&(tmp[k+1][h+1]==0)&(tmp[k][h+1]==0): 222 | coords.append([h,k,0,0]) 223 | elif (tmp[k-1][h]==0)&(tmp[k-1][h+1]==0)&(tmp[k][h+1]==0): 224 | coords.append([h,k,0,0]) 225 | elif(tmp[k+1][h]==1)&(tmp[k][h+1]==1)& (tmp[k+1][h+1]==0): 226 | coords.append([h,k,0,0]) 227 | elif(tmp[k-1][h]==1)&(tmp[k][h+1]==1)& (tmp[k-1][h+1]==0): 228 | coords.append([h,k,0,0]) 229 | elif(tmp[k+1][h]==1)&(tmp[k][h-1]==1)&(tmp[k+1][h-1]==0) : 230 | coords.append([h,k,0,0]) 231 | elif(tmp[k-1][h]==1) & (tmp[k][h-1]==1) & (tmp[k-1][h-1]==0): 232 | coords.append([h,k,0,0]) 233 | 234 | tmp_diff=1000000 235 | p_x_1=coords[0][0] 236 | for k in range(1, len(coords)): 237 | p_x_2=coords[k][0] 238 | tmp_dif=abs(p_x_1-p_x_2) 239 | if(tmp_dif1): 240 | tmp_diff=tmp_dif 241 | p_y_1=coords[0][1] 242 | for k in range(1, len(coords)): 243 | p_y_2=coords[k][1] 244 | tmp_dif=abs(p_y_1-p_y_2) 245 | if(tmp_dif1): 246 | tmp_diff=tmp_dif 247 | 248 | door_imgs=read_door(door_img,img,tmp_diff) 249 | door_no=int(door_imgs.max()) 250 | door_tp=[] 251 | for i in range(door_no): 252 | door_img=np.zeros((256, 256)) 253 | for k in range(256): 254 | for h in range(256): 255 | if(door_imgs[k][h]==i+1):door_img[k][h]=1 256 | doors_img.append(door_img) 257 | rmpn=len(doors_img) 258 | for t in range(len(doors_img)): 259 | tmp=doors_img[t] 260 | kpp=np.max(tmp) 261 | if(kpp<=0): 262 | dec=dec+1 263 | continue 264 | poly2=mr.get_polygon(doors_img[t]) 265 | coords_1=list(poly2.exterior.coords)# 266 | coords=[] 267 | for kn in range(len(coords_1)): 268 | coords.append([list(coords_1[kn])[1],list(coords_1[kn])[0],0,0,t,17]) 269 | p=0 270 | for c in range(len(coords)-1): 271 | walls.append([coords[c][0],coords[c][1],coords[c+1][0],coords[c+1][1],-1,17,len(rms_type)+coords[c][4]-dec,-1,0]) 272 | doors.append([coords[c][0],coords[c][1],coords[c+1][0],coords[c+1][1]]) 273 | p=len(coords)-1 274 | poly.append(p) 275 | tmp=img[:,:,1] 276 | en_img=np.zeros((256, 256)) 277 | for k in range(256): 278 | for h in range(256): 279 | if(tmp[k][h]==15): 280 | en_img[k][h]=1 281 | tmp=en_img 282 | coords=[] 283 | for k in range(2,254): 284 | for h in range(2,254): 285 | if(tmp[k][h]==1): 286 | if((tmp[k-1][h]==0) & (tmp[k-1][h-1]==0)&(tmp[k][h-1]==0)): 287 | coords.append([h,k,0,0]) 288 | elif (tmp[k+1][h]==0)&(tmp[k+1][h-1]==0)&(tmp[k][h-1]==0): 289 | coords.append([h,k,0,0]) 290 | elif (tmp[k+1][h]==0)&(tmp[k+1][h+1]==0)&(tmp[k][h+1]==0): 291 | coords.append([h,k,0,0]) 292 | elif (tmp[k-1][h]==0)&(tmp[k-1][h+1]==0)&(tmp[k][h+1]==0): 293 | coords.append([h,k,0,0]) 294 | elif(tmp[k+1][h]==1)&(tmp[k][h+1]==1)& (tmp[k+1][h+1]==0): 295 | coords.append([h,k,0,0]) 296 | elif(tmp[k-1][h]==1)&(tmp[k][h+1]==1)& (tmp[k-1][h+1]==0): 297 | coords.append([h,k,0,0]) 298 | elif(tmp[k+1][h]==1)&(tmp[k][h-1]==1)&(tmp[k+1][h-1]==0) : 299 | coords.append([h,k,0,0]) 300 | elif(tmp[k-1][h]==1) & (tmp[k][h-1]==1) & (tmp[k-1][h-1]==0): 301 | coords.append([h,k,0,0]) 302 | 303 | en_imgs=[] 304 | for i in range(1): 305 | 306 | door_img=np.zeros((256, 256)) 307 | for k in range(256): 308 | for h in range(256): 309 | if(en_img[k][h]==i+1): 310 | en_img[k][h]=1 311 | en_imgs.append(en_img) 312 | for t in range(len(en_imgs)): 313 | tmp=en_imgs[t] 314 | kpp=np.max(tmp) 315 | if(kpp<=0): 316 | dec=dec+1 317 | continue 318 | poly2=mr.get_polygon(en_imgs[t]) 319 | coords_1=list(poly2.exterior.coords) 320 | coords=[] 321 | for kn in range(len(coords_1)): 322 | coords.append([list(coords_1[kn])[1],list(coords_1[kn])[0],0,0,t,15]) 323 | p=0 324 | for c in range(len(coords)-1): 325 | walls.append([coords[c][0],coords[c][1],coords[c+1][0],coords[c+1][1],-1,15,rmpn+len(rms_type)+coords[c][4]-dec,-1,0]) 326 | doors.append([coords[c][0],coords[c][1],coords[c+1][0],coords[c+1][1]]) 327 | p=len(coords)-1 328 | poly.append(p) 329 | 330 | no_doors=int(len(doors)/4) 331 | rms_type=rm_type 332 | for i in range(no_doors-1): 333 | rms_type.append(17) 334 | rms_type.append(15) 335 | out=1 336 | ### check if it was noy polygon 337 | for i in range(len(poly)): 338 | if(poly[i]<4): 339 | out=-1 340 | if (len(doors)%4!=0): 341 | out=-3 342 | ##saving the name out standard (usable) layout 343 | # if(out!=1): 344 | # h.write(line) 345 | """f=open("output.txt", "a+") 346 | f.write(str(rms_type).strip('[]')) 347 | f.write(" ") 348 | f.write(str(len(rms_type))) 349 | if((len(rms_type)-no_doors)>(no_doors)): 350 | h1=open("door.txt","a+") 351 | out=-4 352 | h1.write(line)""" 353 | assert(out==1), f"error in reading the file {line}, {out=} but expected out==1" 354 | return rms_type,poly,doors,walls,out 355 | 356 | -------------------------------------------------------------------------------- /run.py: -------------------------------------------------------------------------------- 1 | import argparse 2 | import glob 3 | 4 | import subprocess 5 | import os 6 | 7 | from tqdm import tqdm 8 | 9 | 10 | RPLAN_PATH = "rplan_dataset/floorplan_dataset" 11 | 12 | def paths_to_ids(paths): 13 | return [int(path.split("/")[-1].split(".")[0]) for path in paths] 14 | 15 | 16 | 17 | def main(limit: int | None, max_processes: int): 18 | 19 | os.makedirs("rplan_json", exist_ok=True) 20 | os.makedirs("failed_rplan_json", exist_ok=True) 21 | 22 | ids = paths_to_ids(glob.glob(f"{RPLAN_PATH}/*.png")) 23 | 24 | if limit is not None: 25 | ids = ids[:limit] 26 | 27 | done_ids = paths_to_ids(glob.glob("rplan_json/*.json")) 28 | failed_ids = paths_to_ids(glob.glob("failed_rplan_json/*")) 29 | 30 | todo_ids = list(set(ids) - set(done_ids) - set(failed_ids)) 31 | 32 | print(f"{len(todo_ids)=}") 33 | 34 | 35 | # subprocess loop from: https://stackoverflow.com/a/4992640 36 | processes = set() 37 | 38 | for rplan_id in tqdm(todo_ids, smoothing=50/len(todo_ids)): 39 | command = f'python raster_to_json.py --path rplan_dataset/floorplan_dataset/{rplan_id}.png || (touch failed_rplan_json/{rplan_id} && false)' 40 | 41 | processes.add(subprocess.Popen(command, shell=True)) 42 | if len(processes) >= max_processes: 43 | os.wait() 44 | processes.difference_update([ 45 | p for p in processes if p.poll() is not None]) 46 | 47 | 48 | if __name__ == "__main__": 49 | 50 | argparser = argparse.ArgumentParser() 51 | 52 | argparser.add_argument("--limit", type=int, default=None) 53 | argparser.add_argument("--max_processes", type=int, default=8) 54 | 55 | args = argparser.parse_args() 56 | 57 | main(limit=args.limit, max_processes=args.max_processes) 58 | -------------------------------------------------------------------------------- /sample_output/0.json: -------------------------------------------------------------------------------- 1 | {"room_type": [3, 4, 1, 3, 2, 5, 17, 17, 17, 17, 17, 15], "boxes": [[72.0, 161.0, 124.0, 220.0], [72.0, 130.0, 107.0, 157.0], [111.0, 28.0, 184.0, 203.0], [72.0, 87.0, 124.0, 126.0], [115.0, 53.0, 144.0, 83.0], [128.0, 207.0, 184.0, 228.0], [108.0, 145.0, 110.0, 155.0], [114.0, 158.0, 125.0, 160.0], [114.0, 127.0, 124.0, 129.0], [145.0, 60.0, 147.0, 84.0], [134.0, 204.0, 178.0, 206.0], [165.0, 38.0, 167.0, 52.0]], "edges": [[72.0, 161.0, 72.0, 220.0, 3, 0], [72.0, 220.0, 124.0, 220.0, 3, 0], [124.0, 220.0, 124.0, 161.0, 3, 0], [124.0, 161.0, 72.0, 161.0, 3, 1], [72.0, 130.0, 72.0, 157.0, 4, 0], [72.0, 157.0, 107.0, 157.0, 4, 0], [107.0, 157.0, 107.0, 130.0, 4, 1], [107.0, 130.0, 72.0, 130.0, 4, 0], [148.0, 28.0, 148.0, 87.0, 1, 2], [148.0, 87.0, 128.0, 87.0, 1, 0], [128.0, 87.0, 128.0, 130.0, 1, 0], [128.0, 130.0, 111.0, 130.0, 1, 3], [111.0, 130.0, 111.0, 157.0, 1, 4], [111.0, 157.0, 128.0, 157.0, 1, 3], [128.0, 157.0, 128.0, 203.0, 1, 0], [128.0, 203.0, 184.0, 203.0, 1, 5], [184.0, 203.0, 184.0, 87.0, 1, 0], [184.0, 87.0, 164.0, 87.0, 1, 0], [164.0, 87.0, 164.0, 28.0, 1, 0], [164.0, 28.0, 148.0, 28.0, 1, 0], [72.0, 87.0, 72.0, 126.0, 3, 0], [72.0, 126.0, 124.0, 126.0, 3, 1], [124.0, 126.0, 124.0, 87.0, 3, 0], [124.0, 87.0, 72.0, 87.0, 3, 0], [115.0, 53.0, 115.0, 83.0, 2, 0], [115.0, 83.0, 144.0, 83.0, 2, 0], [144.0, 83.0, 144.0, 53.0, 2, 1], [144.0, 53.0, 115.0, 53.0, 2, 0], [128.0, 207.0, 128.0, 228.0, 5, 0], [128.0, 228.0, 184.0, 228.0, 5, 0], [184.0, 228.0, 184.0, 207.0, 5, 0], [184.0, 207.0, 128.0, 207.0, 5, 1], [108.0, 145.0, 108.0, 155.0, 17, 4], [108.0, 155.0, 110.0, 155.0, 17, 0], [110.0, 155.0, 110.0, 145.0, 17, 1], [110.0, 145.0, 108.0, 145.0, 17, 0], [114.0, 158.0, 114.0, 160.0, 17, 0], [114.0, 160.0, 125.0, 160.0, 17, 3], [125.0, 160.0, 125.0, 158.0, 17, 0], [125.0, 158.0, 114.0, 158.0, 17, 1], [114.0, 127.0, 114.0, 129.0, 17, 0], [114.0, 129.0, 124.0, 129.0, 17, 1], [124.0, 129.0, 124.0, 127.0, 17, 3], [124.0, 127.0, 114.0, 127.0, 17, 0], [145.0, 60.0, 145.0, 84.0, 17, 2], [145.0, 84.0, 147.0, 84.0, 17, 0], [147.0, 84.0, 147.0, 60.0, 17, 1], [147.0, 60.0, 145.0, 60.0, 17, 0], [134.0, 204.0, 134.0, 206.0, 17, 0], [134.0, 206.0, 178.0, 206.0, 17, 5], [178.0, 206.0, 178.0, 204.0, 17, 0], [178.0, 204.0, 134.0, 204.0, 17, 1], [165.0, 38.0, 165.0, 52.0, 15, 1], [165.0, 52.0, 167.0, 52.0, 15, 0], [167.0, 52.0, 167.0, 38.0, 15, 0], [167.0, 38.0, 165.0, 38.0, 15, 0]], "ed_rm": [[0], [0], [0], [0, 2], [1], [1], [1, 2], [1], [2, 4], [2], [2], [2, 3], [2, 1], [2, 0], [2], [2, 5], [2], [2], [2], [2], [3], [3, 2], [3], [3], [4], [4], [4, 2], [4], [5], [5], [5], [5, 2], [6, 1], [6], [6, 2], [6], [7], [7, 0], [7], [7, 2], [8], [8, 2], [8, 3], [8], [9, 4], [9], [9, 2], [9], [10], [10, 5], [10], [10, 2], [11, 2], [11], [11], [11]]} --------------------------------------------------------------------------------