@@ -4,29 +4,29 @@ require 'cv.imgcodecs'
4
4
require ' cv.highgui'
5
5
6
6
if not arg [1 ] then
7
- print (' Usage: `th demo/descriptors.lua path-to-image`' )
7
+ print (' ` Usage: `th demo/descriptors.lua path-to-image`' )
8
8
print (' Now using demo/data/lena.jpg' )
9
9
end
10
10
11
11
local image = cv .imread {arg [1 ] or ' demo/data/lena.jpg' }
12
12
13
- if not image then
14
- print (" Problem loading image\n " )
13
+ if image : nDimension () == 0 then
14
+ print (' Problem loading image\n ' )
15
15
os.exit (0 )
16
16
end
17
17
18
- cv .namedWindow {" win1" }
19
- cv .setWindowTitle {" win1" , " Original image" }
20
- cv .imshow {" win1" , image }
18
+ cv .namedWindow {' win1' }
19
+ cv .setWindowTitle {' win1' , ' Original image' }
20
+ cv .imshow {' win1' , image }
21
21
cv .waitKey {0 }
22
22
23
23
local AGAST = cv .AgastFeatureDetector {threshold = 34 }
24
24
local keyPts = AGAST :detect {image }
25
25
26
26
-- show keypoints to the user
27
27
local imgWithAllKeypoints = cv .drawKeypoints {image , keyPts }
28
- cv .setWindowTitle {" win1" , keyPts .size .. " keypoints by AGAST" }
29
- cv .imshow {" win1" , imgWithAllKeypoints }
28
+ cv .setWindowTitle {' win1' , keyPts .size .. ' keypoints by AGAST' }
29
+ cv .imshow {' win1' , imgWithAllKeypoints }
30
30
cv .waitKey {0 }
31
31
32
32
-- remove keypoints within 60 pixels from image border
@@ -35,6 +35,6 @@ keyPts = cv.KeyPointsFilter.runByImageBorder{keyPts, imageSize, 60}
35
35
36
36
-- show again, with reduced number of keypoints
37
37
local imgWithSomeKeypoints = cv .drawKeypoints {image , keyPts }
38
- cv .setWindowTitle {" win1" , keyPts .size .. " remaining keypoints" }
39
- cv .imshow {" win1" , imgWithSomeKeypoints }
38
+ cv .setWindowTitle {' win1' , keyPts .size .. ' remaining keypoints' }
39
+ cv .imshow {' win1' , imgWithSomeKeypoints }
40
40
cv .waitKey {0 }
0 commit comments