def register(): cust_name = username_input.get() Registration.collectSamples(dataset=dataset, subdata=cust_name) res = Registration.registerCustomer(cust_name) if res == 'Customer Register Succesfuly': suc_reg_lbl.config(text=cust_name + ' Registered Succesfully', bg='sea green') root.after(5000, removeSuccesMessage) username_entry.delete(0, END) else: messagebox.showerror('Error', "Customer was already registered")
def __database__(*args): if len(args) == 5: username, password, email, dob, name = args k = Registration.Dbms(username, password, email, dob, name) value = k.registering() if value == 0: return __database__(username, password) elif value == 1: return render_template('register.html', email_message="enter valid email", username=username, dob=dob, name=name) elif value == 2: return render_template('register.html', email_message="email already registered", username=username, dob=dob, name=name) elif value == 3: return render_template('register.html', username_message="username already in use", email=email, dob=dob, name=name) elif value == 4: return render_template('register.html', dob_message="enter valid dob", username=username, email=email, name=name) elif value == 5: return render_template('register.html', username_message="invalid username", email=email, name=name, dob=dob) else: username, password = args k = Registration.Dbms(username, password) value = k.log_in() if value is None: return render_template('login.html', message="invalid username or password") else: return render_template('home.html', username=value[0], email=value[1], dob=value[2], name=value[3])
def newmessage(message): token = vkbot.token(message.chat.id) session = vk.AuthSession(access_token=token[0]) vk_api = vk.API(session) name = vkbot.chats(Registration.start(message)) keyboard = telebot.types.InlineKeyboardMarkup() i = 0 for a in name: data = vk_api.messages.getHistory(offset=-1, count=1, start_message_id=-1, peer_id=name[a], v=5.38) #print(data) if len(data['items']) > 0: #print(data['items']) callback_button = telebot.types.InlineKeyboardButton( text=a, callback_data=name[a]) keyboard.add(callback_button) i += 1 else: break if i > 0: bot.send_message(message.chat.id, "Для вас есть новые сообщения в этих чатах", reply_markup=keyboard) else: bot.send_message(message.chat.id, "Новых сообщений нет")
def testCheckout(self): register = Registration.Registration(self.driver) register.test_register() while True: try: header = TestHelper.Header(self.driver) header.LoginUserHeader() except NoSuchElementException: print "Checking Header" else: break addproduct = TestHelper.addproductOnHomePage(self.driver) addproduct.productOnHomePage() while False: try: assert "[E14] Product Is Already Added To Your Shopping Cart. You Have Reached Quantity Limit For This Product" in self.driver.page_source except NoSuchElementException: print "Can't add product to cart for first time user -[E14] Product Is Already Added To Your Shopping Cart. You Have Reached Quantity Limit For This Product " self.driver.close() else: print "Autotest over" break while True: try: addtocart = TestHelper.ProductPage(self.driver) addtocart.addToCartProductPageMethod() except NoSuchElementException, e: print "Click button [Add to Cart] on product page" else: break
def main(self): flag = 0 while flag == 0: print( "Enter 1 for Registration\n 2 for Billing\n 3 for Checkout/Searching" ) d1 = 0 while d1 == 0: try: choice = int(input("Option:")) except ValueError: print("Invalid Choice") print("Try Again!") else: d1 = 1 print( "******************************************************************************************************************************* \n " ) if choice == 1: r = Registration() # Registration of the guest r.main() elif choice == 2: b = Billing() # To print a bill for the guest b.main() elif choice == 3: c = Checkout_Searching( ) # To check out the guest or to search for a guest who has already checked out c.main() else: print("Wrong choice") print() d = 1 while d == 1: # To take user's input on whether the program should again start from the beginning s = input("Do you want to continue?(yes/no)") if s.lower() == "yes": print( "******************************************************************************************************************************* \n " ) break elif s.lower == "no": print("\t\t\t\t\t\t\t\t\t***THANK YOU***") flag = 1 break else: print("Sorry ,please give your opinion in yes or no")
def chat(message): #выводит список последних чатов name = vkbot.chats(Registration.start(message)) keyboard = telebot.types.InlineKeyboardMarkup() for a in name: callback_button = telebot.types.InlineKeyboardButton( text=a, callback_data=name[a]) keyboard.add(callback_button) bot.send_message(message.chat.id, "Выберите чат", reply_markup=keyboard)
def handle_start(message): tokenVK = Registration.start(message) if tokenVK == '0': a = message.text.split('/') b = 'https://oauth.vk.com/'.split('/') if a[0:2] == b[0:2]: Registration.start1(message) print('0') else: if message.text == "Обновить сообщения": obnov(message.chat.id) else: token = vkbot.token(message.chat.id) session = vk.AuthSession(access_token=token[0]) vk_api = vk.API(session) vk_api.messages.send(peer_id=token[1], message=message.text, v=5.38)
def display(): f = request.form.get("first-name") l = request.form.get("last-name") email = request.form.get("email") password = request.form.get("psw") register = Registration(first_name=f, last_name=l,email=email,datetime=datetime.now(),password=password) try: db.session.add(register) db.session.commit() print() print(f+" "+l) return render_template("print.html",f=f,l=l) except Exception : return render_template("error.html", errors = "Details are already given")
def register(): message = "" id = txt.get() name = txt2.get() pss = txt4.get() msg = rg.registration(id, name, pss) message = tk.Label(root, text=msg, bg="#ededed", fg="blue", width=40, height=2, activebackground="blue", font=('times', 15, ' bold ')) if (("already" in msg) or "Please" in msg): message.configure(fg="firebrick2") message.place(x=600, y=350)
def forget_password(): if request.method == 'GET': email = request.args.get('username') dob = request.args.get('dob') npassword = request.args.get('password') name = request.args.get('name') else: email = request.form['username'] dob = request.form['dob'] npassword = request.form['password'] name = request.form['name'] if email is None: return render_template('forget.html') else: k = Registration.Dbms(email, dob, npassword, name) value = k.forget() if value == 0: return render_template('forget.html', message="successful") else: return render_template('forget.html', message="unsuccessful")
def further_action(self, user_op): if user_op == 1: h = Registration.Home(myDB, myCursor) h.homeview() elif user_op == 2: l1 = Login.LogUser(myDB, myCursor) l1.action() elif user_op == 3: f = ForgotPassword.UserAssist(myDB, myCursor) f.assist() elif user_op == 4: exit() else: print("You entered a wrong option!") user_action = input("Do you want to exit? (Y/N) : ") if user_action == 'Y': exit() elif user_action == 'N': self.options() else: exit()
def alignment(ndarray_ref, ndarray_list): """ To align the LIGHT image according to a references image Parameters : - ndarray_ref : ndarray of the light reference. - ndarray_list : ndarray list of the lights which must be aligned Return : - ndarray_list : ndarray list of all the aligned lights. """ lenght = len(ndarray_list) h,l,r = ndarray_ref.shape for nb in range(lenght) : # The result is always calculated from the ref image result = np.copy(ndarray_ref) # Calcul the shift factor shift = reg.shift_translation(ndarray_ref,ndarray_list[nb]) decalx = int(shift[0]) decaly = int(shift[1]) # Apply the shift factor, according to its sign if decalx>=0 and decaly>=0 : for i in range(decalx,h): for j in range(decaly,l): result[i][j]=ndarray_list[nb][i-decalx][j-decaly] if decalx<0 and decaly<0 : for i in range(0-decalx,h): for j in range(0-decaly,l): result[i+decalx][j+decaly]=ndarray_list[nb][i][j] if decalx>=0 and decaly<0 : for i in range(decalx,h): for j in range(0-decaly,l): result[i][j+decaly]=ndarray_list[nb][i-decalx][j] if decalx<0 and decaly>=0 : for i in range(0-decalx,h): for j in range(decaly,l): result[i+decalx][j]=img2[i][j-decaly] # Apply the changes to the image ndarray_list[nb] = result return (ndarray_ref,ndarray_list)
def a(message): user_markup = telebot.types.ReplyKeyboardMarkup(True) user_markup.row("Обновить сообщения") bot.send_message( message.chat.id, "Нажмите на эту кнопку для обновления непрочитанных сообщений", reply_markup=user_markup) if Registration.start(message) == "0": keyboard = telebot.types.InlineKeyboardMarkup() url_button = telebot.types.InlineKeyboardButton( text="Перейти", url= "https://oauth.vk.com/authorize?client_id=6618701&display=page&redirect_uri=https://oauth.vk.com/blank.html&display=page&scope=messages,offline&response_type=code&v=5.80" ) keyboard.add(url_button) bot.send_message( message.chat.id, "Здраствуйте. Перейдите по ссылке и разрешите приложению читать ваши сообщения", reply_markup=keyboard) bot.send_message(message.chat.id, "Введите полученную по этому адресу ссылку") else: pass
def openRegister(self): reg = Registration.Register() self.destroy()
def customerdetection(*args): images, labels, names = Registration.loadDataset() face_recognizer_model = Registration.loadAlgorithm(images, labels) webcam = cv2.VideoCapture(0) cnt = 0 (width, height) = (130, 100) while True: (ret, img) = webcam.read() Registration.put_text(img, 'Press Q to quit', 50, 220) gray_img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) facesFound = Registration.face_cascade.detectMultiScale( gray_img, 1.32, 3) for (x, y, w, h) in facesFound: cv2.rectangle(img, (x, y), (x + w, y + h), (255, 0, 0), 2) faceFound = gray_img[y:y + h, x:x + w] face_resized = cv2.resize(faceFound, (int(width), int(height))) label, confidence = face_recognizer_model.predict(face_resized) Registration.draw_rect(img, (x, y, w, h)) predicted_name = names[label] if confidence < 70: Registration.put_text(img, predicted_name + str(confidence), x, y) Registration.CustomerWelcome(predicted_name) else: Registration.put_text(img, "Unregistred Customer", x, y) cv2.namedWindow("Detection", cv2.WINDOW_NORMAL) cv2.moveWindow("Detection", 650, 150) cv2.resizeWindow('Detection', 640, 420) cv2.imshow('Detection', img) if cv2.waitKey(1) & 0xFF == ord("q"): break webcam.release() cv2.destroyAllWindows() Registration.CustomerWelcome(predicted_name)
def press_registration(self): self.LOGIN.destroy() Registration.Registration()
class TestRegistration(unittest.TestCase): def setUp(self) -> None: self.user = Registration() def test_register(self): with self.assertRaises(ErrorName): self.user.register("Yv*nne", "*****@*****.**", "poiuyt098") self.user.register("Yv&nne?", "*****@*****.**", "poiuyt098") self.user.register("Yvonne", "*****@*****.**", "Poiuyt098") with self.assertRaises(EmailError): self.user.register("Estella", "*****@*****.**", "zxcvb987") self.user.register("Estella", "estellam@@gmail.com", "zxcvb987") self.user.register("Estella", "*****@*****.**", "Zxcvb987") with self.assertRaises(LengthEmailError): self.user.register("Iris", "*****@*****.**", "asdfg123") self.user.register("Iris", "*****@*****.**", "asdfg123") self.user.register("Iris", "*****@*****.**", "Asdfg123") with self.assertRaises(UserAlreadyRegistered): self.user.register("Lucas", "*****@*****.**", "123qwerty") self.user.register("Lucas", "*****@*****.**", "zxcvb456") self.user.register("Lucas", "*****@*****.**", "Zxcvb456") with self.assertRaises(PasswordLengthError): self.user.register("Grace", "*****@*****.**", "qaz5") self.user.register("Grace", "*****@*****.**", "Qazwsx579") with self.assertRaises(PasswordError): self.user.register("Quinn", "*****@*****.**", "qu!nn379") self.user.register("Quinn", "*****@*****.**", "qu!nn$%#379") self.assertEqual( self.user.register("Quinn", "*****@*****.**", "Quinn379"), 200) def test_login_in(self): with self.assertRaises(ErrorLogIn): self.user.login_in("*****@*****.**", "123qw") self.user.login_in("*****@*****.**", "123Qwerty") self.user.login_in("*****@*****.**", "123Qwerty") def tearDown(self) -> None: print("tearDown")
import os import Registration import Login #This Segment Focuses on Character Creation / The first thing to pop up after booting up the game. Field_Separator = "\n\n------------------------------------------------------------------------------------------\n\n" while True: Player_Login_Choice = int( input(Field_Separator + "[1] Register [2] Login [3] Exit" + Field_Separator + "Choice: ")) if Player_Login_Choice == 1: Registration.registration() #Post Character Creation section where a player gets to start his or her adventure. if Player_Login_Choice == 2: Profile_data = Login.login() break Player_Name = Profile_data["Name:"] Player_Class = Profile_data["Class:"] print("Welcome " + Player_Class + " " + Player_Name + " To <Insert Title Here>" + Field_Separator + "[0] Start Game\n[1] Options\n[2] Exit" + Field_Separator) while True: Main_Menu_Choice = int(input()) if Main_Menu_Choice == 0:
ext = '.jpg' IX_path = datadir + name1 + ext IY_path = datadir + name2 + ext IX = cv2.imread(IX_path) # IX = cv2.resize(IX, (600, 800)) IY = cv2.imread(IY_path) # IY = cv2.resize(IY, (600, 800)) shape = IX.shape[:2] shape_arr = np.array(shape) center = shape_arr / 2.0 window_width = shape[1] window_height = shape[0] print('initializing') reg = Registration.CNN7() reg.init_thres = 1.15 print('registering') X, Y, T = reg.register(IX, IY) print('generating warped image') registered = tps_warp(Y, T, IY, IX.shape) print('generating checkboard image') cb = checkboard(IX, registered, 11) plt.imshow(cv2.cvtColor(cb, cv2.COLOR_RGB2BGR)) plt.show() PD = pairwise_distance(X, T) C, _ = match(PD)
def setUp(self) -> None: self.user = Registration()
def goRegistrationFunc(self): self.registration = Registration.Registration() self.registration.show()
def main(IX, IY, ylm, iterations): # resize images scale_percent = 10 # percent of original size might have to make an if to reduce every img to same size width = int(IX.shape[1] * scale_percent / 100) height = int(IX.shape[0] * scale_percent / 100) xdim = (width, height) width = int(IY.shape[1] * scale_percent / 100) height = int(IY.shape[0] * scale_percent / 100) ydim = (width, height) IX = cv2.resize(IX, xdim, interpolation=cv2.INTER_AREA) IY = cv2.resize(IY, ydim, interpolation=cv2.INTER_AREA) # import and rescale landmarks ylm = ylm * scale_percent / 100 ylm = np.round(ylm) # initialize reg = Registration.CNN() if iterations == 1: # Base Method X, Y, Z = reg.register(IX, IY) # generate registered image using TPS registered, nlm = tps_warp(Y, Z, IY, IX.shape, ylm) elif iterations == 2: # DLMR X, Y, Z = reg.register(IX, IY) # generate registered image using TPS registered0, nlm = tps_warp(Y, Z, IY, IX.shape, ylm) # slice image into 4 SLIX = Image.fromarray(IX) SRES = Image.fromarray(registered0) [i, j, k, l] = image_slicer.slice(SRES, 4, save=False) [m, n, o, q] = image_slicer.slice(SLIX, 4, save=False) i = numpy.array(i.image) j = numpy.array(j.image) k = numpy.array(k.image) l = numpy.array(l.image) m = numpy.array(m.image) n = numpy.array(n.image) o = numpy.array(o.image) q = numpy.array(q.image) xlength = registered0.shape[1] / 2 ylength = registered0.shape[0] / 2 # register each image slice Y = [] Z = [] if blank(i): Xi, Yi, Zi = reg.register(m, i) Y.append(Yi) Z.append(Zi) if blank(j): Xj, Yj, Zj = reg.register(n, j) Yj = Yj + [0, xlength] Zj = Zj + [0, xlength] Y.append(Yj) Z.append(Zj) if blank(k): Xk, Yk, Zk = reg.register(o, k) Yk = Yk + [ylength, 0] Zk = Zk + [ylength, 0] Y.append(Yk) Z.append(Zk) if blank(l): Xl, Yl, Zl = reg.register(q, l) Yl = Yl + [ylength, xlength] Zl = Zl + [ylength, xlength] Y.append(Yl) Z.append(Zl) Yf = numpy.concatenate(Y, axis=0) Zf = numpy.concatenate(Z, axis=0) # interpolate final image registered, nlm = tps_warp(Yf, Zf, registered0, IX.shape, nlm) elif iterations == 3: # 16 x resolution X, Y, Z = reg.register(IX, IY) # generate registered image using TPS registered0, temp1 = tps_warp(Y, Z, IY, IX.shape, ylm) # slice image into 4 SLIX = Image.fromarray(IX) SRES = Image.fromarray(registered0) [i, j, k, l] = image_slicer.slice(SRES, 4, save=False) [m, n, o, q] = image_slicer.slice(SLIX, 4, save=False) i = numpy.array(i.image) j = numpy.array(j.image) k = numpy.array(k.image) l = numpy.array(l.image) m = numpy.array(m.image) n = numpy.array(n.image) o = numpy.array(o.image) q = numpy.array(q.image) # register each image slice Xi, Yi, Zi = reg.register(m, i) Xj, Yj, Zj = reg.register(n, j) Xk, Yk, Zk = reg.register(o, k) Xl, Yl, Zl = reg.register(q, l) # combine Z of each slice into one xlength = registered0.shape[1] / 2 ylength = registered0.shape[0] / 2 Yj = Yj + [0, xlength] Yk = Yk + [ylength, 0] Yl = Yl + [ylength, xlength] Zj = Zj + [0, xlength] Zk = Zk + [ylength, 0] Zl = Zl + [ylength, xlength] Yf = numpy.concatenate((Yi, Yj, Yk, Yl), axis=0) Zf = numpy.concatenate((Zi, Zj, Zk, Zl), axis=0) # interpolate intermediate image registered1, nlm = tps_warp(Yf, Zf, registered0, IX.shape, temp1) SLIX = Image.fromarray(IX) SRES = Image.fromarray(registered1) [xa, xb, xc, xd, xe, xf, xg, xh, xi, xj, xk, xl, xm, xn, xo, xp] = image_slicer.slice(SLIX, 16, save=False) [ya, yb, yc, yd, ye, yf, yg, yh, yi, yj, yk, yl, ym, yn, yo, yp] = image_slicer.slice(SRES, 16, save=False) xa, xb, xc, xd, xe, xf, xg, xh, xi, xj, xk, xl, xm, xn, xo, xp = numpy.array(xa.image), numpy.array(xb.image), \ numpy.array(xc.image), numpy.array(xd.image), numpy.array(xe.image), numpy.array(xf.image),\ numpy.array(xg.image),numpy.array(xh.image), numpy.array(xi.image), numpy.array(xj.image), \ numpy.array(xk.image), numpy.array(xl.image), numpy.array(xm.image), numpy.array(xn.image), \ numpy.array(xo.image), numpy.array(xp.image) ya, yb, yc, yd, ye, yf, yg, yh, yi, yj, yk, yl, ym, yn, yo, yp = numpy.array(ya.image), numpy.array(yb.image), \ numpy.array(yc.image), numpy.array(yd.image), numpy.array(ye.image), numpy.array(yf.image),\ numpy.array(yg.image),numpy.array(yh.image), numpy.array(yi.image), numpy.array(yj.image), \ numpy.array(yk.image), numpy.array(yl.image), numpy.array(ym.image), numpy.array(yn.image), \ numpy.array(yo.image), numpy.array(yp.image) Xa, Ya, Za = reg.register(xa, ya) Xb, Yb, Zb = reg.register(xb, yb) Xc, Yc, Zc = reg.register(xc, yc) Xd, Yd, Zd = reg.register(xd, yd) Xe, Ye, Ze = reg.register(xe, ye) Xf, Yf, Zf = reg.register(xf, yf) Xg, Yg, Zg = reg.register(xg, yg) Xh, Yh, Zh = reg.register(xh, yh) Xi, Yi, Zi = reg.register(xi, yi) Xj, Yj, Zj = reg.register(xj, yj) Xk, Yk, Zk = reg.register(xk, yk) Xl, Yl, Zl = reg.register(xl, yl) Xm, Ym, Zm = reg.register(xm, ym) Xn, Yn, Zn = reg.register(xn, yn) Xo, Yo, Zo = reg.register(xo, yo) Xp, Yp, Zp = reg.register(xp, yp) xlength = IX.shape[1] / 4 ylength = IX.shape[0] / 4 Yb, Zb = Yb + [0, xlength], Zb + [0, xlength] Yc, Zc = Yc + [0, 2 * xlength], Zc + [0, 2 * xlength] Yd, Zd = Yd + [0, 3 * xlength], Zd + [0, 3 * xlength] Ye, Ze = Ye + [ylength, 0], Ze + [ylength, 0] Yf, Zf = Yf + [ylength, xlength], Zf + [ylength, xlength] Yg, Zg = Yg + [ylength, 2 * xlength], Zg + [ylength, 2 * xlength] Yh, Zh = Yh + [ylength, 3 * xlength], Zh + [ylength, 3 * xlength] Yi, Zi = Yi + [2 * ylength, 0], Zi + [2 * ylength, 0] Yj, Zj = Yj + [2 * ylength, xlength], Zj + [2 * ylength, xlength] Yk, Zk = Yk + [2 * ylength, 2 * xlength ], Zk + [2 * ylength, 2 * xlength] Yl, Zl = Yl + [2 * ylength, 3 * xlength ], Zl + [2 * ylength, 3 * xlength] Ym, Zm = Ym + [3 * ylength, 0], Zm + [3 * ylength, 0] Yn, Zn = Yn + [3 * ylength, xlength], Zn + [3 * ylength, xlength] Yo, Zo = Yo + [3 * ylength, 2 * xlength ], Zo + [3 * ylength, 2 * xlength] Yp, Zp = Yp + [3 * ylength, 3 * xlength ], Zp + [3 * ylength, 3 * xlength] Yr = numpy.concatenate( (Ya, Yb, Yc, Yd, Ye, Yf, Yg, Yh, Yi, Yj, Yk, Yl, Ym, Yn, Yo, Yp), axis=0) Zr = numpy.concatenate( (Za, Zb, Zc, Zd, Ze, Zf, Zg, Zh, Zi, Zj, Zk, Zl, Zm, Zn, Zo, Zp), axis=0) registered, nlm = tps_warp(Yr, Zr, registered1, IX.shape, nlm) nlm = nlm / (scale_percent / 100) return registered, nlm
def SignUPBtn(self): self.window = QtWidgets.QMainWindow() self.OpenSignUp = Registration.RegisterationForm() self.OpenSignUp.setupUi(self.window) self.window.show()
def openRegister(self): reg = Registration.Register() return
#datadir = '../../data/RemoteSense/TEST/' #datadir = '/Users/yzhq/Code/MATLAB/data/RemoteSense/TEST/' datadir = '/Users/yzhq/Code/data/' IX_path = datadir + '1.png' IY_path = datadir + '1.1.png' IX = cv2.imread(IX_path) IY = cv2.imread(IY_path) shape_arr = np.array(IX.shape[:2]) center = shape_arr / 2.0 for i in range(1): name = Registration.names[3 + i] print(name) reg = Registration.get_reg_by_name(name) reg.init_thres = 1.07 start_time = time.time() X, Y, T = reg.register(IX, IY) print("total %s seconds" % (time.time() - start_time)) try: start_time = time.time() registered = tps_warp(Y, T, IY, IX.shape) cb = checkboard(IX, registered, 11) print("warp and checkboard cost %s seconds" % (time.time() - start_time)) plt.subplot(111 + i) plt.title(name) plt.imshow(cv2.cvtColor(cb, cv2.COLOR_BGR2RGB))
def movetoUserReg(self): self.window3 = QtWidgets.QMainWindow() self.regUI = Registration.Ui_jobSeekerLogin() self.regUI.setupUi(self.window3) self.window3.show()
from __future__ import print_function import Registration import matplotlib.pyplot as plt from utils.utils import * import cv2 # designate image path here IX_path = '../img/1a.jpg' IY_path = '../img/1b.jpg' IX = cv2.imread(IX_path) IY = cv2.imread(IY_path) #initialize reg = Registration.CNN() #register X, Y, Z = reg.register(IX, IY) #generate regsitered image using TPS registered = tps_warp(Y, Z, IY, IX.shape) cb = checkboard(IX, registered, 11) plt.subplot(131) plt.title('reference') plt.imshow(cv2.cvtColor(IX, cv2.COLOR_BGR2RGB)) plt.subplot(132) plt.title('registered') plt.imshow(cv2.cvtColor(registered, cv2.COLOR_BGR2RGB)) plt.subplot(133) plt.title('checkboard') plt.imshow(cv2.cvtColor(cb, cv2.COLOR_BGR2RGB))
def register_clicked(self, e): self.Hide() print("Let's Register!") self.myregister = Registration.Registration(self, "Registration") self.myregister.main()
import scipy.io as sio #datadir = '/media/yzhq/TOSHIBA/data/Registration/UAVs/' datadir = '../../data/UAVs/' matoutdir = datadir + 'matout/' name1 = '21a' name2 = '21b' ext = '.jpg' IX_path = datadir + name1 + ext IY_path = datadir + name2 + ext IX = cv2.imread(IX_path) IY = cv2.imread(IY_path) IY = cv2.resize(IY, (IX.shape[1], IX.shape[0])) fex = Registration.CNN_feature() stime = time.time() X, Y = fex.extract(IX, IY) print(time.time()-stime) print(X.shape[0]) colors = np.random.rand(X.shape[0]) plt.imshow(cv2.cvtColor(IX, cv2.COLOR_BGR2RGB)) plt.scatter(X[:, 1], X[:, 0], s=20, marker='o', c=colors) plt.show() plt.imshow(cv2.cvtColor(IY, cv2.COLOR_BGR2RGB)) plt.scatter(Y[:, 1], Y[:, 0], s=20, marker='o', c=colors) plt.show() # outfile = name1 + '_' + name2 + '.mat'
# get list of current topics and active subscriptions cur_topics = rospy.get_published_topics() rospy.loginfo("cur_topics:") rospy.loginfo(cur_topics) activeSubscriptions = reg.Registration.get_active_subscriptions() rospy.loginfo("activeSubscriptions:") rospy.loginfo(activeSubscriptions) # look for new topics and register new ones for topic in cur_topics: rospy.loginfo("checking: {} {} {} ".format(str(topic), str(topic[0]), str(topic[1]))) if topic[1] == 'std_msgs/Int16MultiArray': rospy.loginfo("found valid topic to subscribe to") if topic[0] not in activeSubscriptions: rospy.loginfo("{} is not active".format(topic[0])) reg.Registration(topic[0]) # look for topics that are no longer being published activeSubscriptions = reg.Registration.get_active_subscriptions() cur_topics = [x[0] for x in rospy.get_published_topics()] rospy.loginfo("cur_topics:") rospy.loginfo(cur_topics) rospy.loginfo("activeSubscriptions:") rospy.loginfo(activeSubscriptions) for activeTopic in activeSubscriptions: rospy.loginfo("Checking: {}".format(activeTopic)) if activeTopic not in cur_topics: reg.Registration.unRegisterCamera(activeTopic) rate.sleep() # this will 'pulse' the loop at the rate