Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Sun committed Aug 1, 2019
2 parents ef45f6e + 0062694 commit 272084c
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 5 deletions.
2 changes: 1 addition & 1 deletion hashing/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Please see:

* [Facebook Newsroom post on the open-source release of TMK+PDQF and PDQ](https://newsroom.fb.com/news/2019/08/link-name-tbd])
* [Facebook Newsroom post on the open-source release of TMK+PDQF and PDQ](https://newsroom.fb.com/news/2019/08/open-source-photo-video-matching])
* [Detailed information on algorithm sketch, details, and evaluation](https://github.com/facebook/ThreatExchange/blob/master/hashing/hashing.pdf)
* [Implementation and setup information about TMK+PDQF](https://github.com/facebook/ThreatExchange/blob/master/hashing/tmk/README.md)
* [Implementation and setup information about PDQ](https://github.com/facebook/ThreatExchange/blob/master/hashing/pdq/README.md)
2 changes: 1 addition & 1 deletion hashing/pdq/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ as well as
[../hashing.pdf](https://github.com/facebook/ThreatExchange/blob/master/hashing/hashing.pdf)
within this repository.

See also https://newsroom.fb.com/news/2019/08/to-do-add-this-link-once-published for context.
See also https://newsroom.fb.com/news/2019/08/open-source-photo-video-matching for context.

As of November 2018 there are C++, PHP, and Java implementations. Details are in the `*/README.md` files.

Expand Down
8 changes: 6 additions & 2 deletions hashing/pdq/cpp/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ CCDBG=$(CC) -g $(CFLAGS) $(IFLAGS) $(WFLAGS)
CCSAN=clang -fsanitize=address -g $(CFLAGS) $(IFLAGS) $(WFLAGS)

# ================================================================
# Please replace CImg.h with your own system image-decoder and edit
# io/pdqio.cpp.
LIBHDRS=\
common/pdqbasetypes.h \
common/pdqhashtypes.h \
Expand All @@ -19,7 +21,8 @@ LIBHDRS=\
downscaling/downscaling.h \
io/pdqio.h \
index/mih.h \
hashing/torben.h
hashing/torben.h \
./CImg.h

LIBSRCS=\
common/pdqhashtypes.cpp \
Expand Down Expand Up @@ -73,11 +76,12 @@ test-hamming: bin/test-hamming.cpp $(LIBSRCS) $(LIBHDRS)

pdq-photo-hasher: bin/pdq-photo-hasher.cpp $(LIBSRCS) $(LIBHDRS)
$(CCOPT) bin/pdq-photo-hasher.cpp $(LIBSRCS) -o pdq-photo-hasher $(LFLAGS)

# Profile version. Usage:
# * make pdq-photo-hasher-prof
# * pdq-photo-hasher-prof {arguments>
# * gprof pdq-photo-hasher-prof gmon.out > myfile.txt
# Note: works on Linux; not on OSX.
# Note: this profiler command works on Linux; not on OSX.
pdq-photo-hasher-prof: bin/pdq-photo-hasher.cpp $(LIBSRCS) $(LIBHDRS)
$(CCDBG) -pg bin/pdq-photo-hasher.cpp $(LIBSRCS) -o pdq-photo-hasher-prof $(LFLAGS) -lpthread

Expand Down
1 change: 1 addition & 0 deletions hashing/pdq/cpp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Please see `../README.md` and `../../README.md` for context, and `../../hashing.

* C++ 11 or higher
* `CImg.h` is included for reference, although note that its license does not allow commercial use. It is expected that your company will already have image-processing logic. Dependencies of this code on `CImg.h` are confined solely to `io/pdqio.h` and `io/pdqio.cpp` which you can customize for your site.
* ImageMagick or other JPEG/PNG libraries: for example, `brew install imagemagick` on MacOSX

# Contact

Expand Down
5 changes: 5 additions & 0 deletions hashing/pdq/cpp/bin/pdq-photo-hasher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ static void usage(char* argv0, int rc) {
fp,
"-k: Continue to next image after image errors, but still exit "
"1 afterward.\n");
fprintf(fp, "--info: show information about the image-decoder library.\n");
exit(rc);
}

Expand All @@ -69,6 +70,10 @@ int main(int argc, char* argv[]) {
} else if (!strcmp(argv[argi], "--help")) {
usage(argv[0], 0);

} else if (!strcmp(argv[argi], "--info")) {
showDecoderInfo();
exit(0);

} else if (
!strcmp(argv[argi], "-i") || !strcmp(argv[argi], "--files-on-stdin")) {
files_on_stdin = true;
Expand Down
5 changes: 5 additions & 0 deletions hashing/pdq/cpp/io/pdqio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ namespace hashing {
// so we use off-the-shelf downsampling to get to an intermediate size.
const int DOWNSAMPLE_DIMS = 512;

// ----------------------------------------------------------------
void showDecoderInfo() {
cimg_library::cimg::info();
}

// ----------------------------------------------------------------
// Returns matrix as num_rows x num_cols in row-major order.
// The caller must free the return value.
Expand Down
2 changes: 2 additions & 0 deletions hashing/pdq/cpp/io/pdqio.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ float* loadFloatLumaFromCImg(
int& numCols
);

void showDecoderInfo();

bool pdqHash256FromFile(
const char* filename,
Hash256& hash,
Expand Down
2 changes: 1 addition & 1 deletion hashing/tmk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ produced in conjunction with Facebook AI Research ('FAIR').

* Full details are located in the [hashing.pdf](https://github.com/facebook/ThreatExchange/blob/master/hashing/hashing.pdf) document.

* See https://newsroom.fb.com/news/2019/08/to-do-add-this-link-once-published for context.
* See https://newsroom.fb.com/news/2019/08/open-source-photo-video-matching for context.

* Researchers in video copy-detection algorithms may also be interested in
https://github.com/facebookresearch/videoalignment for a research version of
Expand Down

0 comments on commit 272084c

Please sign in to comment.