Beispiel #1
0
    def __init__(self):
        # self.image_pub = rospy.Publisher("image_topic_2",Image)
        self.CMT = CMT.CMT()
        self.bridge = CvBridge()

        self.first = True
        self.rect = None
        self.init_img = None

        self.center = None
        self.prev_center = None

        self.h = None
        self.w = None

        self.linear_speed_x = 0.1
        self.k_yaw = 0.0005
        self.k_alt = 0.0005

        self.image_sub = rospy.Subscriber("/rexrov/rexrov/camera/camera_image",
                                          Image, self.callback)

        self.des_vel_pub = rospy.Publisher("/rexrov/cmd_vel",
                                           numpy_msg(geometry_msgs.Twist),
                                           queue_size=1)
Beispiel #2
0
    def __init__(self):
        self.image_pub = rospy.Publisher("image_topic_2", Image)
        self.bridge = CvBridge()
        self.image_sub = rospy.Subscriber("/usb_cam/image_raw", Image,
                                          self.callback)
        #self.image_sub = rospy.Subscriber("/ocam/image_raw",Image,self.callback)
        #self.image_sub = rospy.Subscriber("/usb2_cam/image_rect_color",Image,self.callback)
        self.CRT = CMT.CMT()

        self.CRT.estimate_scale = 'estimate_scale'
        self.CRT.estimate_rotation = 'estimate_rotation'
        self.pause_time = 10
        ###########################Primer Region

        im0 = cv2.imread('./frame_cap.jpg',
                         flags=cv2.IMREAD_COLOR)  #flags=cv2.IMREAD_GRAYSCALE)
        #im0 = cv2.imread('/home/sergio/catikin_ws_user/src/cmt/scripts/frame.jpg', flags=cv2.IMREAD_COLOR)
        #im0 = cv2.imread('/home/sergio/catikin_ws_user/src/cmt/scripts/frame.jpg',flags=cv2.IMREAD_GRAYSCALE)
        cv2.imshow('im0', im0)
        #im_gray0 = cv2.cvtColor(im0, cv2.COLOR_BGR2GRAY)
        im_gray0 = im0
        im_draw = np.copy(im0)
        print('Selecciona Primer Region')
        tl = (84, 55)
        br = (557, 307)
        #tl=(35,35)
        #bl=(605,325)
        (tl, br) = util.get_rect(im_draw)
        print('usando %i, %i como init bb', tl, br)
        self.CRT.initialise(im_gray0, tl, br)
        self.frame = 1
Beispiel #3
0
 def __init__(self, input_queue):
     multiprocessing.Process.__init__(self)
     self.CMT = CMT.CMT()
     self.templet = cv2.resize(cv2.imread(config['Video']['original']), (FRAME_WIDTH, FRAME_HEIGHT))
     self.cap = cv2.VideoCapture(config['Video']['cap'])
     self.message_queue = input_queue
     self.cap.set(cv2.CAP_PROP_FRAME_HEIGHT, FRAME_HEIGHT)
     self.cap.set(cv2.CAP_PROP_FRAME_WIDTH, FRAME_WIDTH)
     self.cap.set(cv2.CAP_PROP_FPS, 10)
    def __init__(self):
        # self.image_pub = rospy.Publisher("image_topic_2",Image)
        self.CMT = CMT.CMT()
        self.bridge = CvBridge()

        self.tracker = cv2.TrackerTLD_create()

        self.count = 0

        self.first = True
        self.first_ttc = True

        self.rect = None
        self.init_img = None

        self.center = None
        self.prev_center = None

        self.hit_buoy = False
        self.track_window = None

        self.h = None
        self.w = None

        self.dt = 1.0 / 19.0
        self.bbox_h = None
        self.bbox_h_init = None
        self.bbox_h_prev = None

        self.linear_speed_x = 0.35
        self.k_yaw = 0.0005
        self.k_alt = 0.0005
        # self.k_yaw = 0.0008
        # self.k_alt = 0.0008

        self.image_sub = rospy.Subscriber("/rexrov/rexrov/camera/camera_image",
                                          Image, self.callback)
        self.jerk_sub = rospy.Subscriber("/jerk", Float32, self.jerk_callback)

        self.des_vel_pub = rospy.Publisher("/rexrov/cmd_vel",
                                           numpy_msg(geometry_msgs.Twist),
                                           queue_size=1)

        smach.State.__init__(self, outcomes=['hit', 'in_pursuit'])
