How to use _screenToWindow method in fMBT

Best Python code snippet using fMBT_python

eyenfinger.py

Source:eyenfinger.py Github

copy

Full Screen

...1381 draw_commands = ["-stroke", "red", "-fill", "blue", "-draw", "fill-opacity 0.2 circle %s,%s %s,%s" % (1382 x, y, x + 20, y)]1383 draw_commands += ["-stroke", "none", "-fill", "red", "-draw", "point %s,%s" % (x, y)]1384 _runDrawCmd(inputfilename, draw_commands, outputfilename)1385def _screenToWindow(x,y):1386 """1387 Converts from absolute coordinats to window coordinates1388 """1389 offsetX = _g_windowOffsets[_g_lastWindow][0]1390 offsetY = _g_windowOffsets[_g_lastWindow][1]1391 return (x-offsetX, y-offsetY)1392def _windowToScreen(x,y):1393 """1394 Converts from window coordinates to screen coordinates1395 """1396 offsetX = _g_windowOffsets[_g_lastWindow][0]1397 offsetY = _g_windowOffsets[_g_lastWindow][1]1398 return (x+offsetX, y+offsetY)1399def drawLines(inputfilename, outputfilename, orig_coordinates, final_coordinates):1400 """1401 coordinates contains the coordinates connected by lines1402 """1403 if inputfilename == None:1404 return1405 # The command which will be run1406 draw_commands = []1407 for pos in xrange(len(final_coordinates)-1):1408 # Get the pair coordinates1409 (x, y) = (final_coordinates[pos][0], final_coordinates[pos][1])1410 (nextX, nextY) = (final_coordinates[pos+1][0], final_coordinates[pos+1][1])1411 # Convert to window coordinates1412 (drawX, drawY) = _screenToWindow(x,y)1413 (drawnextX, drawnextY) = _screenToWindow(nextX, nextY)1414 # Draw a pair of circles. User-given points are blue1415 if (x, y) in orig_coordinates:1416 draw_commands += ["-fill", "blue", "-stroke", "red", "-draw", "fill-opacity 0.2 circle %d, %d %d, %d" % (drawX, drawY, drawX-5, drawY-5)]1417 # Computer-generated points are white1418 else:1419 draw_commands += ["-fill", "white", "-stroke", "red", "-draw", "fill-opacity 0.2 circle %d, %d %d, %d" % (drawX, drawY, drawX-5, drawY-5)]1420 # Draw the line between the points1421 draw_commands += ["-stroke", "red", "-draw", "line %d, %d, %d, %d" % (drawX, drawY, drawnextX, drawnextY)]1422 draw_commands += ["-stroke", "black", "-draw", "line %d, %d, %d, %d" % (drawX+1, drawY+1, drawnextX+1, drawnextY+1)]1423 if len(final_coordinates) > 0:1424 lastIndex = len(final_coordinates)-11425 (finalX, finalY) = _screenToWindow(final_coordinates[lastIndex][0], final_coordinates[lastIndex][1])1426 draw_commands += ["-fill", "blue", "-stroke", "red", "-draw", "fill-opacity 0.2 circle %d, %d %d, %d" % (finalX, finalY, finalX-5, finalY-5)]1427 _runDrawCmd(inputfilename, draw_commands, outputfilename)1428def evaluatePreprocessFilter(imageFilename, ppfilter, words):1429 """1430 Visualise how given words are detected from given image file when1431 using given preprocessing filter.1432 """1433 global _g_preprocess1434 evaluatePreprocessFilter.count += 11435 preprocessed_filename = '%s-pre%s.png' % (imageFilename, evaluatePreprocessFilter.count)1436 _runcmd("convert '%s' %s '%s' && tesseract %s eyenfinger.autoconfigure hocr" %1437 (imageFilename, ppfilter, preprocessed_filename,1438 preprocessed_filename))1439 detected_words = _hocr2words(file("eyenfinger.autoconfigure.html").read())...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run fMBT automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful