Example #1
0
def main():

    selection = dialogs.alert('Type', '', 'Encrypt', 'Decrypt')
    if selection == 1:
        i = dialogs.alert('Image', '', 'Take Photo', 'Select from Photos')
        if i == 1:
            im = photos.capture_image()
        else:
            im = photos.pick_image()

        im.thumbnail(
            (430, 430)) if im.size[0] > 430 or im.size[1] > 430 else None

        # im, im_arr = load_image("Test.img")
        im_arr = im.load()
        x_size, y_size = im.size
        basic_encrypt_scramble(im_arr, x_size, y_size)
        two_key_encryption(im_arr, x_size, y_size, 123, 4574574)
        im.show()
        save_image(input("Name (example.png):"), im)

    else:
        i = dialogs.alert('Image', '', 'Load Image', 'Select from Photos')
        if i == 1:
            im = Image.open(input("Name (example.png): "))
        else:
            im = photos.pick_image()
        n, d = (int(num) for num in input("(n, d) = ").split(","))
        im_arr = im.load()
        x_size, y_size = im.size

        two_key_decryption(im_arr, x_size, y_size, 123, 4574574)
        basic_decrypt_unscramble(im_arr, x_size, y_size, n, d)
        im.show()
        save_image(input("Name (example.png): "), im)
Example #2
0
 async def acquire(self, instance, value):
     image = photos.capture_image()
     # resize to (width, height)
     image = image.resize((image_width, image_height))
     # and convert to grayscale
     image_array = np.dot(np.asarray(image)[..., :3], [0.299, 0.587, 0.114])
     await self.image.write(image_array.flatten().astype(np.uint32))
Example #3
0
 def take_a_selfie(self, filename='.temp.jpg'):
     self.name = raw_input()
     self.selfie = raw_input()
     if 'selfie' in self.selfie:
         img = photos.capture_image()
         if img:
             img.save(filename)
             console.show_image(filename)
             speech.say(self.name + ', you look stunning!')
             print self.name + ', you look stunning!'
             speech.say(
                 'Would you like to save your master piece in a custom album?'
             )
             print 'Would you like to save your master piece in a custom album?'
             self.to_save_or_not_to_save = raw_input()
             if 'ye' in self.to_save_or_not_to_save:
                 photos.create_album(self.name + 's Album')
                 speech.say(
                     'Okay. I have created your own custom album to save your legendary pic.'
                 )
                 print 'Okay. I have created your own custom album to save your legendary pic.'
                 speech.say(
                     'Hold the image to save your elegant pic in your custom album'
                 )
                 print 'Hold the image to save your elegant pic in your custom album'
                 self.idle()
             else:
                 speech.say(
                     'Affirmative... Your photo will be deleted after this session.'
                 )
                 print 'Affirmative... Your photo will be deleted after this session.'
                 self.idle()
     console.clear()
Example #4
0
def act(sender):
    nv = sender.navigation_view
    p = photos.capture_image()
    #Generate maze map from image
    image = mazeGen.finalScan(p.resize((320, 240)))

    def f_handle(image):
        '''Callback function for MazeEditView'''
        global edited, sev
        edited = image

        def f_handle_2(start, end):
            sol = SolutionView(edited, start, end)
            nv.push_view(sol)

        sev = StartEndView(image=edited, finished_handler=f_handle_2)
        sev.name = 'Step 3: Mark Start and End Points'
        sev.right_button_items = [
            ButtonItem(title='Continue', action=sev.finish)
        ]
        nv.push_view(sev)

    #View for editing scan, f_handle is callback for returning edited image
    mev = MazeEditView(image=image, finished_handler=f_handle)
    mev.name = 'Step 2: Fix Mistakes'
    mev.right_button_items = [ButtonItem(title='Continue', action=mev.finish)]
    nv.push_view(mev)
    #Problem is here because mev is not closed automatically, code that closes is after wait modal. fix by pushing new view from within callback function.
    mev.wait_modal()
    sev.wait_modal()
    edited.show()
Example #5
0
def photoButton(sender):
    global Hint
    global CurrentHintID
    global CurrentHint
    global photoImage
    global mustSave
    KillGPSView()

    image = photos.capture_image()

    mustSave = True

    CreateGPSView()
    wi = photoImage.width
    hi = (int)(photoImage.width * image.height / image.width)

    img2 = image.resize((wi, hi), Image.ANTIALIAS)
    img2.save(AdventureFolder + '/photo_hint_' + str(CurrentHintID) + '.jpg',
              'jpeg')
    # convert the Image to PNG string
    img_buf = BytesIO()
    img2.save(img_buf, 'jpeg')
    img = img_buf.getvalue()
    sender.superview['photoview'].image = ui.Image.from_data(img)
    refreshEditorItems(True)
