def callback(self, ros_data):
        '''Callback function of subscribed topic. 
        Here images get converted and features detected'''
        if VERBOSE :
            print 'received image of type: "%s"' % ros_data.format

        #### direct conversion to CV2 ####
        np_arr = np.fromstring(ros_data.data, np.uint8)
        image_np = cv2.imdecode(np_arr, cv2.CV_LOAD_IMAGE_COLOR)
        
        #### Feature detectors using CV2 #### 
        # "","Grid","Pyramid" + 
        # "FAST","GFTT","HARRIS","MSER","ORB","SIFT","STAR","SURF"
        #method = "FAST"
        #feat_det = cv2.FeatureDetector_create(method)
        
        
        #convert np image to grayscale
#        grey_imagenp = cv2.cvtColor(image_np, cv2.COLOR_BGR2GRAY)
#        print 'The image is being processed'

        predictionArray, centroidArray = tS.processAndClassify(image_np)

        #featPoints,des,keyImage = dd.featureDetectDesORB(grey_imagenp)
#       
#        for featpoint in featPoints:
#            x,y = featpoint.pt
#            cv2.circle(image_np,(int(x),int(y)), 3, (0,0,255), -1)
#       
       
        print 'The image is being processed'
        cv2.imshow('cv_img', frameBoundingBox)
        cv2.waitKey(2)

        #### Create CompressedIamge ####
        msg = CompressedImage()
        msg.header.stamp = rospy.Time.now()
        msg.format = "jpeg"
        msg.data = np.array(cv2.imencode('.jpg', image_np)[1]).tostring()
        # Publish new image
        self.image_pub.publish(msg)
Ejemplo n.º 2
0
    def callback(self, ros_data):
        '''Callback function of subscribed topic. 
        Here images get converted and features detected'''
        if VERBOSE:
            print 'received image of type: "%s"' % ros_data.format

        #### direct conversion to CV2 ####
        np_arr = np.fromstring(ros_data.data, np.uint8)
        image_np = cv2.imdecode(np_arr, cv2.CV_LOAD_IMAGE_COLOR)

        #### Feature detectors using CV2 ####
        # "","Grid","Pyramid" +
        # "FAST","GFTT","HARRIS","MSER","ORB","SIFT","STAR","SURF"
        #method = "FAST"
        #feat_det = cv2.FeatureDetector_create(method)

        #convert np image to grayscale
        #        grey_imagenp = cv2.cvtColor(image_np, cv2.COLOR_BGR2GRAY)
        #        print 'The image is being processed'

        predictionArray, centroidArray = tS.processAndClassify(image_np)

        #featPoints,des,keyImage = dd.featureDetectDesORB(grey_imagenp)
        #
        #        for featpoint in featPoints:
        #            x,y = featpoint.pt
        #            cv2.circle(image_np,(int(x),int(y)), 3, (0,0,255), -1)
        #

        print 'The image is being processed'
        cv2.imshow('cv_img', frameBoundingBox)
        cv2.waitKey(2)

        #### Create CompressedIamge ####
        msg = CompressedImage()
        msg.header.stamp = rospy.Time.now()
        msg.format = "jpeg"
        msg.data = np.array(cv2.imencode('.jpg', image_np)[1]).tostring()
        # Publish new image
        self.image_pub.publish(msg)
Ejemplo n.º 3
0
def processImage(rosImage):
    global predictionArray, centroidArray,labels 
    frame = np.array(rosImage, dtype=np.uint8)
        # Process the frame using the process_image() function
    predictionArray, centroidArray,labels = tS.processAndClassify(frame)
    return predictionArray, centroidArray,labels
 def processImage(self, frame, codeBookCenters, svm):
     predictionArray, centroidArray,labels = tS.processAndClassify(frame, codeBookCenters, svm)
     return predictionArray, centroidArray,labels
# -*- coding: utf-8 -*-
"""
Created on Fri Jan 15 19:28:03 2016

@author: 4chennur
"""

import cv2
import testSegmented as tS
frame = cv2.imread('frame0032.jpg')

tS.processAndClassify(frame)
 def processImage(self, frame, codeBookCenters, svm):
     predictionArray, centroidArray, labels = tS.processAndClassify(
         frame, codeBookCenters, svm)
     return predictionArray, centroidArray, labels