Beispiel #5
0
    def __init__(self):
        self.image_pub = rospy.Publisher("image_topic_2", Image)
        self.bridge = CvBridge()
        self.image_sub = rospy.Subscriber("/usb_cam/image_raw", Image,
                                          self.callback)
        #self.image_sub = rospy.Subscriber("/usb2_cam/image_rect_color",Image,self.callback)
        self.CRT = CMT.CMT()
        self.CNT = CMT.CMT()
        self.CST = CMT.CMT()

        self.CRT = CMT.CMT()
        self.CNT = CMT.CMT()
        self.CST = CMT.CMT()

        self.CRT.estimate_scale = 'estimate_scale'
        self.CRT.estimate_rotation = 'estimate_rotation'
        self.CNT.estimate_scale = 'estimate_scale'
        self.CNT.estimate_rotation = 'estimate_rotation'
        self.CST.estimate_scale = 'estimate_scale'
        self.CST.estimate_rotation = 'estimate_rotation'
        self.pause_time = 10
        ###########################Primer Region

        im0 = cv2.imread('~/catikin_ws_c/src/cmt/scripts/imas.jpg',
                         flags=cv2.IMREAD_COLOR)
        if im0:
            print(im0.shape)
        im_gray0 = cv2.cvtColor(im0, cv2.COLOR_BGR2GRAY)
        im_draw = np.copy(im0)
        print('Selecciona Primer Region')
        (tl, br) = util.get_rect(im_draw)
        print('using %i, %i as init bb', tl, br)
        self.CRT.initialise(im_gray0, tl, br)
        ###########################Segunda Region
        print('Selecciona Segunda Region')
        (tl, br) = util.get_rect(im_draw)
        print('using %i, %i as init bb', tl, br)
        self.CNT.initialise(im_gray0, tl, br)
        ############################Tercer Region
        print('Selecciona Tercer Region')
        (tl, br) = util.get_rect(im_draw)
        print('using %i, %i as init bb', tl, br)
        self.CST.initialise(im_gray0, tl, br)
        self.frame = 1
Beispiel #6
0
    def __init__(self):
        self.image_pub = rospy.Publisher("image_topic_cmt",
                                         Image,
                                         queue_size=1)
        self.vis_odo_pub = rospy.Publisher("visual_odometry",
                                           Odometry,
                                           queue_size=1)
        self.bridge = CvBridge()
        #self.image_sub = rospy.Subscriber("/usb_cam/image_raw",Image,self.callback)
        self.image_sub = rospy.Subscriber("/ocam/image_raw",
                                          Image,
                                          self.callback,
                                          queue_size=1)
        self.yaw_sub = rospy.Subscriber("model_car/yaw2",
                                        Float32,
                                        self.headingcallback,
                                        queue_size=1)
        #self.image_sub = rospy.Subscriber("/usb2_cam/image_rect_color",Image,self.callback)
        self.CRT = CMT.CMT()

        self.CRT.estimate_scale = 'estimate_scale'
        self.CRT.estimate_rotation = 'estimate_rotation'
        self.pause_time = 10
        ###########################Primer Region
        #im0 = cv2.imread('./frame_cuadri_1500.jpg', flags=cv2.IMREAD_GRAYSCALE)
        im0 = cv2.imread('./frame_cap13.jpg', flags=cv2.IMREAD_GRAYSCALE)
        #im0 = cv2.imread('./frame_cap_13.jpg', flags=cv2.IMREAD_GRAYSCALE)
        #im0 = cv2.imread('./frame_fisica3.jpg', flags=cv2.IMREAD_GRAYSCALE)
        #im0 = cv2.imread('./frame_cap_16.jpg', flags=cv2.IMREAD_GRAYSCALE)
        #im0 = cv2.imread('./frame_cap_noche.jpg', flags=cv2.IMREAD_GRAYSCALE)
        #im0 = cv2.imread('./frame_cap3.jpg', flags=cv2.IMREAD_GRAYSCALE)#flags=cv2.IMREAD_GRAYSCALE)
        #im0 = cv2.imread('/home/sergio/catikin_ws_user/src/cmt/scripts/frame.jpg', flags=cv2.IMREAD_COLOR)
        #im0 = cv2.imread('/home/sergio/catikin_ws_user/src/cmt/scripts/frame.jpg',flags=cv2.IMREAD_GRAYSCALE)
        #cv2.imshow('im0', im0)
        #im_gray0 = cv2.cvtColor(im0, cv2.COLOR_BGR2GRAY)
        im_gray0 = im0
        #print(np.size(im_gray0))
        #im_gray0=cv2.blur(im0,(3,3))
        #cv2.line(im_gray0, (70,0), (70,300), (0, 0, 0), 150)
        #cv2.line(im_gray0, (490,0), (490,300), (0, 0, 0), 150)
        #im_gray0=cv2.resize(im0, (360, 240))
        #im_draw = np.copy(im0)
        print('Selecciona Primer Region')
        #tl=(84, 55) #talvez
        #br=(557, 307#tal vez
        #tl=(68, 68)
        #br=(544, 316)
        #tl=(35,35)
        #bl=(605,325)
        #tl=(78, 59) #ultimos con156kp
        #br=(553, 297)#uktimos con 156kp
        tl = (73, 56)  #labo umi
        br = (449, 244)  #labo umi

        #tl=(88, 58) #camaras labo
        #br=(429, 240)#camaras labo
        #tl=(93, 61) #camaras labo nuevo
        #br=(436, 241)#labo camaras nuevo
        tl = (85, 59)  #last camrasa
        br = (428, 239)  #lascamaras
        #tl=(166, 64)
        #br=(348, 237)
        #(84, 63) (429, 237)
        #tl=(87, 57)#camaras
        #br= (426, 234)#camaras
        tl = (87, 57)  #camaras
        br = (326, 154)  #camaras
        tl = (59, 44)  #camaras peque
        br = (300, 195)  #camaras peque
        tl = (128, 25)
        br = (394, 278)

        ##cuadrilatero
        #tl=(157,6)
        #br=(408,257)
        tl = (154, 21)  #55)
        br = (392, 259)
        #tl=(40+20,27+20)
        #br=(269-20, 256-20)
        tl = (40 + 10, 27 + 10)
        br = (269 - 10, 256 - 10)
        tl = (320 - 146, 180 - 146)
        br = (320 + 146, 180 + 146)
        #(158, 14) (392, 261)

        ##fisica
        #tl=(118, 54)
        #br=(348, 250)
        #(tl, br) = util.get_rect(im_gray0)
        print('usando %i, %i como init bb', tl, br)
        self.CRT.initialise(im_gray0, tl, br)
        print('Num keypoint init', self.CRT.num_initial_keypoints)
        self.frame = 1
        self.conta = 0

        self.frame_id = 'visual_odometry'
        self.child_frame_id = 'base_link2'
        self.msg = Odometry()
