• b0hr

    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 read more
  • b0hr

    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 read more

Internal error.

Oops! Looks like something went wrong!