Fun OpenCV Tests cv FastFeatureDetector style body height 300px style script src https docs opencv org master opencv js script script cv onRuntimeInitialized console log onRuntimeInitialized RunCV async function RunCV console log RunCV let imgurl https notebook xbdev net var images simpleshapes png let img document createElement img img src imgurl await img decode let src cv imread img let keyPoints new cv KeyPointVector let mask new cv Mat console log mask mask let threshold 20 0 let FAST new cv FastFeatureDetector threshold FAST detect src keyPoints mask console log keyPoints keyPoints size let img2 new cv Mat let color new cv Scalar 0 255 0 1 cv drawKeypoints src keyPoints img2 color if you want to extract look at a particular point keyPoints get 2 pt y 5 console log keyPoints get 2 pt y cv imshow canvas img2 src delete let canvas document createElement canvas canvas style padding 5px canvas style display inline canvas width 100 canvas height 100 document body appendChild canvas console log script script cv ORB detector style body height 300px style script src https docs opencv org master opencv js script script cv onRuntimeInitialized console log onRuntimeInitialized RunCV async function RunCV console log RunCV let imgurl https notebook xbdev net var images simpleshapes png let img document createElement img img src imgurl await img decode let src cv imread img Initiate ORB detector let orb new cv ORB 1000 let keyPoints new cv KeyPointVector let color new cv Scalar 0 255 0 1 find the keypoints with ORB orb detect src keyPoints let des new cv Mat compute the descriptors with ORB orb compute src keyPoints des draw only keypoints location not size and orientation let img2 new cv Mat cv drawKeypoints src keyPoints img2 color cv imshow canvas img2 src delete let canvas document createElement canvas canvas style padding 5px canvas style display inline canvas width 100 canvas height 100 document body appendChild canvas console log script script cv cornerHarris style body height 300px style script src https docs opencv org master opencv js script script cv onRuntimeInitialized console log onRuntimeInitialized RunCV async function RunCV console log RunCV let imgurl https notebook xbdev net var images simpleshapes png let img document createElement img img src imgurl await img decode let src cv imread img let gray new cv Mat cv cvtColor src gray cv COLOR_RGB2GRAY let des new cv Mat let harris new cv cornerHarris gray des 7 0 1 0 05 console log harris cv imshow canvas des src delete let canvas document createElement canvas canvas style padding 5px canvas style display inline canvas width 100 canvas height 100 document body appendChild canvas console log script script cv goodFeaturesToTrack style body height 300px style script src https docs opencv org master opencv js script script cv onRuntimeInitialized console log onRuntimeInitialized RunCV async function RunCV console log RunCV let imgurl https notebook xbdev net var images simpleshapes png let img document createElement img img src imgurl await img decode let src cv imread img let gray new cv Mat cv cvtColor src gray cv COLOR_RGB2GRAY let des new cv Mat const maxCorners 100 const qualityLevel 0 01 const minDistance 10 const blockSize 3 const useHarrisDetector false const k 0 04 cv goodFeaturesToTrack gray des maxCorners qualityLevel minDistance new cv Mat blockSize useHarrisDetector k des convertTo des cv CV_32F or CV_32F or CV_32FC1 console log des size des size console log des data32F length des data32F length Draw corners detected let r 4 var color new cv Scalar 255 0 0 for var i 0 i des data32F length 2 i let x des data32F i 2 0 let y des data32F i 2 1 cv circle src x x y y r color 2 cv imshow canvas src src delete let canvas document createElement canvas canvas style padding 5px canvas style display inline canvas width 100 canvas height 100 document body appendChild canvas console log script script cv BRISK style body height 300px style script src https docs opencv org master opencv js script script cv onRuntimeInitialized console log onRuntimeInitialized RunCV async function RunCV console log RunCV let imgurl https notebook xbdev net var images simpleshapes png let img document createElement img img src imgurl await img decode let src cv imread img let gray new cv Mat cv cvtColor src gray cv COLOR_RGB2GRAY let col new cv Mat cv cvtColor src col cv COLOR_RGBA2RGB Initiate STAR detector var brisk new cv BRISK 10 1 3 find the keypoints with ORB var kp new cv KeyPointVector brisk detect src kp new cv Mat compute the descriptors with ORB var des new cv Mat brisk compute src kp des draw only keypoints location not size and orientation var img2 new cv Mat var color new cv Scalar 0 255 0 cv drawKeypoints src kp img2 color cv imshow canvas img2 var mser new cv MSER 5 60 14400 0 25 0 2 200 1 01 0 003 5 var contours new cv PointVector var kp new cv KeyPointVector var boxes new cv RectVector mser detectRegions col contours boxes var img2 src clone var channels img2 channels var cols img2 cols var data img2 data for var i 0 i contours size i 1 var contour contours get i for var j 0 j contour size j 1 var p contour get j data p 1 cols p 0 channels 255 contour delete cv imshow canvas img2 src delete let canvas document createElement canvas canvas style padding 5px canvas style display inline canvas width 100 canvas height 100 document body appendChild canvas console log script script
script src https docs opencv org master opencv js script script cv onRuntimeInitialized console log onRuntimeInitialized RunCV async function RunCV console log RunCV let imgurl https notebook xbdev net var images simpleshapes png let img document createElement img img src imgurl await img decode let src cv imread img let gray new cv Mat cv cvtColor src gray cv COLOR_RGB2GRAY let des new cv Mat const maxCorners 100 const qualityLevel 0 01 const minDistance 10 const blockSize 3 const useHarrisDetector false const k 0 04 cv goodFeaturesToTrack gray des maxCorners qualityLevel minDistance new cv Mat blockSize useHarrisDetector k des convertTo des cv CV_32F or CV_32F or CV_32FC1 console log des size des size console log des data32F length des data32F length Draw corners detected let r 4 var color new cv Scalar 255 0 0 for var i 0 i des data32F length 2 i let x des data32F i 2 0 let y des data32F i 2 1 cv circle src x x y y r color 2 cv imshow canvas src src delete let canvas document createElement canvas canvas style padding 5px canvas style display inline canvas width 100 canvas height 100 document body appendChild canvas console log script script cv BRISK style body height 300px style script src https docs opencv org master opencv js script script cv onRuntimeInitialized console log onRuntimeInitialized RunCV async function RunCV console log RunCV let imgurl https notebook xbdev net var images simpleshapes png let img document createElement img img src imgurl await img decode let src cv imread img let gray new cv Mat cv cvtColor src gray cv COLOR_RGB2GRAY let col new cv Mat cv cvtColor src col cv COLOR_RGBA2RGB Initiate STAR detector var brisk new cv BRISK 10 1 3 find the keypoints with ORB var kp new cv KeyPointVector brisk detect src kp new cv Mat compute the descriptors with ORB var des new cv Mat brisk compute src kp des draw only keypoints location not size and orientation var img2 new cv Mat var color new cv Scalar 0 255 0 cv drawKeypoints src kp img2 color cv imshow canvas img2 var mser new cv MSER 5 60 14400 0 25 0 2 200 1 01 0 003 5 var contours new cv PointVector var kp new cv KeyPointVector var boxes new cv RectVector mser detectRegions col contours boxes var img2 src clone var channels img2 channels var cols img2 cols var data img2 data for var i 0 i contours size i 1 var contour contours get i for var j 0 j contour size j 1 var p contour get j data p 1 cols p 0 channels 255 contour delete cv imshow canvas img2 src delete let canvas document createElement canvas canvas style padding 5px canvas style display inline canvas width 100 canvas height 100 document body appendChild canvas console log script script