def decode():
    i = dialogs.alert('Image', '', 'Take Photo', 'Load Image',
                      'Select from Photos')
    if i == 1:
        im = photos.capture_image()
    elif i == 2:
        im = Image.open(input("Name (example.png): "))
    else:
        im = photos.pick_image()

    data = ''
    imgdata = iter(im.getdata())

    while (True):
        pixels = [
            value for value in imgdata.__next__()[:3] +
            imgdata.__next__()[:3] + imgdata.__next__()[:3]
        ]
        # string of binary data
        binstr = ''

        for i in pixels[:8]:
            if (i % 2 == 0):
                binstr += '0'
            else:
                binstr += '1'

        data += chr(int(binstr, 2))
        if (pixels[-1] % 2 != 0):
            return data
Example #7
0
def act(sender):
	nv = sender.navigation_view
	p = photos.capture_image()
	#Generate maze map from image
	image = mazeGen.finalScan(p.resize((320, 240)))
	
	def f_handle(image):
		'''Callback function for MazeEditView'''
		global edited, sev
		edited = image
		def f_handle_2(start, end):
			sol = SolutionView(edited, start, end)
			nv.push_view(sol)
		sev = StartEndView(image=edited, finished_handler=f_handle_2)
		sev.name = 'Step 3: Mark Start and End Points'
		sev.right_button_items = [ButtonItem(title='Continue', action=sev.finish)]
		nv.push_view(sev)
		
	#View for editing scan, f_handle is callback for returning edited image	
	mev = MazeEditView(image=image, finished_handler=f_handle)
	mev.name = 'Step 2: Fix Mistakes'
	mev.right_button_items = [ButtonItem(title='Continue', action=mev.finish)]
	nv.push_view(mev)
	#Problem is here because mev is not closed automatically, code that closes is
	# after wait modal. fix by pushing new view from within callback function. 
	mev.wait_modal()
	sev.wait_modal()
	edited.show()
Example #8
0
def PythonistaTest():
    '''A test of the module for iOS devices running Pythonista'''
    import console, photos, clipboard
    #Ask the user to either take a photo or choose an existing one
    capture = console.alert("Image2ASCII",
                            button1="Take Photo",
                            button2="Pick Photo")
    if capture == 1:
        im = photos.capture_image()
    elif capture == 2:
        im = photos.pick_image(original=False)
    photos.save_image(im)
    console.show_activity()
    out = image2ASCII(im, 200)
    outim = RenderASCII(out, bgcolor='#ededed')
    stitchImages(im, outim).show()
    console.hide_activity()
    outim.save('image.jpg')
    console.quicklook('image.jpg')
    mode = console.alert("Image2ASCII", "You can either:", "Share Text",
                         "Share Image")
    if mode == 1:
        file = open('output.txt', 'w')
        file.write(out)
        file.close()
        console.open_in('output.txt')
    elif mode == 2:
        console.open_in('image.jpg')
    time.sleep(5)
    console.clear()
Example #9
0
def PythonistaTest():
	'''A test of the module for iOS devices running Pythonista'''
	import console,photos,clipboard
	#Ask the user to either take a photo or choose an existing one
	capture = console.alert("Image2ASCII", button1="Take Photo", button2="Pick Photo")
	if capture == 1:
		im = photos.capture_image()
	elif capture == 2:
		im = photos.pick_image(original=False)
	photos.save_image(im)
	console.show_activity()
	out = image2ASCII(im, 200)
	outim = RenderASCII(out, bgcolor = '#ededed')
	stitchImages(im, outim).show()
	console.hide_activity()
	outim.save('image.jpg')
	console.quicklook('image.jpg')
	mode = console.alert("Image2ASCII", "You can either:","Share Text","Share Image")
	if mode == 1:
		file = open('output.txt', 'w')
		file.write(out)
		file.close()
		console.open_in('output.txt')
	elif mode == 2:
		console.open_in('image.jpg')
	time.sleep(5)
	console.clear()
Example #10
0
def get_user_photo(in_allow_none = True):
    ''' Prompts the user to take a photo and returns the image '''
    user_photo = photos.capture_image()
    if user_photo or in_allow_none:
        return user_photo
    Error = 'You are not allowed to cancel taking the photograph at this time.'
    console.hud_alert(Error, 'error')
    return get_user_photo(in_allow_none)