Beispiel #7
0
region = None
tracker = None
with trax.server.Server(options, verbose=True) as server:
    while True:
        request = server.wait()
        if request.type in ["quit", "error"]:
            break
        if request.type == "initialize":
            region = request.region
            im0 = read_trax_image(request.image)
            im_gray0 = cv2.cvtColor(im0, cv2.COLOR_BGR2GRAY)
            tl = (region.x, region.y)
            br = (region.x + region.width - 1, region.y + region.height - 1)
            tracker = None
            try:
                tracker = CMT.CMT()
                tracker.initialise(im_gray0, tl, br)
            except Exception:
                tracker = None
        else:
            im = read_trax_image(request.image)
            im_gray = cv2.cvtColor(im, cv2.COLOR_BGR2GRAY)
            if not tracker == None:
                tracker.process_frame(im_gray)
                if not math.isnan(tracker.bb[0]):
                    region = trax.region.Rectangle(tracker.bb[0],
                                                   tracker.bb[1],
                                                   tracker.bb[2],
                                                   tracker.bb[3])
                else:
                    region = trax.region.Special(0)
Beispiel #8
0
#!/usr/bin/env python

import argparse
import cv2
from numpy import empty, nan
import os
import sys
import time

import CMT
import numpy as np
import util

CMT = CMT.CMT()

parser = argparse.ArgumentParser(description='Track an object.')

parser.add_argument('inputpath', nargs='?', help='The input path.')
parser.add_argument('--challenge',
                    dest='challenge',
                    action='store_true',
                    help='Enter challenge mode.')
parser.add_argument('--preview',
                    dest='preview',
                    action='store_const',
                    const=True,
                    default=None,
                    help='Force preview')
parser.add_argument('--no-preview',
                    dest='preview',
                    action='store_const',
Beispiel #9
0
import cv2
from numpy import empty, nan
import os
import threading
import multiprocessing
import sys
import time
from multiprocessing.dummy import Pool as Threadpool
import CMT
import numpy as np

#import CMT2
import util
from functools import partial

CMT = [CMT.CMT(), CMT.CMT()]
#CMT2 = CMT2.CMT2()

parser = argparse.ArgumentParser(description='Track an object.')

parser.add_argument('inputpath', nargs='?', help='The input path.')
parser.add_argument('--challenge',
                    dest='challenge',
                    action='store_true',
                    help='Enter challenge mode.')
parser.add_argument('--preview',
                    dest='preview',
                    action='store_const',
                    const=True,
                    default=None,
                    help='Force preview')
Beispiel #10
0
    def __init__(self):
        """Initialize CMT detector"""

        self._cmt = CMT.CMT()
        self.location = None
Beispiel #11
0
#!/usr/bin/env python

import argparse
import cv2
from numpy import empty, nan
import os
import sys
import time

import CMT
import numpy as np
import util

CMTobj = CMT.CMT()

parser = argparse.ArgumentParser(description='Track an object.')

parser.add_argument('inputpath', nargs='?', help='The input path.')
parser.add_argument('--challenge',
                    dest='challenge',
                    action='store_true',
                    help='Enter challenge mode.')
parser.add_argument('--preview',
                    dest='preview',
                    action='store_const',
                    const=True,
                    default=None,
                    help='Force preview')
parser.add_argument('--no-preview',
                    dest='preview',
                    action='store_const',