Jump to content

Open the jpg file containing the date and time.


Recommended Posts

Hello, I needed your help with a code I wrote.
The problem is; based on the data read and the date and time of the file to be opened. There is a difference of 1 second (very rarely 2 seconds) between the data read and the file to be opened. Let me exemplify like this.
The problem "0010171588\07.08.2023_17.32.40.jpg" pops up. but sometimes the file name to be opened can be "0010171588\07.08.2023_17.32.41.jpg" due to the network write delay, then the file cannot be opened. (although very rarely it can be 010171588\07.08.2023_17.32.42.jpg)
 

GUICtrlCreateGroup("QUIT PHOTO", 455, 280, 330, 260)
GUICtrlSetFont(-1, 10, 800, 0, "Righteous")
$Tim02a = StringRegExpReplace($Read24, "\A(\d*):(\d*):(\d*)", "$1.$2.$3")
$Tim02b = $Read21 & "\" & $Read22 & "_" & $Tim02a & ".jpg"

If FileExists($Tim02b) Then
    $Pict02 = GUICtrlCreatePic($Tim02b, 460, 295, 320, 240)
    ConsoleWrite($Tim02b & @CR)
Else
    Local $Tim03a = StringRegExpReplace($Tim02a, "_(\d+)\.", "_" & IncrementSecond("$1") & ".")
    $Tim03b = $Read21 & "\" & $Read22 & "_" & $Tim03a & ".jpg"
    $Pict02 = GUICtrlCreatePic($Tim03b, 460, 295, 320, 240)
    ConsoleWrite($Tim03b & @CR)
EndIf

Func IncrementSecond($match)
    Return "_" & (Int($match) + 1) & "."
EndFunc

:ILA2:

Edited by mucitbey
Link to comment
Share on other sites

24 minutes ago, rsn said:

How often are the files written? If it's greater than a few seconds, maybe build in a few seconds of leeway for the filenames, like +-2 sec?

     Data is not generated in an orderly fashion. The data is recorded in an ini file with date and time data, and when this process is completed, a jpg file taken with the webcam is recorded. However, when I want to match the ini file with the jpg data, I cannot match because of the difference in the file name between the read data and the data to be retrieved, since the jpg file is usually written with a 1-2 second delay, although not always. I hope I was able to explain the problem.

Edited by mucitbey
Link to comment
Share on other sites

For me it's not clear at all. I got the part where you get some screen captures from your webcam and save them as jpg files and the name of each file contains date/time information. Where does this +- delay come from?

When the words fail... music speaks.

Link to comment
Share on other sites

11 minutes ago, Andreik said:

For me it's not clear at all. I got the part where you get some screen captures from your webcam and save them as jpg files and the name of each file contains date/time information. Where does this +- delay come from?

When the record is entered, it first writes the data as Date (07.08.2023) and Time (17.32.40) in an ini file, and takes a picture of the document with a webcam after saving it (07.08.2023_17.32.41.jpg). When the webcam creates a file, it records with a delay of 1 second. therefore, while matching the image file with the data in the ini program (07.08.2023) and Clock (17.32.40) it tries to merge and open the jpg file. But it can't find the file because of the delay.

I also save the image with this udf.

Webcam UDF

Edited by mucitbey
Link to comment
Share on other sites

Why don't you save the timestamp in the JPG itself?

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

I think you are saying that the actual filename is created by the webcam software and you are not in control of that file generated.

Some things you could try

Take webcam snapshot before writing ini file

Take a directorylist and sort that on time and see if latest matches to your timestamp.

Link to comment
Share on other sites

Convert the date in .ini into a sortable format (y-m-d h:m:s) use _FileListToArray to list files then convert similarly dates in filenames into the same sortable format. Then it's easy to find a file dated within few seconds of the ini date.

Things would be much simpler if a standard (sortable) datetime stamp were used!

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

Hello,
First of all, thank you all for your help and guidance. I solved the problem in a different way. I went back to the codes I wrote first, there was something I missed at first, when I fixed it, the problems were solved. Therefore, this procedure is no longer necessary. In short, my mistake was that I tried to write the ":" character in the filename. :thumbsup:

Link to comment
Share on other sites

3 hours ago, mucitbey said:

I tried to write the ":" character in the filename

That creates an ADS (Alternate Data Stream) "under" the main filename (provided the file system of the device is NTFS). https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-fscc/e2b19412-a925-4360-b009-86e3b8a020c8

 

Edited by jchd

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...