Example #11
0
def get_user_photo(in_allow_none=True):
    ''' Prompts the user to take a photo and returns the image '''
    user_photo = photos.capture_image()
    if user_photo or in_allow_none:
        return user_photo
    Error = 'You are not allowed to cancel taking the photograph at this time.'
    console.hud_alert(Error, 'error')
    return get_user_photo(in_allow_none)
Example #12
0
 def take_photo(self, sender):
     self.img = photos.capture_image()
     if self.img:
         time_now = datetime.datetime.now().strftime('%c')
         photo_hash = hashlib.sha1(time_now.encode('UTF-8')).hexdigest()
         self.card_photo_path = 'capture/' + photo_hash + '.jpeg'
         self.values[sender.name] = self.card_photo_path
         self.img.save(self.card_photo_path)
     """
Example #13
0
 def __init__(self):
     self.img = photos.capture_image()
     #all_assets = photos.get_assets()
     #last_asset = all_assets[-1]
     #self.img = last_asset.get_image()
     self.img = self.img.convert("L")
     self.img = ImageOps.invert(self.img)
     self.miniimg = self.img.copy()
     self.miniimg = self.miniimg.resize(
         (round(self.img.width * 0.2), round(self.img.height * 0.2)))
Example #14
0
def takePhoto_action(sender):
    ph = photos.capture_image()
    if ph is None:
        return
    if sender.superview.name == 'fuckupcolors':
        sender.superview['fuckUpSlider'].value = 0
    if sender.superview.name == 'shift':
        sender.superview['shiftSlider1'].value = 0
        sender.superview['shiftSlider2'].value = 0
    if sender.superview.name == 'color':
        sender.superview['rSlider'].value = 0
        sender.superview['gSlider'].value = 0
        sender.superview['bSlider'].value = 0
    sender.superview['imageview1'].image, buff = from_norm_to_ui(ph)
    buff.close()
def encode(msg):
    i = dialogs.alert('Image', '', 'Take Photo', 'Load Image',
                      'Select from Photos')
    if i == 1:
        im = photos.capture_image()
    elif i == 2:
        im = Image.open(input("Name (example.png): "))
    else:
        im = photos.pick_image()

    newimg = im.copy()
    encode_enc(newimg, msg)
    newimg.show()
    new_img_name = input("Name (example.png): ")
    newimg.save(new_img_name, str(new_img_name.split(".")[1].upper()))
    print("Image saved")
Example #16
0
def displayConvertedData(sender):

    pil_img = photos.capture_image()

    if pil_img is None:
        return

    size = (int(pil_img.size[0] * 0.3), int(pil_img.size[1] * 0.3))
    pil_img = pil_img.resize(size)

    img = io.BytesIO()
    pil_img.save(img, "JPEG")
    img_byte = img.getvalue()
    doc = ocr.getDoc(img_byte)
    lines = doc.split('.')

    textview = sender.superview['textview']
    for line in lines:
        if line is not None:
            textview.text += '\n\n' + line + "."
            textview.text += '\n\n*' + translator.translate(line + ".")
def encode():
    i = dialogs.alert('Image', '', 'Take Photo', 'Load Image',
                      'Select from Photos')
    if i == 1:
        im = photos.capture_image()
    elif i == 2:
        im = Image.open(input("Name (example.png): "))
    else:
        im = photos.pick_image()

    data = input("Enter data to be encoded: ")
    if (len(data) == 0):
        raise ValueError('Data is empty')

    newimg = im.copy()
    encode_enc(newimg, data)

    new_img_name = input("Name (example.png): ")
    newimg.show()
    newimg.save(new_img_name, str(new_img_name.split(".")[1].upper()))
    print("Image saved")
Example #18
0
    def touch_began(self, touch):

        current = location.get_location()
        latLong = (round(current['latitude'],
                         4), round(current['longitude'], 4)
                   )  #solved the close points problem using rounding
        picTaken = latLong in self.photoLocations

        x, y = touch.location

        if self.imageModeOpen == True:
            self.imageModeOpen = False
            self.img.hidden = True

        if self.loopPrompt == True:
            if x > 50 and x < self.size.x / 2 and y < self.size.y / 2 and y > self.size.y / 2 - 50:
                self.loopPrompt = False
                self.loopPromptState = 1
            elif x > self.size.x / 2 and x < self.size.x - 50 and y < self.size.y / 2 and y > self.size.y / 2 - 50:
                self.loopPrompt = False
                self.loopPromptState = 2

        elif self.MoreState == True:
            #SOS State
            if x < self.size.w / 2 + 30 and x > self.size.w / 2 - 30 and y > 50 and y < 100 and self.MoreState == True:
                webbrowser.open('tel:911')

            #MapView
            elif x < 100 and x > 50 and y < 220 and y > 160 and len(
                    self.locations) >= 2:
                googleMapsMaxPoints = 20
                mapLocations = copy.deepcopy(self.locations)
                if len(self.locations) > googleMapsMaxPoints:
                    mapLocations = []
                    jump = math.ceil(len(self.locations) / googleMapsMaxPoints)
                    for i in range(0, len(self.locations), jump):
                        mapLocations += [self.locations[i]]
                self.query = 'safari-https://www.google.com/maps/dir/'
                for loc in mapLocations:
                    self.query += str(loc[0])
                    self.query += ","
                    self.query += str(loc[1])
                    self.query += "/"
                self.query = self.query[:-1]
                webbrowser.open(self.query)

            elif x < self.size.x / 2 + 40 and x > self.size.x / 2 - 40 and y < 220 and y > 160 and len(
                    self.locations) >= 2:
                googleMapsMaxPoints = 20
                mapLocations = copy.deepcopy(self.locations)
                if len(self.locations) > googleMapsMaxPoints:
                    mapLocations = []
                    jump = math.ceil(len(self.locations) / googleMapsMaxPoints)
                    for i in range(0, len(self.locations), jump):
                        mapLocations += [self.locations[i]]
                self.query = 'safari-https://www.google.com/maps/dir/'
                for loc in mapLocations:
                    self.query += str(loc[0])
                    self.query += ","
                    self.query += str(loc[1])
                    self.query += "/"
                self.query = self.query[:-1]
                clipboard.set(self.query[7:])
                self.clipState = True

            elif x < self.size.x - 50 and x > self.size.x - 100 and y < 220 and y > 160 and len(
                    self.locations) > 2:
                self.pathState = True

            else:
                self.MoreState = False
                self.clipState = False
                self.pathState = False

        #open landmark
        elif y > 150 and y < 200 and self.imageMode == True:
            sound.play_effect('arcade:Laser_2')
            self.imageModeOpen = True
            self.imageMode = False

            self.heightFrame = (self.photoHeight /
                                self.photoWidth) * (self.size.x)
            self.widthFrame = (self.photoWidth /
                               self.photoWidth) * (self.size.x)

            self.heightPhoto = (self.photoHeight /
                                self.photoWidth) * (self.size.x - 20)
            self.widthPhoto = (self.photoWidth /
                               self.photoWidth) * (self.size.x - 20)

            self.halfScreenFrame = self.size.y / 2 - self.heightFrame / 2
            self.halfScreen = self.size.y / 2 - self.heightPhoto / 2

            self.img = ui.Button(name='image')
            self.img.frame = (10, self.halfScreen, self.widthPhoto,
                              self.heightPhoto)
            self.img.background_image = self.ui_image
            self.img.enable = False
            self.img.hidden = False
            self.view.add_subview(self.img)

        elif y < 150 and y > 200 and self.imageMode == True:
            self.imageMode = False

        #reset button
        elif x < 100 and x > 50 and y < 100 and y > 50:
            self.measuringOn = False
            self.checkedOnce = 0
            self.background_color = self.theme["backgroundColor"]
            self.locations = []
            self.needMore = False
            self.photoCount = 0
            self.photoLocations = []
            self.locationsLeft = []
            self.needMore = False
            self.timerCount = 0

        #more button
        elif x < self.size.w / 2 + 25 and x > self.size.w / 2 - 25 and y < 30 and y > 0:
            self.MoreState = True

        #take photos and add to album
        elif x < self.size.w / 2 + 30 and x > self.size.w / 2 - 30 and y > 50 and y < 100 and self.MoreState == False and self.measuringOn == True and picTaken == False:
            imageree = photos.capture_image()
            if imageree != None:
                photos.save_image(imageree)
                time.sleep(1)
                self.photoCount += 1
                allAssets = photos.get_assets()
                theImage = allAssets[-1]
                #print("Divider")
                # Find the album or create it:
                try:
                    self.photoLibrary = [
                        a for a in photos.get_albums() if a.title == 'Thread'
                    ][0]
                except IndexError:
                    self.photoLibrary = photos.create_album('Thread')
                # Add the file as an asset to the library:
                # asset = photos.create_image_asset(theImage)
                # Add the asset to the album:
                theImage = allAssets[len(allAssets) - 1]
                self.photoLibrary.add_assets([theImage])

                self.photoLocations += [latLong]

        #compass State: Letters (NWSE) or degrees
        elif x < 325 and x > 275 and y < 100 and y > 50:
            self.compassStat = not (self.compassStat)

        elif self.measuringOn == False and self.checkedOnce == 0:
            #sound.play_effect('arcade:Laser_2')
            self.measuringOn = True
            self.background_color = self.theme["backgroundColor"]
            self.checkedOnce += 1

        elif self.measuringOn == True and self.checkedOnce == 1 and len(
                self.locations) < 4:
            #sound.play_effect('arcade:Laser_1')
            self.needMore = True

        elif self.measuringOn == True and self.checkedOnce == 1 and len(
                self.locations) > 3:
            #sound.play_effect('arcade:Laser_1')
            self.needMore = False
            self.measuringOn = False
            self.background_color = self.theme["backgroundColor"]
            self.checkedOnce += 1

        elif self.measuringOn == False and self.checkedOnce == 3:
            #sound.play_effect('arcade:Laser_1')
            self.background_color = self.theme["backgroundColor"]
            self.checkedOnce += 1
Example #19
0
 def __init__(self):
     print('Executed')
     photos.capture_image()
Example #20
0
def imagetake(sender):
    im = photos.capture_image()
    if im:
        rootView.remove_subview(view1)
        main(im)
Example #21
0
 def take_photo_action(self, sender):
     image = photos.capture_image()
     photos.save_image(image)
Example #22
0
	def run(self):
		self.status = 'complete'
		#console.alert(title='Known Issue',message='Take Photo sometimes freezes the ui and pythonista needs to be killed.',button1='Ok',hide_cancel_button=True)
		time.sleep(.5)
		return ElementValue(type = self.get_output_type(), value = photos.capture_image())
Example #23
0
# --------------------

import ui
import photos


class Extracter(ui.View):
    def __init__(self):
        print('Executed')
        photos.capture_image()


if __name__ == '__main__':
    view = Extracter()
# --------------------

import ui
import photos

photos.capture_image()


class Extracter(ui.View):
    def __init__(self):
        print('Executed')


if __name__ == '__main__':
    view = Extracter()
# --------------------
Example #24
0
	
	im = Image.new("RGB", (width, height), "white")
	im.paste(im1, (0, 0))
	im.paste(im2, (w1, 0))
	
	return im



if __name__ == "__main__":
	while 1:
		#Ask the user to either take a photo or choose an existing one
		capture = console.alert("Image2ASCII", button1="Take Photo", button2="Pick Photo")
	
		if capture == 1:
			im = photos.capture_image()
		elif capture == 2:
			im = photos.pick_image(original=False)
		
		console.show_activity()
	
		out = image2ASCII(im, 200)
		outim = RenderASCII(out, bgcolor = '#ff0000')
		stitchImages(im, outim).show()
	
		console.hide_activity()
		
		outim.save('image.jpg')
		console.quicklook('image.jpg')
		
		mode = console.alert("Image2ASCII", "You can either:","Share Text","Share Image")
Example #25
0
def take_photo(filename='.temp.jpg'):
	img = photos.capture_image()
	if img:
		img.save(filename)
		return filename
Example #26
0
def take_photo(filename='.temp.jpg'):
    img = photos.capture_image()
    if img:
        img.save(filename)
        return filename
Example #27
0
    def touch_began(self, touch):
        sound.play_effect('Footstep')

        #creates a query of the locations recorded and opens it on google maps
        #because the query accepts at most around 20 points, if you have more
        #than 20 points it will create a new list and get points evenly spaced
        #throughout the path to a total of less than 20. Looks representative
        #and accurate.
        def mapView(self):
            googleMapsMaxPoints = 20
            mapLocations = copy.deepcopy(self.locations)
            if len(self.locations) > googleMapsMaxPoints:
                mapLocations = []
                jump = math.ceil(len(self.locations) / googleMapsMaxPoints)
                for i in range(0, len(self.locations), jump):
                    mapLocations += [self.locations[i]]
            self.query = 'safari-https://www.google.com/maps/dir/'
            for loc in mapLocations:
                self.query += str(loc[0])
                self.query += ","
                self.query += str(loc[1])
                self.query += "/"
            self.query = self.query[:-1]
            webbrowser.open(self.query)

        #when you run across a landmark (photo) you placed down, it will
        #notify you its present and you can tap to reveal the photo
        def openLandmark(self):
            sound.play_effect('Click_1')
            self.imageModeOpen = True
            self.imageMode = False

            self.heightPhoto = (self.photoHeight/self.photoWidth) * \
            (self.size.x-20)
            self.widthPhoto = (self.photoWidth/self.photoWidth) * \
            (self.size.x-20)

            self.heightFrame = self.heightPhoto + 10
            self.widthFrame = self.widthPhoto + 10

            self.halfScreenFrame = self.size.y / 2 - self.heightFrame / 2
            self.halfScreen = self.size.y / 2 - self.heightPhoto / 2

            #asked a question on the omz (Pythonista) forum and they answered!
            #'https://forum.omz-software.com/topic/5263/displaying-an-image-
            #from-album-in-photos-onto-screen-in-scene-module'
            #opens the image and has it hidden.
            self.img = ui.Button(name='image')
            self.img.frame = (10, self.halfScreen, self.widthPhoto,
                              self.heightPhoto)
            self.img.background_image = self.ui_image
            self.img.enable = False
            self.img.hidden = False
            self.view.add_subview(self.img)

        #when you tap, get the current location to perform functions
        current = location.get_location()
        #solved the close points problem using rounding
        latLong = (round(current['latitude'],
                         4), round(current['longitude'], 4))
        picTaken = latLong in self.photoLocations

        #get the location on the screen of the touch
        x, y = touch.location

        #if the image is open, close it when you tap (has to be off the image)
        if self.imageModeOpen == True:
            self.imageModeOpen = False
            self.img.hidden = True

        #if you have the loop Prompt, you must tap an answer in order to use
        #the other functions
        if self.loopPrompt == True:
            if x > 50 and x < self.size.x/2 and y < self.size.y/2 \
            and y > self.size.y/2 - 50:
                self.loopPrompt = False
                self.loopPromptState = 1
            elif x > self.size.x/2 and x < self.size.x-50 \
            and y < self.size.y/2 and y > self.size.y/2 - 50:
                self.loopPrompt = False
                self.loopPromptState = 2

        #when it has the more menu open, you must are not able to tap any of
        #the other buttons, other than the ones in the more menu
        elif self.MoreState == True:
            #SOS State tap, call the cops if you tap
            if x < self.size.w/2 + 30 and x > self.size.w/2 - 30 \
            and y > 50 and y < 100 and self.MoreState == True:
                webbrowser.open('tel:911')

            #MapView tap
            elif x < 100 and x > 50 and y < 220 and y > 160 and \
            len(self.locations) >= 2:
                mapView(self)

            #create the query, but make it a link for phone users, and copy
            #it to the clipboard
            elif x < self.size.x/2+40 and x > self.size.x/2-40 and \
            y < 220 and y > 160 and len(self.locations) >= 2:
                googleMapsMaxPoints = 20
                mapLocations = copy.deepcopy(self.locations)
                if len(self.locations) > googleMapsMaxPoints:
                    mapLocations = []
                    jump = math.ceil(len(self.locations) / googleMapsMaxPoints)
                    for i in range(0, len(self.locations), jump):
                        mapLocations += [self.locations[i]]
                self.query = 'safari-https://www.google.com/maps/dir/'
                for loc in mapLocations:
                    self.query += str(loc[0])
                    self.query += ","
                    self.query += str(loc[1])
                    self.query += "/"
                self.query = self.query[:-1]
                clipboard.set(self.query[7:])
                self.clipState = True

            #tap on Trace button to reveal the path
            elif x < self.size.x-50 and x > self.size.x-100 and y < 220 \
            and y > 160 and len(self.locations) > 2:
                self.pathState = True

            #tap on theme button to switch the theme
            elif x < self.size.w/2 + 30 and x > self.size.w/2 - 30 \
            and y > self.size.y-95-40 and y < self.size.y-95+40:
                self.themeSwitch += 1
                if self.themeSwitch % 2 == 0:
                    self.theme = self.lightMode
                elif self.themeSwitch % 2 == 1:
                    self.theme = self.darkMode

            #tap off a button while in the more menu, and it exits the menu
            else:
                self.MoreState = False
                self.clipState = False
                self.pathState = False

        #open landmark by tapping on the banner
        elif y > 150 and y < 200 and self.imageMode == True:
            openLandmark(self)

        #if in image mode, tap off the image to get rid of it off the screen
        elif y < 150 and y > 200 and self.imageMode == True:
            self.imageMode = False

        #reset button resets everything
        elif x < 100 and x > 50 and y < 100 and y > 50:
            self.measuringOn = False
            self.functionState = 0
            self.background_color = self.theme["backgroundColor"]
            self.locations = []
            self.needMore = False
            self.photoCount = 0
            self.photoLocations = []
            self.locationsLeft = []
            self.needMore = False
            self.timerCount = 0

        #more button is a small and out of the way, opens up more menu
        elif x < self.size.w/2 + 25 and x > self.size.w/2 - 25 and y < 30 \
        and y > 0:
            self.MoreState = True

        #take photos and add to album
        elif x < self.size.w/2 + 30 and x > self.size.w/2 - 30 \
        and y > 50 and y < 100 and self.MoreState == False and \
        self.measuringOn == True and picTaken == False:
            imageree = photos.capture_image()
            if imageree != None:
                #open up the camera and you can take photo
                photos.save_image(imageree)
                time.sleep(1)
                self.photoCount += 1
                allAssets = photos.get_assets()
                theImage = allAssets[-1]
                #if there is no album, create album 'Thread'
                try:
                    self.photoLibrary = [a for a in photos.get_albums() \
                    if a.title == 'Thread'][0]
                except IndexError:
                    self.photoLibrary = photos.create_album('Thread')

                #add the image to the album for the user to have and for
                #future use in the app's use (landmarks!)
                theImage = allAssets[len(allAssets) - 1]
                self.photoLibrary.add_assets([theImage])

                self.photoLocations += [latLong]

        #compass State: Letters (NWSE) or degrees
        elif x < 325 and x > 275 and y < 100 and y > 50:
            self.compassStat = not (self.compassStat)

        #go to measuring mode when tapped for the first time
        elif self.measuringOn == False and self.functionState == 0:
            self.measuringOn = True
            self.background_color = self.theme["backgroundColor"]
            self.functionState += 1

        #if you need more values do not let the user stop recording
        elif self.measuringOn == True and self.functionState == 1 \
        and len(self.locations) < 4:
            self.needMore = True

        #if you have enough locations, when you tap you can move to next state
        elif self.measuringOn == True and self.functionState == 1 \
        and len(self.locations) > 3:
            #sound.play_effect('arcade:Laser_1')
            self.needMore = False
            self.measuringOn = False
            self.background_color = self.theme["backgroundColor"]
            self.functionState += 1

        #move function state up to state 4 so you can begin tracing back
        elif self.measuringOn == False and self.functionState == 3:
            #sound.play_effect('arcade:Laser_1')
            self.background_color = self.theme["backgroundColor"]
            self.functionState += 1
def take_photo(filename='pic.jpg'):
    import photos
    img = photos.capture_image()
    if img:
        img.save(filename)
        return filename
Example #29
0
    def touch_began(self, touch):
        x, y = touch.location

        if self.loopPrompt == True:
            if x > 50 and x < self.size.x / 2 and y < self.size.y / 2 and y > self.size.y / 2 - 50:
                self.loopPrompt = False
                self.loopPromptState = 1
            elif x > self.size.x / 2 and x < self.size.x - 50 and y < self.size.y / 2 and y > self.size.y / 2 - 50:
                self.loopPrompt = False
                self.loopPromptState = 2

        elif self.MoreState == True:
            #SOS State
            if x < self.size.w / 2 + 30 and x > self.size.w / 2 - 30 and y > 50 and y < 100 and self.MoreState == True:
                webbrowser.open('tel:911')

            #MapView
            elif x < 100 and x > 50 and y < 220 and y > 160 and len(
                    self.locations) >= 2:
                googleMapsMaxPoints = 20
                mapLocations = copy.deepcopy(self.locations)
                if len(self.locations) > googleMapsMaxPoints:
                    mapLocations = []
                    jump = math.ceil(len(self.locations) / googleMapsMaxPoints)
                    for i in range(0, len(self.locations), jump):
                        mapLocations += [self.locations[i]]
                self.query = 'safari-https://www.google.com/maps/dir/'
                for loc in mapLocations:
                    self.query += str(loc[0])
                    self.query += ","
                    self.query += str(loc[1])
                    self.query += "/"
                self.query = self.query[:-1]
                webbrowser.open(self.query)

            elif x < self.size.x / 2 + 40 and x > self.size.x / 2 - 40 and y < 220 and y > 160 and len(
                    self.locations) >= 2:
                googleMapsMaxPoints = 20
                mapLocations = copy.deepcopy(self.locations)
                if len(self.locations) > googleMapsMaxPoints:
                    mapLocations = []
                    jump = math.ceil(len(self.locations) / googleMapsMaxPoints)
                    for i in range(0, len(self.locations), jump):
                        mapLocations += [self.locations[i]]
                self.query = 'safari-https://www.google.com/maps/dir/'
                for loc in mapLocations:
                    self.query += str(loc[0])
                    self.query += ","
                    self.query += str(loc[1])
                    self.query += "/"
                self.query = self.query[:-1]
                clipboard.set(self.query[7:])
                self.clipState = True

            elif x < self.size.x - 50 and x > self.size.x - 100 and y < 220 and y > 160:
                self.pathState = True

            else:
                self.MoreState = False
                self.clipState = False
                self.pathState = False

        #reset button
        elif x < 100 and x > 50 and y < 100 and y > 50:
            self.measuringOn = False
            self.checkedOnce = 0
            self.background_color = 'white'
            self.locations = []
            self.needMore = False

        #more button
        elif x < self.size.w / 2 + 25 and x > self.size.w / 2 - 25 and y < 30 and y > 0:
            self.MoreState = True

        elif x < self.size.w / 2 + 30 and x > self.size.w / 2 - 30 and y > 50 and y < 100 and self.MoreState == False:
            imageree = photos.capture_image()
            photos.save_image(imageree)
            time.sleep(3)
            self.photoCount += 1
            all_assets = photos.get_assets()
            theImage = all_assets[-1]
            #print("Divider")
            # Find the album or create it:
            try:
                album = [
                    a for a in photos.get_albums() if a.title == 'Thread'
                ][0]
            except IndexError:
                album = photos.create_album('Thread')
            # Add the file as an asset to the library:
            # asset = photos.create_image_asset(theImage)
            # Add the asset to the album:
            theImage = all_assets[len(all_assets) - 1]
            album.add_assets([theImage])

        #compass State: Letters (NWSE) or degrees
        elif x < 325 and x > 275 and y < 100 and y > 50:
            self.compassStat = not (self.compassStat)

        elif self.measuringOn == False and self.checkedOnce == 0:
            #sound.play_effect('arcade:Laser_2')
            self.measuringOn = True
            self.background_color = 'white'
            self.checkedOnce += 1

        elif self.measuringOn == True and self.checkedOnce == 1 and len(
                self.locations) < 4:
            #sound.play_effect('arcade:Laser_1')
            self.needMore = True

        elif self.measuringOn == True and self.checkedOnce == 1 and len(
                self.locations) > 3:
            #sound.play_effect('arcade:Laser_1')
            self.needMore = False
            self.measuringOn = False
            self.background_color = 'white'
            self.checkedOnce += 1

        elif self.measuringOn == False and self.checkedOnce == 3:
            #sound.play_effect('arcade:Laser_1')
            self.background_color = 'white'
            self.checkedOnce += 1
Example #30
0
import clipboard
import Image
import console
import photos

console.clear()

console.alert("Take first image", "", "Ok")
img1 = photos.capture_image()

console.alert("Take second image", "", "Ok")
img2 = photos.capture_image()

console.show_activity()

w1, h1 = img1.size
w2, h2 = img2.size

# Set the width and height of each image
img1_w = img1.size[0]
img1_h = img1.size[1]
img2_w = img2.size[0]
img2_h = img1.size[1]


def image_merge(img):
    if (img1_w * 1.0) / img1_h > 1:
        print 'Landscape screenshot...'
        #(2048, 1536)
        #Landscape screenshot
        background = Image.new('RGB', ((img1_w + 20), ((img1_h * 2) + 30)),
Example #31
0
 def take_photo_action(self, sender):
     image = photos.capture_image()
     def a():
        photos.save_image(image)
        self.close()
     ui.delay(a,.5)
Example #32
0
def take_photo(sender):
    img = photos.capture_image()
Example #33
0
# coding: utf-8

# http://mygeekdaddy.net/2016/01/12/capture-and-merge-photos-with-pythonista/

# Prompts user to take 2 pictures and merges the two images together    
import clipboard
import Image
import console
import photos

console.clear()

console.alert("Take first image", "", "Ok")
img1=photos.capture_image()

console.alert("Take second image", "", "Ok")
img2=photos.capture_image()

console.show_activity()

w1,h1 = img1.size
w2,h2 = img2.size

# Set the width and height of each image
img1_w = img1.size[0]
img1_h = img1.size[1]
img2_w = img2.size[0]
img2_h = img1.size[1]

def image_merge(img):
    if (img1_w*1.0)/img1_h > 1:
Example #34
0
import photos
import qrcode
"""Create a QR code from an imgae"""

img = photos.capture_image()

if img:
    qr = qrcode.make(img)
    qr.show()
Example #35
0
 def run(self):
     self.status = 'complete'
     #console.alert(title='Known Issue',message='Take Photo sometimes freezes the ui and pythonista needs to be killed.',button1='Ok',hide_cancel_button=True)
     time.sleep(.5)
     return ElementValue(type=self.get_output_type(),
                         value=photos.capture_image())