-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add test infrastructure for cpp decoder
- Loading branch information
1 parent
c8b5325
commit 901eeac
Showing
5 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
all: | ||
g++ -lzfp -Izfp-1.0.0/include -std=c++14 main.cpp -o test |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#include "zfp.hpp" | ||
#include "zfpc.hpp" | ||
#include <cstdio> | ||
|
||
|
||
#include <fstream> | ||
#include <sstream> | ||
#include <string> | ||
|
||
std::string slurp(const char *filename) { | ||
std::ifstream in; | ||
in.open(filename, std::ifstream::in | std::ifstream::binary); | ||
std::stringstream sstr; | ||
sstr << in.rdbuf(); | ||
in.close(); | ||
return sstr.str(); | ||
} | ||
|
||
|
||
int main () { | ||
std::string data = slurp("/Users/wms/code/zfpc/wasm/0-128_0-128_0-10"); | ||
|
||
|
||
size_t voxels = 128 * 128 * 10 * 2; | ||
float* out = new float[voxels](); | ||
const unsigned char* ptr = reinterpret_cast<unsigned char*>(const_cast<char*>(data.c_str())); | ||
|
||
int err = zfpc::decompress(ptr, data.size(), out, voxels * 4); | ||
|
||
std::ofstream f; | ||
f.open("/Users/wms/code/zfpc/wasm/0-128_0-128_0-10.raw"); | ||
|
||
unsigned char* outc = reinterpret_cast<unsigned char*>(out); | ||
|
||
for (int i = 0; i < voxels * 4; i++) { | ||
f << outc[i]; | ||
} | ||
|
||
f.close(); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import numpy as np | ||
from cloudvolume import view | ||
import zfpy | ||
|
||
data = open("0-128_0-128_0-10-1.zfp", "rb").read() | ||
img = zfpy.decompress_numpy(data) | ||
|
||
print(img) | ||
view(img, port=8081) |