Exemple #1
0
def validateInstaUser(username, num_jitters):
    images = getInstaLinks(username)
    if len(images) >= cfg.instaLimit():
        images = images[:cfg.instaLimit()]
    r = FaceRecog(username, images, num_jitters=num_jitters)
    r.loadKnown(username)
    profile_links, _ = r.getValidLinksAndImg(username)
    return len(profile_links) > 0
Exemple #2
0
def main(skipFB=False, skipY=False, FBUrls=[], jsonRep=None):
    if not skipFB:
        # collect user input
        console.prompt('Enter the persons name to find on FB: ')
        name = input('')
        while not name:
            console.prompt('Enter the persons name to find on FB: ')
            name = input('')
    else:
        console.task('Skipping FB Search')
        name = "Unknown"

    console.prompt(
        'How many jitters, higher is better [max 100] (default=70): ')
    num_jitters = input('')
    if not num_jitters:
        console.task('Settings jitters to 70')
        num_jitters = 70
    num_jitters = int(num_jitters)
    if num_jitters > 100:
        console.subfailure('Dude wtf?!')
        num_jitters = 100
        console.subfailure('Using 100 jitters...')

    if not skipFB:
        # grab profile urls
        f = FBGrabber(name)
        f.grabData()
        # do face recognition on those profile images
        r = FaceRecog(f.getProfileLinks(),
                      f.getProfileImages(),
                      num_jitters=num_jitters)
        r.loadKnown(name)
        profile_links, profile_imgs = r.getValidLinksAndImg(name)
        console.section('Result')
        console.task('Found the following Profiles:')
        for i in range(len(profile_links)):
            console.subtask(profile_links[i])
    else:
        if len(FBUrls) > 0:
            f = FBProfileGrabber(FBUrls)
            img_urls = f.grabLinks()
            #FBURLS are our profile links synchron with img_urls
            # so FBURLS[0] <=> img_urls[0]
            r = FaceRecog(FBUrls, img_urls, num_jitters=num_jitters)
            r.loadKnown(name)
            profile_links, profile_imgs = r.getValidLinksAndImg(name)
            console.section('Result')
            console.task('Found the following Profiles:')
            for i in range(len(profile_links)):
                console.subtask(profile_links[i])
        else:
            profile_links = []
            profile_imgs = []

    # google reverse image search on profile pics
    g = GoogleGrabber()
    for img in profile_imgs:
        g.collectLinks(img)

    # google reverse image search on reference pic
    g.collectLinksLocal()
    rev_links, predictions = g.finish()

    #TODO: Fix yandex search
    #if not skipY:
    if False:
        yandex = YandexGrabber()
        for img in profile_imgs:
            yandex.collectLinks(img)
        yandex.collectLinksLocal()
        #add to rev_links
        for e in yandex.finish():
            rev_links.append(e)
    else:
        console.task('Skipping Yandex Search')
    rev_links = list(set(rev_links))

    instaNames = parseInstaUsername(filterInstaLinks(rev_links))
    validatedInstaNames = []
    console.section("Validating Instagram Profiles")
    for un in instaNames:
        console.task("Validating Profile: '{0}'".format(un))
        if validateInstaUser(un, num_jitters):
            validatedInstaNames.append(un)

    raider_img_list = profile_imgs
    for v in validatedInstaNames:
        l = getInstaLinks(v)

        for li in l:
            raider_img_list.append(li)

    if len(raider_img_list) <= 0:
        console.failure('No Links found...')
    else:
        console.task('RIP Imageraider')

    rev_links = list(set(rev_links))
    predictions = list(set(predictions))
    console.section('Links')
    print(rev_links)
    console.section('Predictions')
    try:
        predictions = [x.lower() for x in predictions]
    except:
        predictions = []
    print(predictions)
    presentResult(predictions)

    for pl in profile_links:
        rev_links.append(pl)
    rev_links = list(set(rev_links))

    #estimate age
    ageEstimator = PictrievGrabber()
    if len(validatedInstaNames) > 0:
        for v in validatedInstaNames:
            l = getInstaLinks(v)
            if len(l) >= cfg.instaLimit():
                l = l[:cfg.instaLimit()]
            for li in l:
                ageEstimator.collectAges(li)
        age = ageEstimator.finish()
    else:
        console.failure('No Instagram Images to upload...')
        #ageEstimator.finish()
        age = "Unknown"

    if jsonRep:
        console.section("Dumping JSON Report")
        makeJSONReport(name, rev_links, predictions, validatedInstaNames, age,
                       jsonRep)
    else:
        console.section("Creating PDF Report")
        makeReport(name, rev_links, predictions, validatedInstaNames, age)

    p = os.path.join(tempfile.gettempdir(), 'imageraider')
    if os.path.isdir(p):
        pathlist = Path(p).glob('**/*')
        for path in pathlist:
            s_p = str(path)
            os.remove(s_p)
    console.task("KTHXBYE")
