Skip to content

Commit

Permalink
Improve readme and add date filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
TheGreatRambler committed Apr 12, 2023
1 parent 851f528 commit b66284e
Show file tree
Hide file tree
Showing 7 changed files with 175 additions and 52 deletions.
53 changes: 48 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,63 @@ A reverse engineered Google Maps streetview client in C++ that lets you download
# Usage
```
Download panoramas
Usage: ./streetview_client download [OPTIONS]
Usage: ./streetview_client download [OPTIONS] [SUBCOMMAND]
Options:
-h,--help Print this help message and exit
--lat FLOAT REQUIRED Latitude
--long FLOAT REQUIRED Longitude
-r,--range INT Range from location
-r,--range INT Range from location, unit not known
--month-start INT Starting month
--month-end INT Ending month (inclusive)
--year-start INT Starting year
--year-end INT Ending year (inclusive)
--path-format TEXT Path format, not including the extension. Supports {id}, {year}, {month}, {lat}, {long}, {street}, {city}
-n,--num-panoramas INT Number of panoramas to attempt to download
-z,--zoom INT How much to zoom in street view images, higher numbers increase resolution
-z,--zoom INT Dimensions of street view images, higher numbers increase resolution. Usually 1=832x416, 2=1664x832, 3=3328x1664, 4=6656x3328, 5=13312x6656 (glitched at the poles)
-j,--json Include JSON info alongside panorama
Render panoramas
Subcommands:
recursive Recursively attempt to download nearby panoramas
```

```
Recursively attempt to download nearby panoramas
Usage: ./streetview_client download recursive [OPTIONS]
Options:
-h,--help Print this help message and exit
-a,--num-attempts INT Number of recursive attempts to download more images
-r,--radius FLOAT Radius of images to download in latitude degrees
```

