• sodoku

    Because it has way to much errors with out from the last thread where I got the last Code that can take pictures of text and numbers either from your library or a disposable picture with the camera but I get way to much errors

    posted in Pythonista read more
  • sodoku

    So I just updated to iOS 15.3 and it said it can download core mls for machine learning modules and on their web site they got something called mnist and I need it to take a picture of my sudoku puzzle and input them into my app I’m gonna go check out the old thread on the forum but if anyone of you can build it and compose it faster I just need it to print it properly in the console like a 9 by 9 and I can adapt it to my sudoku app

    posted in Pythonista read more
  • sodoku

    Is it possible to make speech to text with pythonista to print to the console,

    Or also displaying it as a textsprite thingy

    posted in Pythonista read more
  • sodoku

    Cool awesome Thanks this worked I did not know you could use for twice in one line of code

    a=[‘Haloween’, ‘Boom’, ‘hi’, ‘Howl’, ‘if’, ‘ghosts’]
    B=[s[i:i+2] for s in a for i in range(0, len(s), 2)]
    Print(B)
    

    posted in Pythonista read more
  • sodoku

    I have a question about a list of strings

    Say I got a list like

    a=[‘Haloween’, ‘Boom’, ‘hi’, ‘Howl’, ‘if’, ‘ghosts’]
    

    How do you split or slice the strings to make a list like

    a=[‘Ha’, ‘lo’, ‘we’, ‘en’, ‘Bo’, ‘om’, ‘hi’, ‘Ho’, ‘wl’, ‘if’, ‘gh’, ‘os’, ‘ts’]
    

    Is this possible to do?

    posted in Pythonista read more
  • sodoku

    Question 1
    Are you able to pip install opencv cv2 with stash?

    Question 2
    Are you able to install tessaract and pytessaract with stash?

    Question 3
    Does pythonista 3 come with Core ML already or does it need to be installed?

    posted in Pythonista read more
  • sodoku

    I have a quick question in regards to the original ocr post how do I print the text as one single csv list, I tried but I have been getting a list of lists instead of one single list

    This is a snippet of the code example I think needs to be altered

      success = handler.performRequests_error_([req], None)
        if success:
            for result in req.results():
                print(result.text())
        else:
            print('Problem recognizing anything')
    

    posted in Pythonista read more
  • sodoku

    ive seen the apple documentation coding on Vision Framework I just dont know how to convert it to python

    Question 1
    What about the setting the minimum text height how do you translate either of these codes to python????
    @property(readwrite, nonatomic, assign) float minimumTextHeight; written in objective-c
    var minimumTextHeight: Float { get set } written in Swift

    Question 2
    I was also interested in learning how to recognize the individual boxes from a sudoku puzzle to extract the numbers is there a way to do that possibly with
    VNRecognizedTextObservation A request that detects and recognizes regions of text in an image.
    or possibly with the bounding box technique show in the video https://developer.apple.com/videos/play/wwdc2019/234 , also can you put multiple bounding boxes to recognize text from a sudoku card

    this is Mikeals code i am trying to insert the code into but dont know how to convert the code shown in the apple documentation into python

    language_preference = ['fi','en','se']
    
    import photos, ui, dialogs
    import io
    from objc_util import *
    
    load_framework('Vision')
    VNRecognizeTextRequest = ObjCClass('VNRecognizeTextRequest')
    VNImageRequestHandler = ObjCClass('VNImageRequestHandler')
    
    def pil2ui(pil_image):
        buffer = io.BytesIO()
        pil_image.save(buffer, format='PNG')
        return ui.Image.from_data(buffer.getvalue())
    
    selection = dialogs.alert('Get pic', button1='Camera', button2='Photos')
    
    ui_image = None
    
    if selection == 1:
        pil_image = photos.capture_image()
        if pil_image is not None:
            ui_image = pil2ui(pil_image)
    elif selection == 2:
        ui_image = photos.pick_asset().get_ui_image()
    
    if ui_image is not None:
        print('Recognizing...\n')
    
        req = VNRecognizeTextRequest.alloc().init().autorelease()
        req.recognitionLevel=1
        req.setRecognitionLanguages_(language_preference)
        handler = VNImageRequestHandler.alloc().initWithData_options_(ui_image.to_png(), None).autorelease()
    
        success = handler.performRequests_error_([req], None)
        if success:
            for result in req.results():
                print(result.text())
        else:
            print('Problem recognizing anything')
    

    posted in Pythonista read more
  • sodoku

    I have a few questions about the very first text recognition code posted on this one

    the example video I am referring to is https://developer.apple.com/videos/play/wwdc2019/234

    1 how do you change the recognition level from fast to accurate
    example code from apple website I am not sure if its written in swift or objective c but it is like this :

    myTextRegcognitionRequest.recognitionLevel = VNRequestTextRecognitionLevel.accurate
    

    and another example of this shown in the apple video for setting the recognition level

     request.recognitionLevel = .fast 
    

    question 2
    to ensure that numbers don't get mistaken as letters
    without the language corrector active to avoid mistaking the number 5 for an S or I as 1
    example of this from the video is

    extension Character {
           
         func GetSimilarCharacterIfNotIn(allowedChars: String -> Character {
                let  conversionTable = [
                          's':'5',
                          'S':'5',
                          'i':'1',
                          'I':'1', ] 
    

    question 3
    if you know how to set up the special words detector thingy feature mentioned in the video

    posted in Pythonista read more
  • sodoku

    I need help adapting this script for inputting the numbers from a picture of sudoku and insert the starting numbers into a console script, it does not work good for recognizing ones and sevens???

    Example of sudoku solver

    In my version I want to make the board is all zeros and when you take a picture it will add the numbers than solve, this combines the two programs (sudoku solver) & (ocr text recognition)

    board=[
       [5,8,4,1,0,0,0,0,0],
       [0,0,6,8,0,0,5,1,0],
       [0,0,0,0,5,4,7,0,6],
       [0,5,3,0,1,0,0,6,7],
       [0,0,0,0,2,0,0,0,0],
       [4,6,0,0,9,0,8,3,0],
       [7,0,8,5,4,0,0,0,0],
       [0,2,9,0,0,3,4,0,0],
       [0,0,0,0,0,1,3,7,9]
       ]
    
    
    
    def solve(bo):
    
       find = find_empty(bo)
       if not find:
           return True
       else:
           row,col = find
    
       for i in range(1,10):
           if valid(bo,i,(row,col)):
               bo[row][col] = i
    
               if solve(bo):
                   return True
    
               bo[row][col] = 0
    
       return False
    
    
    
    def valid(bo,num,pos):
       #check row
       for i in range(len(bo[0])):
           if bo[pos[0]][i] == num and pos[1] != i:
               return False
       #check column
       for i in range(len(bo[0])):
           if bo[i][pos[1]] == num and pos[0] != i:
               return False
       #check quadrant
       box_x = pos[1] // 3
       box_y = pos[0] // 3
    
       for i in range(box_y * 3, box_y * 3 + 3):
           for j in range(box_x * 3, box_x * 3 + 3):
               if bo[i][j] == num and (i,j) != pos:
                   return False
    
       return True
    
    
    
    def print_board(bo):
       for i in range(len(bo)):
           if i % 3 == 0 and i != 0:
               print('------+-------+------')
    
           for j in range(len(bo[0])):
               if j % 3 == 0 and j != 0:
                   print('|',end=' ')
               if j == 8:
                   print(bo[i][j])
               else:
                   print(str(bo[i][j])+ ' ', end='')
    
    def find_empty(bo):
       for i in range(len(bo)):
           for j in range(len(bo[0])):
               if bo[i][j] == 0:
                   return (i,j) # row, col
       return None
    
    
    
    print_board(board)
    solve(board)
    print('=====================')
    print_board(board)
    
    language_preference = ['fi','en','se']
    
    import photos, ui, dialogs
    import io
    from objc_util import *
    
    load_framework('Vision')
    VNRecognizeTextRequest = ObjCClass('VNRecognizeTextRequest')
    VNImageRequestHandler = ObjCClass('VNImageRequestHandler')
    
    def pil2ui(pil_image):
       buffer = io.BytesIO()
       pil_image.save(buffer, format='PNG')
       return ui.Image.from_data(buffer.getvalue())
    
    selection = dialogs.alert('Get pic', button1='Camera', button2='Photos')
    
    ui_image = None
    
    if selection == 1:
       pil_image = photos.capture_image()
       if pil_image is not None:
           ui_image = pil2ui(pil_image)
    elif selection == 2:
       ui_image = photos.pick_asset().get_ui_image()
    
    if ui_image is not None:
       print('Recognizing...\n')
    
       req = VNRecognizeTextRequest.alloc().init().autorelease()
       req.setRecognitionLanguages_(language_preference)
       handler = VNImageRequestHandler.alloc().initWithData_options_(ui_image.to_png(), None).autorelease()
    
       success = handler.performRequests_error_([req], None)
       if success:
           for result in req.results():
               print(result.text())
       else:
           print('Problem recognizing anything') ```

    posted in Pythonista read more
  • sodoku

    I will test it for sudoku in the console, well I will try to convert it to use in console for the sudoku solver if need help I’ll post a message

    posted in Pythonista read more
  • sodoku

    So there are a few edits in this thread I don’t know how to piece together to have the best edited version of this???

    posted in Pythonista read more
  • sodoku

    Also what’s the updated code posted by Mikael on GitHub used for is it same as this one posted here or not because it’s so much longer and bigger then this code posted on the forum, is it a better version then this one on the forum

    posted in Pythonista read more
  • sodoku

    So good news I got an iPhone 11 and I’m testing this on it, for sudoku, do the pictures taken save anywhere when used, just curious if I have to delete them because after I use it the pictures don’t show up in my pictures app

    posted in Pythonista read more
  • sodoku

    The thing is i understand the problem I’m encountering, and the main objective and goal I want to achieve, I just have no clue how to code the solution or if it’s even possible to code a solution, at this level of of coding it’s to easy to make a mistake and not code the proper order of operations

    I just know how to ask the smarter people the question, is it possible to fix this problem

    posted in Pythonista read more
  • sodoku

    The only work around I can think of is limiting only page 1 to have the add emoji input, and undo, and redo while removing those three actions from page 2 to kinda make it idiot/fool proof so the functions undo and redo doesn’t glitch, and users won’t get confused and ruin the order of operations
    So basically add emoji, undo and redo would only be available on page 1 and then page 2 would just be a viewable screen to observe then you would have to go back to page 1 to add, undo or redo

    Except that would kinda hinder the game play by adding to much unnecessary steps to manually back track, and it would ruin the experience and point of being an app that saves time

    I hope this could be fixed that would make this app seem more professional

    posted in Pythonista read more
  • sodoku

    I don’t know if my next question I got for you can be solved, okay so I have added @cvp’s code to mine and it works perfectly, except for the undo and redo functions have now become a little glitchy (not working perfectly), I was wondering if it’s possible to fix this or not??

    posted in Pythonista read more
  • sodoku

    Did @ccc add a suggestion to improve the coding that @cvp suggested just asking because I know how to add @cvp’s idea to my module I just don’t know where to add the code suggested by @ccc to my module

    posted in Pythonista read more
  • sodoku

    I think that solves my question thank you @cvp that will be the finishing touch to my first prototype app I’m developing I just need to buy a iPhone so I can add text recognition to my sudoku app

    posted in Pythonista read more
  • sodoku

    I don’t understand your question I just wanted to add the emoji behind the label node text by typing the label node text into the text field
    It works as is but I need to tap page1 then tap the pawz menu type the label node text to add the emojis then I have to tap main to go back to the first scene and then tap page2 then tap pawz then type the label node text again in order to get both pages (scenes a and b) to display the emojis
    I just would like to only have to tap pawz once and type the label node text once so the emojis get added to both pages (scene a and b)

    posted in Pythonista read more
Internal error.

Oops! Looks like something went wrong!