Exemple #3
0
from control_psi import ControlPsi
from face_recog import FaceRecog
from face_track import FaceTrack
from sound_track import SoundTrack
from room_brightness import RoomBrightness
from saliency_track import SaliencyTrack
from tts_feedback import TTSFeedback

rospy.init_node("OpenCog_ROS_bridge")
logging.info("Starting the OpenCog ROS Bridge")
print "Starting the OpenCog ROS Bridge"

co = Control()
cp = ControlPsi()
af = Affect()
ap = AudioPower()
ct = ChatTrack()
fc = FaceRecog()
ft = FaceTrack()
st = SoundTrack()
br = RoomBrightness()
sl = SaliencyTrack()
tf = TTSFeedback

try:
    rospy.spin()
except rospy.ROSInterruptException as e:
    print(e)

print "Exit OpenCog ROS bridge"
Exemple #4
0
 def __init__(self):
     # initialize the video stream and allow the camera sensor to warm up
     print("[INFO] starting video stream...")
     self.vs = VideoStream(usePiCamera=False).start()
     self.face_recog = FaceRecog()
Exemple #5
0
class Camera(object):

    def __init__(self):
        # initialize the video stream and allow the camera sensor to warm up
        print("[INFO] starting video stream...")
        self.vs = VideoStream(usePiCamera=False).start()
        self.face_recog = FaceRecog()

    def adjust_gamma(self, image, gamma=0.5):
        # build a lookup table mapping the pixel values [0, 255] to
        # their adjusted gamma values
        invGamma = 1.0 / gamma
        table = np.array([((i / 255.0) ** invGamma) * 255 for i in np.arange(0, 256)]).astype("uint8")
        # apply gamma correction using the lookup table
        return cv2.LUT(image, table)

    def get_frame(self):

        current_barcode = []
        frame = self.vs.read()
        if frame is None:
            return frame, []

        rgb_frame = imutils.resize(frame, width=500)
        frame = cv2.cvtColor(rgb_frame, cv2.COLOR_BGR2GRAY)
        # reduce brightness
        frame = self.adjust_gamma(frame)

        # find the barcodes in the frame and decode each of the barcodes
        barcodes = pyzbar.decode(frame)

        # loop over the detected barcodes
        for barcode in barcodes:
            # extract the bounding box location of the barcode and draw
            # the bounding box surrounding the barcode on the image
            (x, y, w, h) = barcode.rect
            cv2.rectangle(frame, (x, y), (x + w, y + h), (0, 0, 255), 2)

            # the barcode data is a bytes object so if we want to draw it
            # on our output image we need to convert it to a string first
            barcodeData = barcode.data.decode("utf-8")
            barcodeType = barcode.type

            # draw the barcode data and barcode type on the image
            text = "{} ({})".format(barcodeData, barcodeType)
            cv2.putText(frame, text, (x, y - 10),
                        cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 0, 255), 2)

            current_barcode.append(barcodeData)
            print('barcodedata: {}'.format(barcodeData))

        faces = self.face_recog.process(rgb_frame, draw_on_frame=False)
        for face in faces:
            top, right, bottom, left = face.get('location')
            name = face.get('name')
            # Draw a box around the face
            cv2.rectangle(frame, (left, top), (right, bottom), (0, 0, 255), 2)

            # Draw a label with a name below the face
            cv2.rectangle(frame, (left, bottom - 35), (right, bottom), (0, 0, 255), cv2.FILLED)
            font = cv2.FONT_HERSHEY_DUPLEX
            cv2.putText(frame, name, (left + 6, bottom - 6), font, 1.0, (255, 255, 255), 1)

        ret, jpeg = cv2.imencode('.jpg', frame)

        return jpeg.tobytes(), current_barcode

    def __del__(self):
        # close the output CSV file do a bit of cleanup
        print("[INFO] cleaning up...")
        cv2.destroyAllWindows()