```
Render panoramas in viewer
Usage: ./streetview_client render [OPTIONS]
Options:
-h,--help Print this help message and exit
-i,--id TEXT REQUIRED Initial panorama ID
```
-z,--zoom INT Dimensions of street view images, same as download -z
--month-start INT Starting month
--month-end INT Ending month (inclusive)
--year-start INT Starting year
--year-end INT Ending year (inclusive)
```

# Client
`./streetview_client render` is a simplified Streetview client that allows you to look around and navigate to adjacent panoramas. Look around with drag, zoom in with scroll and move to adjacent panoramas with the up arrow. `./streetview_client download` is a quick downloader that directly downloads panoramas around a location. `./streetview_client download recursive` is a quick downloader that repeatedly requests panoramas close to a location in order to download every single panorama in a radius.

# Example commands
```
./streetview_client download --lat 42.360017 --long -71.058284 --path-format panoramas_boston/{id}-{street}-{year}-{month} -z 2 -n 1000
```
This command will attempt to download 1000 panoramas around Boston with their id, street, year and month in the filename with dimensions of 1664x832.
```
./streetview_client download --lat 52.08855495179819 --long 5.124632840963613 --path-format panoramas_utrecht/{id} -z 4 recursive -a 100 -r 0.00005
```
This command will attempt to recursively download nearby panoramas around Utrecht, Netherlands 100 times in a radius of approximately 18.2 feet (there are approximately 364,000 feet in a latitude degree and 0.00005 * 364,000 = 18.2) with dimensions of 6656x3328.
```
./streetview_client render -z 2 -i 7RP3sV6czwHDli2hSTkB8A
```
This command will allow you to walk around in Boston with panoramas of dimension 1664x832.
6 changes: 6 additions & 0 deletions photogrammetry.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
openMVG_main_SfMInit_ImageListing -i tiles -o matches -c 7 -f 1
openMVG_main_ComputeFeatures -i matches/sfm_data.json -o matches -m SIFT -p HIGH
openMVG_main_ComputeMatches -i matches/sfm_data.json -o matches/matches_putative.bin -p matches/matching_pairs.txt -n HNSWL1
openMVG_main_GeometricFilter -i matches/sfm_data.json -o matches/matches_refined.bin -m matches/matches_putative.bin -g a
openMVG_main_SfM -i matches/sfm_data.json -M matches/matches_refined.bin -o recon -s INCREMENTAL
openMVG_main_sfmViewer -i recon/sfm_data.bin
25 changes: 23 additions & 2 deletions src/extract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#define _USE_MATH_DEFINES
#define DEG_RAD 0.0174533

#include <fmt/format.h>
#include <rapidjson/prettywriter.h>
#include <rapidjson/reader.h>
#include <rapidjson/stringbuffer.h>
Expand Down Expand Up @@ -96,18 +97,38 @@ double center_distance(double lat, double lng, Panorama& panorama) {
return std::sqrt(std::pow(panorama.lat - lat, 2) + std::pow(panorama.lng - lng, 2));
}

int num_within_distance(double lat, double lng, double radius, std::vector<Panorama>& panoramas) {
int num_within_distance_and_date(double lat, double lng, double radius, int year_start,
int year_end, int month_start, int month_end, std::vector<Panorama>& panoramas) {
int num = 0;
for(auto& panorama : panoramas) {
if(center_distance(lat, lng, panorama) <= radius) {
if(is_within_distance_and_date(
lat, lng, radius, year_start, year_end, month_start, month_end, panorama)) {
num++;
}
}
return num;
}

bool is_within_distance_and_date(double lat, double lng, double radius, int year_start,
int year_end, int month_start, int month_end, Panorama& panorama) {
return center_distance(lat, lng, panorama) <= radius && panorama.month >= month_start
&& panorama.month <= month_end && panorama.year >= year_start
&& panorama.year <= year_end;
}

bool is_within_date(
int year_start, int year_end, int month_start, int month_end, Panorama& panorama) {
return panorama.month >= month_start && panorama.month <= month_end
&& panorama.year >= year_start && panorama.year <= year_end;
;
}

void sort_by_distance(double lat, double lng, std::vector<Panorama>& panoramas) {
std::sort(panoramas.begin(), panoramas.end(), [&](Panorama& a, Panorama& b) {
return center_distance(lat, lng, a) < center_distance(lat, lng, b);
});
}

bool is_date_specified(int year_start, int year_end, int month_start, int month_end) {
return !(year_start == -1 && year_end == 10000 && month_start == -1 && month_end == 10000);
}
10 changes: 8 additions & 2 deletions src/extract.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,11 @@ std::pair<double, double> extract_tiles_dimensions(
rapidjson::Document& photometa_document, int streetview_zoom);
bool valid_photometa(rapidjson::Document& photometa_document);
double center_distance(double lat, double lng, Panorama& panorama);
int num_within_distance(double lat, double lng, double radius, std::vector<Panorama>& panoramas);
void sort_by_distance(double lat, double lng, std::vector<Panorama>& panoramas);
int num_within_distance_and_date(double lat, double lng, double radius, int year_start,
int year_end, int month_start, int month_end, std::vector<Panorama>& panoramas);
bool is_within_distance_and_date(double lat, double lng, double radius, int year_start,
int year_end, int month_start, int month_end, Panorama& panorama);
bool is_within_date(
int year_start, int year_end, int month_start, int month_end, Panorama& panorama);
void sort_by_distance(double lat, double lng, std::vector<Panorama>& panoramas);
bool is_date_specified(int year_start, int year_end, int month_start, int month_end);
37 changes: 31 additions & 6 deletions src/interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,17 @@

#include "download.hpp"

InterfaceWindow::InterfaceWindow(std::string initial_panorama_id, CURL* curl_handle) {
InterfaceWindow::InterfaceWindow(std::string initial_panorama_id, int zoom, CURL* curl_handle,
int year_start, int year_end, int month_start, int month_end)
: year_start(year_start)
, year_end(year_end)
, month_start(month_start)
, month_end(month_end)
, client_id(client_id)
, curl_handle(curl_handle) {
// Start preloader
preloader.SetClientId(download_client_id(curl_handle));
preloader.SetZoom(1);
preloader.SetZoom(zoom);
preloader.SetCurlHandle(curl_handle);
preloader.Start(5);

Expand Down Expand Up @@ -167,7 +174,25 @@ void InterfaceWindow::DrawFrame() {
void InterfaceWindow::ChangePanorama(std::string id) {
panorama_info = preloader.GetPanorama(id, true);
current_panorama = extract_info(panorama_info->photometa);
adjacent = extract_adjacent_panoramas(panorama_info->photometa);
fmt::print("Lat: {} Long: {}\n", current_panorama.lat, current_panorama.lng);
auto unfiltered_adjacent = extract_adjacent_panoramas(panorama_info->photometa);

// Filter adjacent to year and month range
adjacent.clear();
for(auto& panorama : unfiltered_adjacent) {
if(!is_date_specified(year_start, year_end, month_start, month_end)) {
// Just add it, much faster
adjacent.push_back(panorama);
} else {
// Have to download date
auto photometa_document = download_photometa(curl_handle, client_id, panorama.id);
panorama = extract_info(photometa_document);
if(is_within_date(year_start, year_end, month_start, month_end, panorama)) {
adjacent.push_back(panorama);
}
}
}

PrepareShader();
}

Expand Down Expand Up @@ -266,9 +291,9 @@ void InterfaceWindow::PrepareShader() {
const float PI_2 = 3.14159265358979323846264 * 0.5;
vec3 rotateXY(vec3 p, vec2 angle) {
vec2 c = cos(angle), s = sin(angle);
p = vec3(p.x, c.x*p.y + s.x*p.z, -s.x*p.y + c.x*p.z);
return vec3(c.y*p.x + s.y*p.z, p.y, -s.y*p.x + c.y*p.z);
vec2 c = cos(angle), s = sin(angle);
p = vec3(p.x, c.x*p.y + s.x*p.z, -s.x*p.y + c.x*p.z);
return vec3(c.y*p.x + s.y*p.z, p.y, -s.y*p.x + c.y*p.z);
}
float4 main(float2 fragCoord) {
Expand Down
9 changes: 8 additions & 1 deletion src/interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@

class InterfaceWindow {
public:
InterfaceWindow(std::string initial_panorama_id, CURL* curl_handle);
InterfaceWindow(std::string initial_panorama_id, int zoom, CURL* curl_handle, int year_start,
int year_end, int month_start, int month_end);

bool PrepareWindow();
void DrawFrame();
Expand Down Expand Up @@ -68,6 +69,12 @@ class InterfaceWindow {
const int map_height = 800;
const double map_scale = 500000.0;

int year_start;
int year_end;
int month_start;
int month_end;
std::string client_id;

// Panorama variables
CURL* curl_handle;
PanoramaPreloader preloader;
Expand Down
Loading

0 comments on commit b66284e

Please sign in to comment.