Skip to content

Commit

Permalink
Merge pull request spmallick#26 from vaibhawchandel/master
Browse files Browse the repository at this point in the history
Faster Selective Search
  • Loading branch information
spmallick authored Sep 19, 2017
2 parents a2454d4 + 29f371a commit e0afc12
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
8 changes: 8 additions & 0 deletions SelectiveSearch/ssearch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,16 @@ int main(int argc, char** argv) {
return -1;
}

// speed-up using multithreads
setUseOptimized(true);
setNumThreads(4);

// read image
Mat im = imread(argv[1]);
// resize image
int newHeight = 200;
int newWidth = im.cols*newHeight/im.rows;
resize(im, im, Size(newWidth, newHeight));

// create Selective Search Segmentation Object using default parameters
Ptr<SelectiveSearchSegmentation> ss = createSelectiveSearchSegmentation();
Expand Down
9 changes: 8 additions & 1 deletion SelectiveSearch/ssearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
'''

import sys
sys.path.insert(0, '/opt/lib/python3.5/dist-packages')
import cv2

if __name__ == '__main__':
Expand All @@ -17,8 +16,16 @@
print(__doc__)
sys.exit(1)

# speed-up using multithreads
cv2.setUseOptimized(True);
cv2.setNumThreads(4);

# read image
im = cv2.imread(sys.argv[1])
# resize image
newHeight = 200
newWidth = int(im.shape[1]*200/im.shape[0])
im = cv2.resize(im, (newWidth, newHeight))

# create Selective Search Segmentation Object using default parameters
ss = cv2.ximgproc.segmentation.createSelectiveSearchSegmentation()
Expand Down

0 comments on commit e0afc12

Please sign in to comment.