Exemple #6
0
def main():
    # collect user input
    console.prompt('Enter the persons name to find on FB: ')
    name = input('')

    console.prompt('How many jitters, higher is better [max 100]: ')
    num_jitters = input('')
    num_jitters = int(num_jitters)
    if num_jitters > 100:
        console.subfailure('Dude wtf?!')
        num_jitters = 100
        console.subfailure('Using 100 jitters...')

    # grab profile urls
    f = FBGrabber(name)
    f.grabData()

    # do face recognition on those profile images
    r = FaceRecog(f.getProfileLinks(), f.getProfileImages(), num_jitters=num_jitters)
    r.loadKnown(name)

    profile_links, profile_imgs = r.getValidLinksAndImg(name)
    console.section('Result')
    console.task('Found the following Profiles:')
    for i in range(len(profile_links)):
        console.subtask(profile_links[i])

    # google reverse image search on profile pics
    g = GoogleGrabber()
    for img in profile_imgs:
        g.collectLinks(img)

    # google reverse image search on reference pic
    g.collectLinksLocal()
    rev_links, predictions = g.finish()

    yandex = YandexGrabber()
    for img in profile_imgs:
        yandex.collectLinks(img)
    
    #add to rev_links
    for e in yandex.finish():
        rev_links.append(e)
    rev_links = list(set(rev_links))

    instaNames = parseInstaUsername(filterInstaLinks(rev_links))
    validatedInstaNames = []
    console.section("Validating Instagram Profiles")
    for un in instaNames:
        console.task("Validating Profile: '{0}'".format(un))
        if validateInstaUser(un, num_jitters):
            validatedInstaNames.append(un)
    

    raider_img_list = profile_imgs
    for v in validatedInstaNames:
        l = getInstaLinks(v)
        for li in l:
            raider_img_list.append(li)

    if len(raider_img_list) <= 0:
        console.failure('No Links founds...')
    else:
        raider = ImageRaiderGrabber()
        raider.insertImageLinks(raider_img_list)
        raider.downloadCSV()
        raider_links = raider.processCSV()
        for raider_link in raider_links:
            rev_links.append(raider_link)


    rev_links = list(set(rev_links))
    predictions = list(set(predictions))
    console.section('Links')
    print(rev_links)
    console.section('Predictions')
    try:
        predictions = [x.lower() for x in predictions]
    except:
        predictions = []
    print(predictions)
    presentResult(predictions)
    

    console.section("Creating PDF Report")
    makeReport(name, rev_links, predictions, validatedInstaNames)


    p = os.path.join(tempfile.gettempdir(), 'imageraider')
    if os.path.isdir(p):
        pathlist = Path(p).glob('**/*')
        for path in pathlist:
            s_p = str(path)
            os.remove(s_p)
    console.task("KTHXBYE")
from face_recog import FaceRecog
#from PAB_Vision.Machine_Learning.bot.botAPI import *
import cv2
import face_recognition
#botResponseReciever("Friend Shyam")
face_recog = FaceRecog()
#frame = face_recognition.load_image_file("G:\\shyam\\Pictures\\Camera Roll\\test\\shyam\\pic.jpg")
#frame = cv2.imread("G:\\shyam\\Pictures\\Camera Roll\\test\\shyam\\pic.jpg")
#frame = frame[:, :, ::-1]
#frame = cv2.resize(frame, (0, 0), fx=0.25, fy=0.25)
#print(face_recog.render_frame(frame))
face_recog.start_video(detect_faces=True)
#face_recog.add_new_face("Shyam", frame)