Re: How Do I Get A Bug In Multiprocessing Fixed?
Also you report requires any developer to write a program from you notes to reproduce the problem. Attach a program that shows the problem would help. Better yet diagnose the problem after you reproduce it with a fix in a PR. Barry > On 18 Jun 2021, at 06:07, Alexander Neilson wrote: > > Hi Michael > > It may be helpful to populate the ticket with further details: > * actual output from when you execute the server and client (possibly with > extra verbosity enabled) > * system you are running this on (windows, macos, linux) flavour / version > details > * minor version of Python interpreter used > * whether you are using a packaged version from your os distributor or from > python.org (or even built your own) > * If you believe it's a regression the version it is working on > > Some more guidance can be found here covering some of the above > https://docs.python.org/3/bugs.html > > I am very interested to note that a report filed in February hasn't had at > least one person take a brief look at it and post a note or set a status > like "needs more info" etc. > > Also I am by no means an expert in multi processing at all as so far my > webapps work worker processes, I am wondering if the wrong approach to this > may be happening and so the client is trying to reuse the same pipe and it > may need a different tear down / process to release that and create a new > pipe / socket / underlying connection cleanly rather than the re connect in > the same object. > > For example I am running python 3.7.7 on windows: > > Manager Output: >> python manager.py > In test_method > >> python manager.py > > > Client Output: > result: ', TEST' > Kill and restart the server and press return > > Got exception , ConnectionResetError(10054, > 'An existing connection was forcibly closed by the remote host', None, > 10054, None) > Reconnecting > Got exception , ConnectionResetError(10054, > 'An existing connection was forcibly closed by the remote host', None, > 10054, None) > Reconnecting > Got exception , ConnectionResetError(10054, > 'An existing connection was forcibly closed by the remote host', None, > 10054, None) > Reconnecting > Got exception , ConnectionResetError(10054, > 'An existing connection was forcibly closed by the remote host', None, > 10054, None) > Reconnecting > Got exception , ConnectionResetError(10054, > 'An existing connection was forcibly closed by the remote host', None, > 10054, None) > Reconnecting > Got exception , ConnectionResetError(10054, > 'An existing connection was forcibly closed by the remote host', None, > 10054, None) > Reconnecting > Got exception , ConnectionResetError(10054, > 'An existing connection was forcibly closed by the remote host', None, > 10054, None) > Reconnecting > Got exception , ConnectionResetError(10054, > 'An existing connection was forcibly closed by the remote host', None, > 10054, None) > Reconnecting > Got exception , ConnectionResetError(10054, > 'An existing connection was forcibly closed by the remote host', None, > 10054, None) > Reconnecting > Got exception , ConnectionResetError(10054, > 'An existing connection was forcibly closed by the remote host', None, > 10054, None) > Reconnecting > Got exception , ConnectionResetError(10054, > 'An existing connection was forcibly closed by the remote host', None, > 10054, None) > Reconnecting > Got exception , ConnectionResetError(10054, > 'An existing connection was forcibly closed by the remote host', None, > 10054, None) > Reconnecting # At this point I terminated the manager > Got exception , > ConnectionRefusedError(10061, 'No connection could be made because the > target machine actively refused it', None, 10061, None) > Reconnecting > Traceback (most recent call last): > File > "C:\Users\Alexander\AppData\Local\Programs\Python\Python37\lib\multiprocessing\connection.py", > line 619, in SocketClient >s.connect(address) > ConnectionRefusedError: [WinError 10061] No connection could be made > because the target machine actively refused it > > During handling of the above exception, another exception occurred: > > Traceback (most recent call last): > File "client.py", line 27, in >manager.connect() > File > "C:\Users\Alexander\AppData\Local\Programs\Python\Python37\lib\multiprocessing\managers.py", > line 532, in connect >conn = Client(self._address, authkey=self._authkey) > File > "C:\Users\Alexander\AppData\Local\Programs\Python\Python37\lib\multiprocessing\connection.py", > line 492, in Client >c = SocketClient(address) > File > "C:\Users\Alexander\AppData\Local\Programs\Python\Python37\lib\multiprocessing\connection.py", > line 619, in SocketClient >s.connect(address) > KeyboardInterrupt > > > > > Regards > Alexander > > Alexander Neilson > Neilson Productions Limited > > alexan...@neilson.net.nz > 021 329 681 > 022 456 2326 > > >> On Fri, 18 Jun 2021 at 15:27, Michael Boom wrote: >> >> The below issue is pretty serious and it is preventing me from using
Re: How Do I Get A Bug In Multiprocessing Fixed?
Hi Michael It may be helpful to populate the ticket with further details: * actual output from when you execute the server and client (possibly with extra verbosity enabled) * system you are running this on (windows, macos, linux) flavour / version details * minor version of Python interpreter used * whether you are using a packaged version from your os distributor or from python.org (or even built your own) * If you believe it's a regression the version it is working on Some more guidance can be found here covering some of the above https://docs.python.org/3/bugs.html I am very interested to note that a report filed in February hasn't had at least one person take a brief look at it and post a note or set a status like "needs more info" etc. Also I am by no means an expert in multi processing at all as so far my webapps work worker processes, I am wondering if the wrong approach to this may be happening and so the client is trying to reuse the same pipe and it may need a different tear down / process to release that and create a new pipe / socket / underlying connection cleanly rather than the re connect in the same object. For example I am running python 3.7.7 on windows: Manager Output: >python manager.py In test_method >python manager.py Client Output: result: ', TEST' Kill and restart the server and press return Got exception , ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None) Reconnecting Got exception , ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None) Reconnecting Got exception , ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None) Reconnecting Got exception , ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None) Reconnecting Got exception , ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None) Reconnecting Got exception , ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None) Reconnecting Got exception , ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None) Reconnecting Got exception , ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None) Reconnecting Got exception , ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None) Reconnecting Got exception , ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None) Reconnecting Got exception , ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None) Reconnecting Got exception , ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None) Reconnecting # At this point I terminated the manager Got exception , ConnectionRefusedError(10061, 'No connection could be made because the target machine actively refused it', None, 10061, None) Reconnecting Traceback (most recent call last): File "C:\Users\Alexander\AppData\Local\Programs\Python\Python37\lib\multiprocessing\connection.py", line 619, in SocketClient s.connect(address) ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it During handling of the above exception, another exception occurred: Traceback (most recent call last): File "client.py", line 27, in manager.connect() File "C:\Users\Alexander\AppData\Local\Programs\Python\Python37\lib\multiprocessing\managers.py", line 532, in connect conn = Client(self._address, authkey=self._authkey) File "C:\Users\Alexander\AppData\Local\Programs\Python\Python37\lib\multiprocessing\connection.py", line 492, in Client c = SocketClient(address) File "C:\Users\Alexander\AppData\Local\Programs\Python\Python37\lib\multiprocessing\connection.py", line 619, in SocketClient s.connect(address) KeyboardInterrupt Regards Alexander Alexander Neilson Neilson Productions Limited alexan...@neilson.net.nz 021 329 681 022 456 2326 On Fri, 18 Jun 2021 at 15:27, Michael Boom wrote: > The below issue is pretty serious and it is preventing me from using a > system I wrote on a larger scale. How do I get this bug fixed? Thanks. > https://bugs.python.org/issue43329 > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list
How Do I Get A Bug In Multiprocessing Fixed?
The below issue is pretty serious and it is preventing me from using a system I wrote on a larger scale. How do I get this bug fixed? Thanks. https://bugs.python.org/issue43329 -- https://mail.python.org/mailman/listinfo/python-list
[RELEASE] Python 3.10.0b3 is available
Summer is almost here (at least in half of the planet) and Python 3.10 is finishing baking in the oven. For those of you that want to taste it before is finally ready (and if you are a library developer, you certainly do!) you can have the second-to-last beta now, but be careful as is still very hot ;) https://www.python.org/downloads/release/python-3100b3/ #This is a beta preview of Python 3.10 Python 3.10 is still in development. 3.10.0b3 is the third of four planned beta release previews. Beta release previews are intended to give the wider community the opportunity to test new features and bug fixes and to prepare their projects to support the new feature release. We strongly encourage maintainers of third-party Python projects to test with 3.10 during the beta phase and report issues found to the Python bug tracker as soon as possible. While the release is planned to be feature complete entering the beta phase, it is possible that features may be modified or, in rare cases, deleted up until the start of the release candidate phase (Monday, 2021-08-02). Our goal is to have no ABI changes after beta 4 and as few code changes as possible after 3.10.0rc1, the first release candidate. To achieve that, it will be extremely important to get as much exposure for 3.10 as possible during the beta phase. Please keep in mind that this is a preview release and its use is not recommended for production environments. The next pre-release of Python 3.10 will be 3.10.0b4, currently scheduled for Saturday, 2021-07-10. #And now for something completely different There are no green stars. Why? In general, objects don’t emit a single wavelength of light when they shine. Instead, they emit photons in a range of wavelengths. If you were to use some sort of detector that is sensitive to the wavelengths of light emitted by an object, and then plotted the number of them versus wavelength, you get a lopsided plot called a blackbody curve. For an object as hot as the Sun, that curve peaks at blue-green, so it emits most of its photons there. But it still emits some that are bluer, and some that are redder. When we look at the Sun, we see all these colors blended together. Our eyes mix them up to produce one color: white. A warmer star will put out more blue, and a cooler one redder, but no matter what, our eyes just won’t see that as green. Due to how we perceive color, the only way to see a star as being green is for it to be only emitting green light. But as starts always emit radiation following the blackbody curve, that’s pretty much impossible. # We hope you enjoy those new releases! Thanks to all of the many volunteers who help make Python Development and these releases possible! Please consider supporting our efforts by volunteering yourself or through organization contributions to the Python Software Foundation. Regards from very cloudy London, Your friendly release team, Pablo Galindo @pablogsal Ned Deily @nad Steve Dower @steve.dower -- https://mail.python.org/mailman/listinfo/python-list
Re: module include path - /usr/local/lib/python3 vs /usr/local/lib/python3.9
On 6/17/21 1:53 AM, Joachim Wuttke wrote: How to write a platform-independent CMake install command to install a Swig-generated Python module? The following brings us very close to a solution: ``` execute_process( COMMAND "${Python3_EXECUTABLE}" -c "from distutils import sysconfig as sc; print(sc.get_python_lib(prefix='', plat_specific=True))" OUTPUT_VARIABLE PYTHON_SITE OUTPUT_STRIP_TRAILING_WHITESPACE) message(STATUS "Python module libcerf will be installed to ${PYTHON_SITE}") install(FILES ${CMAKE_CURRENT_BINARY_DIR}/.py DESTINATION ${PYTHON_SITE}) ``` So far, we only tested under Debain, where the problem arises: - distutils.sysconfig.get_python_lib(...) returns lib/python3/dist-packages - CMake provides CMAKE_INSTALL_PREFIX=/usr/local/ - So installation goes to /usr/local/lib/python3/dist-packages - sys.path, however, does not contain /usr/local/lib/python3/dist-packages. sys.path contains /usr/local/lib/python3.9/dist-packages, and also /usr/lib/python3/dist-packages, so this is slightly incoherent. Anyway, we won't want to change sys.path. So we need to change the above CMake/Python code to return a local installation directory that is part of sys.path. Thanks for any hints - Joachim dist-packages is Debian-family-specific anyway, other Linux distros don't use it - and some have some interesting conventions - if you're using Swig to build a binary extension module, it needs to go in a lib-dynload directory on Fedora. You should look at the Python sysconfig module in preference to using the one from distutils. You probably need to say more about what the target is - are you attempting to install as part of the process building a distro package, or are you expecting to install directly? -- https://mail.python.org/mailman/listinfo/python-list
EuroPython 2021: Schedule published
After two weeks of hard work by our program workgroup, we are very excited to announce the EuroPython 2021 schedule: * EuroPython 2021 Schedule * https://ep2021.europython.eu/schedule/ Seven full days of Python - EuroPython 2021 will be held online in the week of July 26: - Two workshop/training days (Monday, Tuesday): training sessions and workshops - Three conference days (Wednesday, Thursday, Friday): keynotes, talks, lightning talks, poster session - Two sprint days (Saturday, Sunday): code sprints / hackathons Lots of engaging content waiting for you The conference will be packed with interesting Python content, provided in many different formats and presented by our fantastic team of volunteers, speakers and sponsors: - 6 exciting keynotes, - 97 talks, - 18 training sessions, - 3 fun lightning talk blocks, - overall, more than 130 sessions in total, - presented by more than 130 speakers from around the world, - 4 all-day conference tracks, - with a whole track dedicated to data science topics, - a poster track, - interactive sessions, - a virtual social event, - an after party, - and lots of socializing on our conference platform. https://ep2021.europython.eu/events/sessions/ https://ep2021.europython.eu/events/speakers/ We would like to thank all speakers and sponsors who submitted session proposals to the conference. Never miss a talk - All talks will be made available to the attendees via streaming to our Matrix based conference platform, with easy switching between tracks and chat. We’ll also make the streams available with rewind functionality and give you access to the streams after the conference. Conference Tickets -- Conference tickets are available on our registration page. We have several ticket types available to make the conference affordable for everyone and we're also offering financial aid to increase our reach even more. https://ep2021.europython.eu/registration/buy-tickets/ https://ep2021.europython.eu/registration/financial-aid/ EuroPython is your conference - EuroPython has always been a completely volunteer based effort. The organizers work hundreds of hours to make the event happen and will try very hard to create an inspiring and exciting event. However, we can only provide the setting. You, as our attendees, are the ones who fill it with life and creativity. We are very much looking forward to having you at the conference ! Help spread the word Please help us spread this message by sharing it on your social networks as widely as possible. Thank you ! Link to the blog post: https://blog.europython.eu/europython-2021-schedule-published/ Tweet: https://twitter.com/europython/status/1405538503048327169 Enjoy, -- EuroPython 2021 Team https://ep2021.europython.eu/ https://www.europython-society.org/ -- https://mail.python.org/mailman/listinfo/python-list
Re: tkinter: tksheet
On Thu, 17 Jun 2021, Dennis Lee Bieber wrote: FreePascal/Lazarus is supposed to be similar to Delphi, and does have Linux installs -- but I don't know what it provides for database linkages. I do have it installed on my Windows box (the Linux install is HUGE; takes up over 1/4 of the space on BeagleBone Black so I didn't install it there). Dennis, In the 1980s I looked closely at Pascal. More recently I did so again because the local linux/UNIX group had a presentation on its use. Decided another language was not for me. Thanks, Rich -- https://mail.python.org/mailman/listinfo/python-list
Re: tkinter: tksheet
On Thu, 17 Jun 2021, Alan Gauld via Python-list wrote: Sounds like a job for a database view. Can you modify the database schema? Could you create a view - even a temporary one just while your app is running? Alan, Yes, created views work well with postgres. Building one for complex, multitable queries is always a good idea. Thanks, Rich -- https://mail.python.org/mailman/listinfo/python-list
Re: tkinter: tksheet
On Thu, 17 Jun 2021, Dennis Lee Bieber wrote: My naive idea is to use two queries, one selects * from the company table ordered by nunber, the other by name. The UI offers two radiobuttons when viewing the results, one for each sort column. Presuming all the data fits in memory, it may be faster to just define the key structure for Python's internal sort() function than to go back out to the database server, wait for it to gather the desired fields and sort them, then transfer all the data back to your script. Dennis, That's a possibility. Thanks, Rich -- https://mail.python.org/mailman/listinfo/python-list
module include path - /usr/local/lib/python3 vs /usr/local/lib/python3.9
How to write a platform-independent CMake install command to install a Swig-generated Python module? The following brings us very close to a solution: ``` execute_process( COMMAND "${Python3_EXECUTABLE}" -c "from distutils import sysconfig as sc; print(sc.get_python_lib(prefix='', plat_specific=True))" OUTPUT_VARIABLE PYTHON_SITE OUTPUT_STRIP_TRAILING_WHITESPACE) message(STATUS "Python module libcerf will be installed to ${PYTHON_SITE}") install(FILES ${CMAKE_CURRENT_BINARY_DIR}/.py DESTINATION ${PYTHON_SITE}) ``` So far, we only tested under Debain, where the problem arises: - distutils.sysconfig.get_python_lib(...) returns lib/python3/dist-packages - CMake provides CMAKE_INSTALL_PREFIX=/usr/local/ - So installation goes to /usr/local/lib/python3/dist-packages - sys.path, however, does not contain /usr/local/lib/python3/dist-packages. sys.path contains /usr/local/lib/python3.9/dist-packages, and also /usr/lib/python3/dist-packages, so this is slightly incoherent. Anyway, we won't want to change sys.path. So we need to change the above CMake/Python code to return a local installation directory that is part of sys.path. Thanks for any hints - Joachim -- https://mail.python.org/mailman/listinfo/python-list
Re: How to check if an image contains an element I am searchig for
On Thursday, 17 June 2021 at 09:59:49 UTC+2, Arak Rachael wrote: > On Thursday, 17 June 2021 at 08:52:55 UTC+2, Peter J. Holzer wrote: > > On 2021-06-16 15:51:49 -0700, Arak Rachael wrote: > > > On Wednesday, 16 June 2021 at 23:44:02 UTC+2, Chris Angelico wrote: > > > > On Thu, Jun 17, 2021 at 7:35 AM Dan Stromberg > > > > wrote: > > > > > > > > > > On Wed, Jun 16, 2021 at 2:04 PM Barry wrote: > > > > > > > > > > > >>> On Thu, Jun 17, 2021 at 6:06 AM Arak Rachael > > > > > > >>> > > > > > > wrote: > > > > > > >>> I have an image from google maps to say and I need to check if > > > > > > >>> it has > > > > > > road markings, in order to do that, I believe I need to change the > > > > > > effects > > > > > > on the image so the markings and road can be white or something and > > > > > > the > > > > > > things I don't need like cars, trees and so on to be black. > > [...] > > > I understand your concerns. Actually I am doing image processing of > > > satellite pictures for smart cars. > > Using satellite images probably makes that a lot easier (yes, you wrote > > "Google maps", but for some reason I thought of Google Street View). At > > least you have a consistent angle (almost from straight above) and know > > the scale (given the zoom factor and the latitude). > > > > hp > > > > -- > > _ | Peter J. Holzer | Story must make more sense than reality. > > |_|_) | | > > | | | h...@hjp.at | -- Charles Stross, "Creative writing > > __/ | http://www.hjp.at/ | challenge!" > I made the crop code, before I posted the question, I just need the > identification part: > [code] > # Library includes > import os > import cv2 # image and other special formats processing library > # for computer vision > import numpy as np > from numpy import asarray > import PIL > from PIL import Image > > # Global variables > # Recommended: move to a separate file > > # Recommended approach instead of using the "target" > # name directly > source_directory = "test" # Do not put a slash at the beginning > output_directory = "test2" # Do not put a slash at the beginning > > # Function definitions > def image_contains_required_elements(image): # Description: > # The function will check if the cropped image contains the > # required elements of the road(markings, road and others) > > # Local variables and initialization > raise Exception("Not implemented yet") > > > > def split_image(path, dstpath): # Description: > # Convert the generated frames(images) from > # extract_video(video_path, target_dir_path) to grayscale > # and reduce their size to half > > # Local variables and initialization > # Requires the libraries: > # import cv2 > # import os > # import pytest > # import numpy as np > > # Processing > # Reading an image in default mode > #path = r'/home/yordan/devel/python.assignments/topgis-viz.2/data' # Source > Folder > #dstpath = > r'/home/yordan/devel/python.assignments/topgis-viz.2/output_directory' # > Destination Folder > > #path = source_directory # source_directory containing the images before the > processing > #dstpath = output_directory # output_directory containing the images after > the processing > """ > # Test if target_directory exists > try: # Try > makedirs(dstpath) # to create target_directory > except: # if there is an error > print("Directory already exist, images will be written in same folder") # > print the error message > """ > files = os.listdir(path) # Read the files from source_directory and record > them in a list > > for image in files: # For index in list > img = cv2.imread(os.path.join(path, image)) # Read the image from path + > image name as an array into img > > # Split image into b, g ,r function > gray = img > #b, g, r = cv2.split(gray) # Split the image into BGR channels > #print(b, g, r) # print the b, g, r channels(codes) > crop_img = gray[100:100 + 100, 100:100 + 100] # Crop the image with numpy, x > and y are flipped, > # example crop_img = img[margin:-margin, margin:-margin] > if image_contains_required_elements(crop_img) == True: > cv2.imwrite(os.path.join(dstpath, image), crop_img) # Write the image > crop_img to a file with name > # target_directory + image name > > # Displaying the image > #cv2.imshow("Test", crop_img) # Show the image > > > split_image(source_directory, output_directory) > [code] Thanks for the help guys, I did it with OpenCV and Numpy, here is the code, but please download it, because its in my dropbox unsorted folder and I might delete it in time: https://www.dropbox.com/s/cr46m538to0j9ja/file_split.py?dl=0 here is a video processing file for who ever needs it: https://www.dropbox.com/s/39lrxkrfxuws1yd/videotest.py?dl=0 -- https://mail.python.org/mailman/listinfo/python-list
Re: tkinter: tksheet
On 17/06/2021 00:15, Rich Shepard wrote: > When I view my contacts table it needs to includes attributes from the > company, people, and contacts tables so I can view all prior contacts with > that person. Sounds like a job for a database view. Can you modify the database schema? Could you create a view - even a temporary one just while your app is running? Alternatively, and I've done this trick myself, create an in-memory SqlLite database with a table that holds all the columns you want then fetch the data from the master and manipulate/view it from Sqlite - this makes sorting by different columns fast and simple. The downside is you have to refresh it periodically or you will miss all changes in the master. > Many years ago I used wxPython. For several reasons I decided to learn and > use tkinter from now one. One reason is that the application for my clients > will run mostly on windows hosts and I want to limit the software they need > to install and maintain in order to run it. Sure, that's the main reason I use tkinter too. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos -- https://mail.python.org/mailman/listinfo/python-list
Re: How to check if an image contains an element I am searchig for
On Thursday, 17 June 2021 at 08:52:55 UTC+2, Peter J. Holzer wrote: > On 2021-06-16 15:51:49 -0700, Arak Rachael wrote: > > On Wednesday, 16 June 2021 at 23:44:02 UTC+2, Chris Angelico wrote: > > > On Thu, Jun 17, 2021 at 7:35 AM Dan Stromberg wrote: > > > > > > > > On Wed, Jun 16, 2021 at 2:04 PM Barry wrote: > > > > > > > > > >>> On Thu, Jun 17, 2021 at 6:06 AM Arak Rachael > > > > > >>> > > > > > wrote: > > > > > >>> I have an image from google maps to say and I need to check if it > > > > > >>> has > > > > > road markings, in order to do that, I believe I need to change the > > > > > effects > > > > > on the image so the markings and road can be white or something and > > > > > the > > > > > things I don't need like cars, trees and so on to be black. > [...] > > I understand your concerns. Actually I am doing image processing of > > satellite pictures for smart cars. > Using satellite images probably makes that a lot easier (yes, you wrote > "Google maps", but for some reason I thought of Google Street View). At > least you have a consistent angle (almost from straight above) and know > the scale (given the zoom factor and the latitude). > > hp > > -- > _ | Peter J. Holzer | Story must make more sense than reality. > |_|_) | | > | | | h...@hjp.at | -- Charles Stross, "Creative writing > __/ | http://www.hjp.at/ | challenge!" I made the crop code, before I posted the question, I just need the identification part: [code] # Library includes import os import cv2 # image and other special formats processing library # for computer vision import numpy as np from numpy import asarray import PIL from PIL import Image # Global variables # Recommended: move to a separate file # Recommended approach instead of using the "target" # name directly source_directory = "test" # Do not put a slash at the beginning output_directory = "test2" # Do not put a slash at the beginning # Function definitions def image_contains_required_elements(image):# Description: # The function will check if the cropped image contains the # required elements of the road(markings, road and others) # Local variables and initialization raise Exception("Not implemented yet") def split_image(path, dstpath): # Description: # Convert the generated frames(images) from # extract_video(video_path, target_dir_path) to grayscale # and reduce their size to half # Local variables and initialization # Requires the libraries: # import cv2 # import os # import pytest # import numpy as np # Processing # Reading an image in default mode #path = r'/home/yordan/devel/python.assignments/topgis-viz.2/data' # Source Folder #dstpath = r'/home/yordan/devel/python.assignments/topgis-viz.2/output_directory' # Destination Folder #path = source_directory # source_directory containing the images before the processing #dstpath = output_directory # output_directory containing the images after the processing """ # Test if target_directory exists try:# Try makedirs(dstpath) # to create target_directory except: # if there is an error print("Directory already exist, images will be written in same folder") # print the error message """ files = os.listdir(path)# Read the files from source_directory and record them in a list for image in files: # For index in list img = cv2.imread(os.path.join(path, image)) # Read the ima