33import numpy as np
44cimport numpy as np
55
6- cdef extern from " ../ThreatExchange/hashing/ pdq/cpp/common/pdqhashtypes.cpp" namespace " facebook::pdq::hashing" :
6+ cdef extern from " pdq/cpp/common/pdqhashtypes.cpp" namespace " facebook::pdq::hashing" :
77 cdef struct Hash256:
88 unsigned short w[16 ]
99
1010
11- cdef extern from " ../ThreatExchange/hashing/ pdq/cpp/hashing/pdqhashing.cpp" namespace " facebook::pdq::hashing" :
11+ cdef extern from " pdq/cpp/hashing/pdqhashing.cpp" namespace " facebook::pdq::hashing" :
1212 void pdqHash256FromFloatLuma(
1313 float * fullBuffer1,
1414 float * fullBuffer2,
@@ -21,7 +21,7 @@ cdef extern from "../ThreatExchange/hashing/pdq/cpp/hashing/pdqhashing.cpp" name
2121 int & quality
2222 )
2323
24- cdef extern from " ../ThreatExchange/hashing/ pdq/cpp/hashing/pdqhashing.cpp" namespace " facebook::pdq::hashing" :
24+ cdef extern from " pdq/cpp/hashing/pdqhashing.cpp" namespace " facebook::pdq::hashing" :
2525 void pdqFloat256FromFloatLuma(
2626 float * fullBuffer1,
2727 float * fullBuffer2,
@@ -33,7 +33,7 @@ cdef extern from "../ThreatExchange/hashing/pdq/cpp/hashing/pdqhashing.cpp" name
3333 int & quality
3434 )
3535
36- cdef extern from " ../ThreatExchange/hashing/ pdq/cpp/hashing/pdqhashing.cpp" namespace " facebook::pdq::hashing" :
36+ cdef extern from " pdq/cpp/hashing/pdqhashing.cpp" namespace " facebook::pdq::hashing" :
3737 void pdqDihedralHash256esFromFloatLuma(
3838 float * fullBuffer1,
3939 float * fullBuffer2,
@@ -54,14 +54,14 @@ cdef extern from "../ThreatExchange/hashing/pdq/cpp/hashing/pdqhashing.cpp" name
5454 int & quality
5555 )
5656
57- cdef extern from " ../ThreatExchange/hashing/ pdq/cpp/downscaling/downscaling.cpp" namespace " facebook::pdq::downscaling" :
57+ cdef extern from " pdq/cpp/downscaling/downscaling.cpp" namespace " facebook::pdq::downscaling" :
5858 int computeJaroszFilterWindowSize(int oldDimension, int newDimension)
5959
60- cdef extern from " ../ThreatExchange/hashing/ pdq/cpp/hashing/torben.cpp" namespace " facebook::pdq::hashing" :
60+ cdef extern from " pdq/cpp/hashing/torben.cpp" namespace " facebook::pdq::hashing" :
6161 float torben(float m[], int n)
6262
6363def hash_to_vector (hash_value ):
64- return np.array([(hash_value[(k & 255 ) >> 4 ] >> (k & 15 )) & 1 for k in range (256 )]).reshape( 16 , 16 )[:, :: - 1 ].flatten()
64+ return np.array([(hash_value[(k & 255 ) >> 4 ] >> (k & 15 )) & 1 for k in range (256 )])[:: - 1 ]
6565
6666def compute (np.ndarray[char , ndim = 3 ] image):
6767 cdef np.ndarray[float , ndim= 2 ] gray = (image[:, :, 0 ]* 0.299 + image[:, :, 1 ]* 0.587 + image[:, :, 2 ] * 0.114 ).astype(' float32' )
@@ -109,7 +109,7 @@ def compute_float(np.ndarray[char, ndim=3] image):
109109 buffer16x64,
110110 buffer16x16,
111111 quality)
112- return np.array(buffer16x16)[:, :: - 1 ].flatten() , quality
112+ return np.array(buffer16x16).flatten()[:: - 1 ], quality
113113
114114def compute_dihedral (np.ndarray[char , ndim = 3 ] image):
115115 cdef np.ndarray[float , ndim= 2 ] gray = (image[:, :, 0 ]* 0.299 + image[:, :, 1 ]* 0.587 + image[:, :, 2 ] * 0.114 ).astype(' float32' )
0 commit comments