Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
qianyizh committed Jul 20, 2017
0 parents commit 079d9b0
Show file tree
Hide file tree
Showing 384 changed files with 49,779 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.rar filter=lfs diff=lfs merge=lfs -text
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2017 Qianyi Zhou

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# UrbanReconstruction

Automatic 3D Urban Modeling from City-scale Aerial LiDAR Data

![alt text](project_urban.jpg "Project logo")

## Introduction

UrbanReconstruction is the research project I developed during my PhD at the University of Southern California a long time ago. The technique is based on my PhD thesis:

3D Urban Modeling from City-scale Aerial LiDAR Data
Qian-Yi Zhou
PhD Thesis (Advisor: Ulrich Neumann)

See the [project page](http://qianyi.info/urban.html) for a complete list of publications related to this project.

## Usage

The project is ancient. I am not intending to provide support. You are at your own risk.

For quick start, find the prebuilt package under the [prebuild-win32](prebuilt-win32) folder. It includes executables, testing data, detailed documentation, and a demo video. The executables run on Windows platform. If you work on Linux or OS X, [Wine](https://www.winehq.org/) may help you.

The [src](src) folder includes the source code of the entire project. The code was ancient. I developed it with Visual Studio 2008. A modern [Visual Studio](https://www.visualstudio.com/) *should* be able to convert the project into a modern format and compile it. There might be some OpenGL or GUI related code that causes compilation problems. However, this project is a pure console program except the visualization and debugging tool called "huma". If it causes problem, just remove it.

The [src_dualcontouring](src_dualcontouring) includes the source code of the [2.5D Dual Contouring](http://qianyi.info/docs/papers/eccv10_dualcontouring.pdf) paper. It is a duplicate of [src/BldRecons/DualContouring](src/BldRecons/DualContouring), but can be compiled standalone.

## License

The source code is released under the MIT license. You can do anything with the code with proper attribution. I developed this project in hope it will be useful. Please let me ([Qianyi.Zhou@gmail.com](mailto:Qianyi.Zhou@gmail.com)) and Professor Neumann ([uneumann@usc.edu](mailto:uneumann@usc.edu)) know if you are doing anything interesting with it.

See [LICENSE](LICENSE) file for details.

## Help Wanted

The code is in good shape, and I believe it is still useful somewhere. However, I do not have the bandwidth to maintain this project. If you are willing to contribute, [contact me](mailto:Qianyi.Zhou@gmail.com), or submit [issues](https://github.com/qianyizh/UrbanReconstruction/issues) and [pull requests](https://github.com/qianyizh/UrbanReconstruction/pulls).

The current most immediate enhancement is to migrate UrbanReconstruction into a CMake build system and make it cross-platform. Please contact me if you can provide help for this.
3 changes: 3 additions & 0 deletions prebuilt-win32/mod-11.07-win32.rar
Git LFS file not shown
Binary file added project_urban.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions src/BldRecons/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/*.ncb
/*.suo
/Debug/
/Release/
3 changes: 3 additions & 0 deletions src/BldRecons/BPFitPlane/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/Debug/
/Release/
/*.user
70 changes: 70 additions & 0 deletions src/BldRecons/BPFitPlane/BPCloud.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#include "StdAfx.h"
#include "BPCloud.h"

CBPCloud::CBPCloud(void)
{
}

CBPCloud::~CBPCloud(void)
{
}

void CBPCloud::LoadFromBP( char filename[] )
{

m_cReader.OpenFile( filename );
BPHeader header = m_cReader.ReadHeader();

m_n64Patch = header.patch;
m_dbGridLength = header.grid_length;
m_dbGroundZ = header.ground_z;
m_cBoundingBox.Reset();

m_vecPoint.clear();
m_vecPoint.resize( header.number );

for ( int i = 0; i < header.number; i++ ) {
BPPoint point = m_cReader.ReadPoint();

m_vecPoint[ i ].type = PT_Building;
m_vecPoint[ i ].patch.base = point.plane;
m_vecPoint[ i ].patch.num = 0;
m_vecPoint[ i ].v = CVector3D( point.pos );
m_vecPoint[ i ].n = CVector3D( point.n );
m_vecPoint[ i ].flatness = point.flatness;

m_cBoundingBox.Push( m_vecPoint[ i ].v );
}

m_cReader.CloseFile();

m_nUnitNumber[ 0 ] = ( int )( m_cBoundingBox.GetLength( 0 ) / m_dbGridLength ) + 3;
m_nUnitNumber[ 1 ] = ( int )( m_cBoundingBox.GetLength( 1 ) / m_dbGridLength ) + 3;

}

void CBPCloud::SaveToBP( char filename[] )
{

m_cWriter.OpenFile( filename );

m_cWriter.WriteHeader( m_n64Patch, ( int )m_vecPoint.size(), m_dbGroundZ, m_dbGridLength );

for ( int i = 0; i < ( int )m_vecPoint.size(); i++ ) {
BPPoint point;

point.plane = m_vecPoint[ i ].patch.base;
point.flatness = m_vecPoint[ i ].flatness;
point.pos[ 0 ] = m_vecPoint[ i ].v[ 0 ];
point.pos[ 1 ] = m_vecPoint[ i ].v[ 1 ];
point.pos[ 2 ] = m_vecPoint[ i ].v[ 2 ];
point.n[ 0 ] = m_vecPoint[ i ].n[ 0 ];
point.n[ 1 ] = m_vecPoint[ i ].n[ 1 ];
point.n[ 2 ] = m_vecPoint[ i ].n[ 2 ];

m_cWriter.WritePoint( point );
}

m_cWriter.CloseFile();

}
28 changes: 28 additions & 0 deletions src/BldRecons/BPFitPlane/BPCloud.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#pragma once

#include "Geometry\BoundingBox.h"
#include "Geometry\Outline.h"
#include "Lidar\LidarCommon.h"
#include "Miscs\BPReader.h"
#include "Miscs\BPWriter.h"

class CBPCloud
{
public:
CBPCloud(void);
~CBPCloud(void);

public:
std::vector< PatchPointData > m_vecPoint;
CBPReader m_cReader;
CBPWriter m_cWriter;
CBoundingBox m_cBoundingBox;
PatchIndex m_n64Patch;
double m_dbGridLength;
double m_dbGroundZ;
int m_nUnitNumber[ 2 ];

public:
void LoadFromBP( char filename[] );
void SaveToBP( char filename[] );
};
58 changes: 58 additions & 0 deletions src/BldRecons/BPFitPlane/BPFitPlane.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// BPFitPlane.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "ParamManager.h"
#include "BPCloud.h"
#include "BPGrid.h"

void main(int argc, char * argv[])
{

CParamManager * manager = CParamManager::GetParamManager();
manager->RegisterCommandLine( argc, argv );

char pSearch[ 1024 ];
sprintf_s( pSearch, 1024, "%s*.bp", manager->m_pWorkingDir );

WIN32_FIND_DATA finder;
HANDLE handle = FindFirstFile( pSearch, & finder );
BOOL not_finished = ( handle != INVALID_HANDLE_VALUE );

while ( not_finished ) {

if ( strcmp( finder.cFileName, "." ) != 0 && strcmp( finder.cFileName, ".." ) != 0 ) {

if ( ( finder.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) != FILE_ATTRIBUTE_DIRECTORY ) {

fprintf_s( stderr, "Processing %s ... ", finder.cFileName );

char filename[ 1024 ];
memset( filename, 0, 1024 );
sprintf_s( filename, 1024, "%s%s", manager->m_pWorkingDir, finder.cFileName );
CBPCloud cloud;
CBPGrid grid( & cloud );
cloud.LoadFromBP( filename );

grid.BuildGridIndex();
grid.PlaneFitting_RegionGrow();
grid.GenerateOutline();

cloud.SaveToBP( filename );

sprintf_s( filename, 1024, "%s%so", manager->m_pWorkingDir, finder.cFileName );
grid.WriteOutline( filename );

fprintf_s( stderr, "done.\n" );

}

not_finished = FindNextFile( handle, &finder );

}

}

FindClose( handle );

}
Loading

0 comments on commit 079d9b0

Please sign in to comment.