Sign in to follow this  
Followers 0
inter

Sort Images By Content

6 posts in this topic

Hello all,

I've run up against a problem that I've not yet been able to find a solution to and am turning to the forums for help.

I've written a script that navigates through a cable box and takes screenshots of various screens and names and numbers them sequentially. There are three distinct types of screens I could capture and after all the screenshots are taken I need to sort the images into one of three folders depending on the variety. Unfortunately, because there is the potential of tens of thousands of screenshots being taken, sorting through them manually can get rather time consuming.

I've tried to automate this in a number of ways, but have run into troubles with each route I've taken. If I sort the screenshots into their respective folders as they're being taken I end up having problems with the files being numbered incorrectly if/when I have to restart the script. I also tried putting all the screenshots into one folder and appending a suffix to the file name based on the type and then sorting them into folders based on the suffix, but I've also run in to numbering problems with this route.

What seems to be my best route would be to dump all the screenshots in to one folder (with no suffix in the file name) and then loop through and PixelSearch each of them for different cues and sort them based on which cue is found in the image. I've done a great deal of searching and the closest solution I could come up with is but it seems that it's necessary to do this as the screenshots are taken, which I would think would greatly slow down my script. I've also tried GDI+ functions but wasn't able to get very good results with them (possibly user error).

Is there an "easy" solution to my problem or should I explore a different path altogether? Maybe there's another way I could name the files to solve my numbering problems? Apologies for not posting any code, but none of what I had seemed to be getting me anywhere so it got scrapped. If necessary, I could pretty easily recreate what I attempted before, so let me know.

Thanks in advance for any help/ideas provided. :)

Share this post


Link to post
Share on other sites



inter,

Could you please give an example of how you want the files to be numbered in the 3 folders. :)

My first thoughts are that if you can sort the files as they are taken then that would be the neatest solution. All you would then have to achieve is correct numbering - which is why I would like to see what you require. It might be as simple as having 3 counters running..... ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Thanks for your response Melba. Lets see if there's an easily understood way to describe things...

As I said in my original post, there are 3 different types of screenshots taken, we'll call them A, B, and C. I need something where filenames continue in sequence, regardless of where they're placed A1, A2, B3, B4, C5, C6, A7, B8, C9, etc.

My original attempt had me dumping everything into one folder (we'll call it $dir) and numbering them sequentially with no distinction of type at all, which worked fine but required a lot of work afterwards to sort through everything.

For $x = 1 to 1000
    If Not FileExists($dir & $ filename & $x & $date &  ".png") Then
       _ScreenCapture_CaptureWnd ($dir & $ filename & $x & $date &  ".png", $handle, 56, 41, 680, 520 )
       $x = $x + 1          
       ExitLoop
    EndIf
Next

My next idea was sort the screen shots as they were being taken into folders ($dir\Folder1, $dir\Folder2, $dir\Folder3) which resulted in duplicate file names across folders giving me A1, B1, C1, A2, B2, C2, etc.

For $x = 1 to 1000
    If Not FileExists($dir & "\Folder1" & $ filename & $x & $date &  ".png") Then
       _ScreenCapture_CaptureWnd ($dir & "\Folder1" & $ filename & $x & $date &  ".png", $handle, 56, 41, 680, 520 )
       $x = $x + 1          
       ExitLoop
    EndIf
Next

I tried another variation of the code above that gave the results I'd hoped for (A1, A2, B3, B4, C5, C6, A7, B8, C9, etc.), but if I had to stop and restart the script the filenames would start back at one giving me duplicate filenames: A1, B1, C1, A2, B2, C2, etc.

I should also mention that I've tried this calling one function and also by calling three different functions for each type of screenshot.

Apologies if any of this isn't clear, let me know as I'd be happy to further clarify.

Share this post


Link to post
Share on other sites

inter,

The obvious solution is to use an ini file or a registry entry to save the value of the last file saved when you close the script. Then when you restart the script you can read this value and know where to start numbering the files. in this way you can continue to separate the screenshots as you take them - which would also solve your sort problem. :)

For the functions to use, look (unsurprisingly) at IniWrite and IniRead, and RegWrite and RegRead. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

I'd actually just started to look into IniRead/Write yesterday but wasn't sure if it was an appropriate path to take. I'll give it a harder look this time, many thanks. :)

Share this post


Link to post
Share on other sites

inter,

You know where we are if you run into problems. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0