omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular
    1. Home
    2. b0hr

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    • Profile
    • Following 0
    • Followers 0
    • Topics 2
    • Posts 2
    • Best 0
    • Controversial 0
    • Groups 0

    b0hr

    @b0hr

    0
    Reputation
    699
    Profile views
    2
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    b0hr Unfollow Follow

    Latest posts made by b0hr

    • Pip install functionality

      Installing pure Python packages

      Hi guys,

      I'm building my Zettelkasten system on my iPad (I'll keep you posted on my progress, building some stuff you'll probably also like) and I stumbled upon the problem of not being able to install additional Python packages.

      I'm came up with this script - click here to install - that mimics the behaviour of pip install. It grabs the sdist or source distribution from pypi.org and installs the package in the /site-packages directory.

      One more thing - Some packages are not python 2.7 supported anymore, but older versions of the package are! I've added a dict in the beginning of my script where you can define the package name and the latest version which is python 2.7 compatible. Please feel free to add some contributions to this dict so this dictionary can be extended.

      Source code - See github: https://github.com/rebot/Editorial

      Please feel free to add your ideas or make some contributions on Github.

      B0Hr

      posted in Editorial
      b0hr
      b0hr
    • Capturing still images within my scene

      Hi,

      I'm trying to make a small application which allows me to capture an image, process the image through the Microsoft Azure vision API and then give back the recognized text.

      I'm struggeling to make my LiveCameraView to take a picture and save it.

      My references:
      AVFoundationPG - Media Capture
      AVCapturePhotoOutput
      Original code

      from objc_util import *
      import console
      import ui
      
      class LiveCameraView(ui.View):
         def __init__(self,device=0, *args, **kwargs):
            
            self.background_color = 'white'
            ui.View.__init__(self,*args,**kwargs)
            
            # Define a session, used to serve as a placeholder for the input and output + definition of quality
            self._session=ObjCClass('AVCaptureSession').alloc().init()
            
            # Set the quality of the capture
            self._session.setSessionPreset_('AVCaptureSessionPresetMedium');
            
            # Select an input device
            inputDevices=ObjCClass('AVCaptureDevice').devices()
            self._inputDevice=inputDevices[device]
            
            #self._inputDevice.unlockForConfiguration()
            #self._inputDevice.setFocusMode_(ns('AVCaptureFocusModeContinuousAutoFocus'))
            
            # Enable autofocus
            if self._inputDevice.isFocusModeSupported_(2):
            	if self._inputDevice.lockForConfiguration_(None):
            		self._inputDevice.focusMode = 2
            		self._inputDevice.unlockForConfiguration()
            
            # Add the device to your session 
            deviceInput=ObjCClass('AVCaptureDeviceInput').deviceInputWithDevice_error_(self._inputDevice, None);
            
            # Configure device output
            
            deviceOutput = ObjCClass('AVCapturePhotoOutput').alloc().init()
            
            photoSettings = ObjCClass('AVCapturePhotoSettings')
            
            # FROM HERE ON, I'M LOST
      
            deviceConnection = ObjCClass('AVCaptureConnection')
            
            if self._session.canAddInput_(deviceInput):
               self._session.addInput_(deviceInput)
            
            if self._session.canAddOutput_(deviceOutput):
            	self._session.addOutput_(deviceOutput)
            self._previewLayer=ObjCClass('AVCaptureVideoPreviewLayer').alloc().initWithSession_(self._session)
            self._previewLayer.setVideoGravity_( 
               'AVLayerVideoGravityResizeAspectFill')
            rootLayer=ObjCInstance(self).layer()
            rootLayer.setMasksToBounds_(True)
            self._previewLayer.setFrame_(
               CGRect(CGPoint(-70, 0), CGSize(self.height,100)))
            rootLayer.insertSublayer_atIndex_(self._previewLayer,0)
            self._session.startRunning()
            b = ui.Button(title = 'Scan code')
            b.action = self.snap
            b.center = (self.width * 0.5, self.height * 0.5)
            b.flex = 'LRTB'
            self.add_subview(b)
            
         def snap(self, sender):
            console.alert('snap','snap')
            
         def will_close(self):
            self._session.stopRunning()
         def layout(self):
            if not self._session.isRunning():
               self._session.startRunning()
      
      rootview=LiveCameraView(frame=(0,0,200,500))
      rootview.present('popover')
      

      Can someone help me to capture the image and process it so I'm be able to send it using requests?

      Thank you in advance,

      Kind regards,

      Gilles

      posted in Pythonista
      b0hr
      b0hr