Please ignore the first question that i have posted
Again the problem i encountered is about SIFT
Here is my actual code and error
#include "opencv2/core/core_c.h" #include "opencv2/core/core.hpp" #include "opencv2/flann/miniflann.hpp" #include "opencv2/imgproc/imgproc_c.h" #include "opencv2/imgproc/imgproc.hpp" #include "opencv2/video/video.hpp" #include "opencv2/features2d/features2d.hpp" #include "opencv2/objdetect/objdetect.hpp" #include "opencv2/calib3d/calib3d.hpp" #include "opencv2/ml/ml.hpp" #include "opencv2/highgui/highgui_c.h" #include "opencv2/highgui/highgui.hpp" #include "opencv2/contrib/contrib.hpp"
int main()
{
import cv2
import numpy as np
img = cv2.imread('python.jpeg')
gray= cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
sift = cv2.xfeatures2d.SIFT_create()
kp = sift.detect(gray,None)
img=cv2.drawKeypoints(gray,kp)
cv2.imwrite('sift_keypoints.jpg',img)
img=cv2.drawKeypoints(gray,kp,flags=cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS) cv2.imwrite('sift_keypoints.jpg',img)
}
the error i have encountered
sift.cpp:21:23: warning: character constant too long for its type [enabled by default]
img = cv2.imread('python.jpeg')
^
sift.cpp:29:17: warning: character constant too long for its type [enabled by default]
cv2.imwrite('sift_keypoints.jpg',img)
^
sift.cpp:31:17: warning: character constant too long for its type [enabled by default]
cv2.imwrite('sift_keypoints.jpg',img)
^
sift.cpp: In function ‘int main()’:
sift.cpp:18:2: error: ‘import’ was not declared in this scope
import cv2 ^ sift.cpp:18:9: error: expected ‘;’ before ‘cv2’
import cv2 ^