Method and device for synchronously collecting DIC data and storage medium
By combining the software of a DSLR camera with that of a universal testing machine, synchronous acquisition of DIC data without additional hardware was achieved, solving the problems of high barriers to entry and high costs in existing technologies, and improving the resolution and accuracy of DIC data.
Patent Information
- Application Number
- CN202511100378.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-07
- Publication Date
- 2025-11-14
AI Technical Summary
Existing DIC technologies suffer from high costs for commercial systems, low resolution for industrial cameras, and high barriers to data synchronization and acquisition. Furthermore, the need for additional hardware equipment increases the application threshold.
By combining a DSLR camera with a universal testing machine, and through secondary software development and driver modification, hotkey binding between the DSLR camera and the universal testing machine was achieved. Combined with Python and the Pymsgbox extension package, synchronous acquisition of DIC data was realized without the need for additional hardware.
It reduced hardware requirements, enabled high-precision DIC data synchronous acquisition, simplified the operation process, improved resolution and data accuracy, and reduced costs.
Smart Images

Figure CN120957016A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of digital image experimental technology, and in particular to a method, device and storage medium for synchronous acquisition of DIC data. Background Technology
[0002] Digital image correlation (DIC) is a non-contact, visual non-destructive testing technique based on image processing and computer vision. By processing surface images of the sample before and after deformation, it directly obtains the full-field displacement and strain distribution. The DIC method is highly versatile and can be applied to almost any type of material testing under numerous experimental conditions. It achieves sub-pixel accuracy at two-dimensional or three-dimensional macroscopic and micro / nanoscale scales, and boasts advantages such as non-contact, full-field, real-time performance, and simple equipment. The DIC method acquires digital images of the specimen before and after deformation using a camera. A computer then divides the AOI (Area of Interest) in the image before deformation into a mesh. For each sub-region, calculations are performed according to a predefined function. In the image after deformation, the region with the highest cross-correlation coefficient for each sub-region is found, thus obtaining the displacement of each sub-region. All sub-regions are then merged to obtain the full-field deformation information, including deformation, displacement, and strain. Commonly used digital image correlation methods include two-dimensional digital image correlation (2D-DIC) using a single camera and three-dimensional image correlation (3D-DIC) using multiple cameras. The system components are the same: camera, light source, control system, and image post-processing software.
[0003] Existing technologies suffer from problems such as high cost of commercial systems, low resolution of industrial cameras, and high barriers to data synchronization acquisition, which significantly limit the application of DIC methods in industry and research. Furthermore, while some existing technologies use SLR cameras to achieve synchronous acquisition of DIC data with universal testing machines, this inevitably requires additional hardware. Currently, there is no technology that can achieve high-precision synchronous acquisition of DIC experimental data without additional hardware.
[0004] For example, Chinese invention patent application CN117629092A discloses a method, device, equipment, and medium for acquiring DIC experimental data. The method includes: mounting a flash trigger on a camera hot shoe and connecting the positive and negative terminals of the flash trigger to a voltage acquisition unit; using a preset SLR camera control program in a control terminal device to acquire images of the required image area of the DIC test piece to determine the image data for the DIC experiment; and using a voltage acquisition program in the control terminal device to acquire the operating voltage data of the flash trigger to determine the image data acquisition time. It is evident that this patent includes additional hardware devices such as a flash trigger, a voltage acquisition unit, and a control terminal device. The introduction of these hardware devices raises the application threshold of this technology to some extent. Summary of the Invention
[0005] To address the problems of high cost of commercial systems, low resolution of industrial cameras, and high barriers to data synchronization in existing DIC technologies, this invention provides a method for DIC data synchronization acquisition that can achieve synchronous acquisition of universal testing machine data and DIC image data without any additional hardware equipment.
[0006] According to a first aspect of the present invention, a method for synchronous acquisition of DIC data is provided, comprising the following steps: Place the DIC sample on the fixture of the universal testing machine, mount the SLR camera on a tripod, align the SLR camera viewfinder with the DIC sample, adjust the focal length and focal length of the SLR camera to achieve the best display effect of the DIC image, and keep it locked, while turning off the autofocus and auto exposure functions of the SLR camera. Connect the DSLR camera to the computer that comes with the universal testing machine, and modify the camera control driver, including: binding the "start taking pictures" hotkey of the DSLR camera to the "start testing" hotkey in the universal testing machine, opening the camera control driver, and running the hotkey binding in the background; Setting up a program to send hotkey signals at intervals on a computer includes: modifying the hotkey in the corresponding code inside the program to the hotkey bound to "Start Taking Pictures" according to the bound hotkey, opening the program to send hotkey signals at intervals, inputting the interval time as needed, and keeping it running in the background; Open the universal testing machine's operating interface and press the "Start Test" hotkey to start data acquisition simultaneously with the DSLR camera. The data correspondence is completed according to the universal testing machine's data acquisition frequency and interval shooting frequency.
[0007] Based on the above technical solution, the present invention can also be improved as follows.
[0008] Preferably, before the step of connecting the SLR camera to the drive, the following steps are also included: Mount the fill light on a tripod, aim the light at the DIC specimen data acquisition area, and adjust the light angle to make the acquisition area bright but not obviously overexposed.
[0009] Preferably, before the step of connecting the SLR camera to the drive, the following steps are also included: To find the keyboard shortcut for "Start Test" in the universal testing machine software, look up the "X" key. Install the Keyboard hotkey monitoring extension package on the computer corresponding to the universal testing machine; Install the corresponding driver package according to the brand of your SLR camera; Configure the driver package to match the "Start Taking Pictures" function in the driver and the "Start Experiment" function in the software with the same keyboard hotkey; use the Keyboard hotkey monitoring extension package to globally monitor the hotkey, that is, when the SLR camera driver is running in the background, it monitors the hotkey, and when the hotkey signal is received, it performs the picture taking operation.
[0010] Preferably, the modification of the camera control driver to bind the "Start Taking Pictures" hotkey of the SLR camera to the "Start Testing" hotkey of the universal testing machine includes: Change the hotkey for "Take Picture" in the DSLR camera driver to the "X" key. At the same time, use the Keyboard hotkey monitoring extension package to globally monitor the hotkey "X" key, so that when the driver is running in the background, pressing the hotkey "X" on the keyboard will perform "Take Picture".
[0011] Preferably, before the step of setting up the program for sending hotkey signals at intervals on the computer, the following steps are included: Configure the Python and C++ runtime environments on the computer installed in the universal testing machine; Install the Pymsgbox extension package on the computer where the universal testing machine is installed; The universal testing machine's corresponding computer opens the interval hotkey signal sending program; After setting the interval for the program, run the program, check the results, and keep it running in the background.
[0012] Preferably, the program for setting up intervals for sending hotkey signals on a computer includes: The Python programming language is used to input the hotkey "X" into the computer every few seconds.
[0013] Preferably, the program for sending hotkey signals at intervals needs to implement the following functions: Automatically send the hotkey "X" function, automatically sending the "X" key once at a specified time interval, and stopping when the "ESC" key is triggered; Input the photo-taking interval time, pop up a window to input the required photo-taking time interval, and prompt to switch to the testing machine software and manually press the "X" key to start the test; Regularly trigger the "X" key and end photo-taking when "ESC" is detected.
[0014] Preferably, when performing high-speed continuous shooting, connect the DSLR camera to the computer supporting the universal testing machine, open the control driver, set the shooting mode to high-speed continuous shooting mode in the driver, and make the driver run in the background; At this time, there is no need to start the program for sending hot key signals at intervals. Just open the operation interface of the universal testing machine in the computer, set the test parameters, and tap the hot key "X" to make the universal testing machine and the DSLR camera start data acquisition simultaneously; then the driver automatically controls high-speed photo-taking to acquire DIC data.
[0015] According to the second aspect of the present invention, an electronic device is provided, including a memory and a processor. When the processor executes the computer program stored in the memory, the implementation steps of a method for synchronously collecting DIC data are realized.
[0016] According to the third aspect of the present invention, a computer-readable medium is provided, which stores a computer program implemented according to the method for synchronously collecting DIC data by the DSLR camera in the form of computer-readable instructions. The computer program includes: Change the hot key of "Take Picture" in the driver to the "X" key, and at the same time use the keyboard hot key monitoring extension package Keyboard to globally monitor the "X" key. When the driver runs in the background, tap the "X" key on the keyboard to implement "Take Picture"; The program for interval acquisition; implemented using programming languages such as Python. Every few seconds, input the hot key "X" to the computer, and the input box pops up the extension package Pymsgbox to implement the input of the interval time.
[0017] In specific implementation, the two programs can be integrated together; when the computer program is called and run by the computer, the method for synchronously collecting DIC data as described above is executed.
[0018] The present invention has the following technical effects and advantages: The present invention provides a method, device and storage medium for synchronously collecting DIC data, which can realize the synchronous collection of the data of the universal testing machine and the DIC image data without any additional hardware devices.
[0019] Secondly, the method for synchronous acquisition of DIC data provided by this invention relies on secondary software development and modification of the driver program. The medium on which it is based is the computer connected to the universal testing machine. It has no performance or interface requirements for the computer, and the program triggering has no delay. It also supports the custom modification of parameters such as acquisition frequency.
[0020] Third, the maximum acquisition frequency of the DIC experimental data of this invention can reach the level of general industrial cameras. The specific value depends on the specific model of the SLR camera. In practice, it reached 30Hz. It is difficult to achieve such a high acquisition frequency by using external devices such as flash triggers to trigger synchronous high-speed acquisition. The DIC data synchronous acquisition method described in this invention reduces the hardware requirements of laboratory instruments in the prior art and builds a low-cost DIC data synchronous acquisition test platform. Fourth, the connection and data acquisition between industrial cameras and computers in existing technologies have certain technical barriers and are relatively complex to operate. In contrast, SLR cameras can be connected to most computers on the market via USB interface, and the code for secondary development and interval shooting programs is relatively simple, which simplifies the DIC experimental operation process. SLR cameras have higher resolution than industrial cameras and can resolve smaller speckle sizes, which is more effective in analyzing fine objects such as microcracks and improves the accuracy of DIC experimental data. Attached Figure Description
[0021] Figure 1 A flowchart illustrating a method for synchronous acquisition of DIC data provided in an embodiment of the present invention; Figure 2 This is a schematic diagram of the process of synchronously acquiring experimental data by a universal testing machine and a DSLR camera in low-frequency mode in Embodiment 1 of the present invention; Figure 3 This is a flowchart and effect diagram of the interval photography procedure in Embodiment 1 of the present invention; Figure 4 This is a schematic diagram of the process of synchronously acquiring experimental data by a universal testing machine and a DSLR camera in high-frequency mode in Embodiment 2 of the present invention; Figure 5 The figures show a comparison of the DIC image effects acquired by the present invention and existing technologies. In the figures, (a) represents the original image acquired by a commonly used industrial camera; (b) represents the strain cloud map after post-processing; (c) represents the original image acquired by the method of the present invention; and (d) represents the strain cloud map after post-processing. Figure 6 The diagram shows the distribution of microcracks obtained by optical microscope measurements, prior art, and three different acquisition methods of the present invention, as provided in the embodiments of the present invention. Detailed Implementation
[0022] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0023] In existing technologies, most systems utilize complete sets of commercial DIC strain measurement systems, which are relatively expensive and lack interchangeability, meaning each component in the system is a one-to-one matching unit. Traditional DIC systems use industrial cameras with low resolution, and their connection to computers and data acquisition have certain technical barriers, making operation complex. Existing control systems only support independent control of the industrial camera at the time of purchase. If synchronization with a universal testing machine is required, a completely redesigned system is necessary, which limits the brand and output interface of the universal testing machine and increases additional costs. Alternatively, manual control of the camera and testing machine synchronization can lead to errors.
[0024] It is understood that, in order to address the problems mentioned in the background, this invention provides a method for synchronous acquisition of DIC data, specifically as follows: Figure 1 As shown, it includes the following steps: Install the DIC sample and the DSLR camera: Place the processed DIC sample on the fixture of the universal testing machine, mount the DSLR camera on the tripod, align the DSLR camera viewfinder with the DIC sample, change the focal length and focal length of the DSLR camera to achieve the best DIC image effect, and keep it locked, while turning off the DSLR camera's autofocus and auto exposure functions. DSLR camera connection driver: Connect the DSLR camera to the computer that comes with the universal testing machine, open the specially coded camera control driver, bind the "Start Taking Pictures" hotkey in it to the "Start Testing" hotkey in the universal testing machine, and run it in the background; Set up the interval photo-taking program: Open the self-written interval hotkey signal sending program, input the interval time as needed, and keep it running in the background; Simultaneous data acquisition by universal testing machine and SLR camera: Open the universal testing machine operation interface and press the "Start Test" hotkey to start data acquisition by both the universal testing machine and the SLR camera at the same time; complete the data correspondence according to the data acquisition frequency of the universal testing machine and the interval shooting frequency in the program.
[0025] In this embodiment of the invention, the DIC sample includes hard surface materials such as concrete, mortar, and rock. The hotkey can be set to any key according to user habits; it is hereby labeled with an "X" key.
[0026] In this embodiment of the invention, before the step of connecting the SLR camera to the driver, the following steps are also included: Mount the fill light on a tripod, aim the light at the DIC specimen data acquisition area, and adjust the light angle to make the acquisition area bright but not obviously overexposed.
[0027] Before the step of connecting the DSLR camera to the driver, the following steps are also included: To find the keyboard shortcut for "Start Test" in the universal testing machine software, look up the "X" key. Install the Keyboard hotkey monitoring extension package on the computer corresponding to the universal testing machine; Install the corresponding driver package according to the brand of your SLR camera; The driver package is further developed to bind the "Start Taking Pictures" hotkey in the driver to the corresponding "Start Testing" hotkey in the universal testing machine software. That is, the "Start Taking Pictures" hotkey in the driver and the "Start Testing" hotkey in the software correspond to the same keyboard hotkey. The Keyboard hotkey monitoring extension package is used to globally monitor the hotkey. That is, the hotkey will also be monitored when the SLR camera driver is running in the background. When the hotkey signal is received, the corresponding operation is performed.
[0028] The modification of the camera control driver, which binds the "Start Taking Pictures" hotkey of the SLR camera to the "Start Testing" hotkey of the universal testing machine, includes: changing the "Take Picture" hotkey in the SLR camera driver to the "X" key, and using the Keyboard hotkey monitoring extension package to globally monitor the "X" key, so that when the driver is running in the background, pressing the "X" hotkey on the keyboard will achieve "Take Picture".
[0029] Before setting up the procedure for sending hotkey signals at intervals, the following steps are included: Configure the Python and C++ runtime environments on the computer installed in the universal testing machine; Install the Pymsgbox extension package on the computer where the universal testing machine is installed. Open the program for sending hotkey signals at intervals on the computer corresponding to the universal testing machine. Based on the hotkeys bound in the above steps, modify the hotkeys in the corresponding Python code inside the program to the hotkeys bound to "Start taking pictures". After setting the interval for the program, run the program, check the results, and keep it running in the background.
[0030] The program for setting up intervals to send hotkey signals on a computer includes: using the Python programming language to input the hotkey "X" into the computer every few seconds.
[0031] The present invention will be further illustrated below by way of embodiments. The specific process conditions and results described in the embodiments are only for illustrating the present invention, but do not limit the present invention to the scope of the embodiments.
[0032] Example 1 It should be noted that this embodiment is a low-frequency synchronous acquisition of DIC experimental data. Interval data acquisition is achieved through a self-written Python program. At this time, the driving shooting mode is "Single Shot". Due to the shutter speed limitation, the maximum acquisition frequency is 2Hz, that is, two DIC data are acquired per second. In this embodiment, the keyboard hotkey "X" is set to the keyboard "Enter" key.
[0033] The SLR camera used in this embodiment is a Canon camera, corresponding to the official Canon SDK driver, which supports secondary development and remote camera control. The universal testing machine in this embodiment is a universal testing machine from MTS Corporation; The core code for interval photography is as follows: 1) Automatically send the hotkey "Enter". Automatically send the Enter key once every specified time interval, looping until the "ESC" key is triggered.
[0034] def auto_press_enter(interval): global stop_flag print(f"\nStarted, sending Enter key every {interval} seconds, press ESC to stop.\n") while not stop_flag: keyboard.press_and_release('enter') print(f"[{time.strftime('%H:%M:%S')}] Sent") time.sleep(interval) print("End") def stop_shooting(): global stop_flag stop_flag = True print("ESC detected, end...") 2) Enter the photo interval time. A pop-up window will appear; enter the required photo interval time and you will be prompted to switch to the testing machine software and manually press Enter to start the test.
[0035] if __name__ == "__main__": interval = pymsgbox.prompt(text='Shooting interval (seconds):', title='Timed shooting settings', default='5') interval = int(interval) print("\nPlease switch to the testing machine software interface and manually press Enter to start the test...") keyboard.wait('enter') 3) The Enter key is triggered periodically, and the photo taking ends when "ESC" is detected.
[0036] click_thread = threading.Thread(target=auto_press_enter, args=(interval,)) click_thread.start() keyboard.add_hotkey('esc', stop_shooting) Appendix Figure 2 This is a flowchart illustrating the process of synchronously acquiring experimental data using a universal testing machine and a DSLR camera in low-frequency mode, as described in Example 1, to achieve synchronous acquisition of DIC experimental data at a lower frequency. The diagram is mainly divided into three parts: the first part is the synchronous startup of the testing machine and camera, which can be achieved without additional hardware; the second part is the interval acquisition of DIC image data, which can be achieved at lower intervals using a self-written script; the third part is the precise correspondence between the testing machine data and the DIC image data, which can be achieved by matching the acquisition frequency of the testing machine with the acquisition frequency of the self-written program. The method includes the following steps: First, install the Visual Studio compiler on your computer; configure the C++ and Python runtime environments on your computer; and install the required Keyboard and Pymsgbox extension packages on your computer.
[0037] Step S101. Install the DIC specimen and the SLR camera. Place the processed DIC sample (such as hard surface materials such as concrete, mortar and rock) on the fixture of the universal testing machine. Mount the SLR camera on a tripod so that the viewfinder of the SLR camera is aligned with the DIC specimen. Change the focal length and focal length of the SLR camera to achieve the best DIC image effect and keep it locked. At the same time, turn off the autofocus and auto exposure functions of the SLR camera. Next, turn on the computer and confirm that the hotkey for "Start Test" in the universal testing machine software is the "Enter" key. Install the Canon SDK driver package on the computer and perform secondary development. Modify the code controlling the main interface in the driver, i.e., the MainWindows.cs file, to add two functions: first, change the Take Picture hotkey to "Enter"; second, globally listen for the keyboard hotkey "Enter". After completing the secondary development of the driver, use the compilation software Visual Studio to compile the driver to obtain the CameraControl.exe application, which is the Canon SDK driver. Step S102. Connect the DSLR camera to the computer corresponding to the universal testing machine, open the control driver, select the shooting mode as "Single Shot", and run the driver in the background. Step S103. Set up the interval shooting program. The operation flow and effect diagram of the interval shooting program are as follows: Figure 3 As shown, open the Python-written program for sending hotkey signals at intervals. Specifically, the program needs to perform the following functions: First, after opening the hotkey signal program, the user manually inputs the interval time, which is set to 5 seconds here; Second, every 5 seconds, the program automatically inputs the hotkey "Enter" command to the computer. The Canon SDK driver receives the hotkey "Enter" command through global listening and performs a Take Picture operation, that is, completes one DIC image data acquisition. Input the interval time as needed and keep it running in the background; Step S104. The universal testing machine and the SLR camera acquire data synchronously. Open the universal testing machine operation interface on the computer, set the test parameters, and press the hotkey "Enter" to start data acquisition simultaneously from the universal testing machine and the SLR camera. After that, the Python program automatically sends the "Enter" command every 5 seconds to control the SLR camera to take pictures.
[0038] Specifically, the universal testing machine used in this embodiment has a data acquisition frequency of 20Hz, meaning it acquires 20 mechanical data points per second, while a DSLR camera acquires image data once every 5 seconds. Based on this conversion, the 1st, 2nd, and 3rd images in the DIC image data correspond to the 1st, 101st, and 201st mechanical data points in the testing machine, respectively, and so on, thus completing the correspondence between the DIC image data and the universal testing machine's mechanical data.
[0039] Example 2 Example 2 is a high-frequency synchronous acquisition of DIC data, with appendix. Figure 4This is a flowchart illustrating the process of synchronously acquiring experimental data using a universal testing machine and a DSLR camera in high-frequency mode, as shown in Example 2, to achieve higher-frequency DIC experimental data acquisition. It mainly consists of three parts; the first part is the same as in Example 1 (see attached diagram). Figure 1 The method involves three parts: first, maintaining consistency between the data acquisition frequency of the testing machine and the high-speed acquisition frequency in the driver; second, high-frequency acquisition of DIC image data by modifying the high-speed capture frequency in the camera driver; and third, precise data correspondence by establishing a correspondence between the testing machine's data acquisition frequency and the high-speed acquisition frequency in the driver. The method includes the following steps: Before step S102, the process remains consistent with Example 1; Step S102. Connect the DSLR camera to the computer that comes with the universal testing machine, open the control driver, set the shooting mode to "High speed continuous" in the driver, and run the driver in the background. Step S103 is not included at this time, that is, there is no need to start the interval photography program; Step S104. Simultaneous data acquisition by universal testing machine and SLR camera: Open the universal testing machine operation interface on the computer, set the test parameters, and press the hotkey "Enter" to start data acquisition by both the universal testing machine and SLR camera simultaneously; then the Canon SDK driver will automatically control high-speed photography to acquire DIC data. Specifically, referring to the method of secondary development of the driver in Embodiment 1, the frequency of high / low speed continuous shooting in the driver can be obtained and modified. This can be done by obtaining the information in the SDK's Property system and modifying the sampling frequency in the CPP module. It is worth noting that the maximum supported sampling frequency is related to the camera model. In this Embodiment 2, the sampling frequency of the high-speed continuous shooting mode is set to 20Hz. Specifically, the data acquisition frequency of the universal testing machine used in this example is 20Hz, that is, 20 data points are acquired per second. The acquisition frequency in the high-speed continuous shooting mode is 20Hz, meaning that the mechanical data obtained by the universal testing machine corresponds one-to-one with the image data in the DIC.
[0040] Appendix Figure 5 This is a comparison image showing the effects of DIC images acquired using the present invention and existing technologies. Existing technologies use industrial cameras to acquire DIC image data, and the original images acquired by commonly used industrial cameras are... Figure 5 As shown in (a), with a resolution of 2448×2048, the post-processed strain contour map is as follows: Figure 5 As shown in (b), it can be seen that the identification effect of microcracks is poor, and the strain cloud map shows a sheet-like shape instead of the linear shape that cracks should have. Figure 5(c) is the original image acquired using the method of this invention, with a resolution of 6240×4160, which is much larger than that of existing technologies. Meanwhile, as... Figure 5 As shown in (d), the method of the present invention has a better identification effect on micro-cracks and other fine objects, and the strain cloud map shows a line shape that is closer to the crack itself.
[0041] Appendix Figure 6 The figure shows the distribution of microcracks obtained by three different acquisition methods: optical microscopy measurement, existing technology, and the present invention. The horizontal axis represents the microcrack width obtained after image post-processing, and the vertical axis represents the corresponding number of cracks. The black curve represents the measured value obtained by optical microscopy, which can be considered the true distribution of microcracks. The red curve represents the distribution obtained by the method of the present invention, and the blue curve represents the distribution obtained by existing technology. It is evident that the present invention shows a smaller discrepancy with the true distribution, with crack widths all in the tens of micrometers range. In contrast, the crack widths obtained by the existing technology are much larger than the measured values, and the number of cracks is less than the actual number. This is because the existing technology has lower resolution, causing several cracks to be identified as a single crack.
[0042] In summary, the low-cost, high-precision DIC experimental data acquisition method described in this embodiment of the invention can achieve synchronous acquisition of universal testing machine data and DIC image data without any additional hardware equipment.
[0043] To another objective of the present invention, embodiments of the present invention also provide an electronic device, including a memory and a processor, wherein the processor is used to execute a computer program stored in the memory to implement the above-described method for synchronous acquisition of DIC data.
[0044] To another objective of the present invention, embodiments of the present invention provide a computer storage medium storing, in the form of computer-readable instructions, a computer program implemented according to the method for synchronous acquisition of DIC data, the computer program comprising: This is a secondary development program for SLR camera drivers. Most commonly used SLR camera brands have their own official drivers, which also support secondary development. The drivers all support computer-controlled camera shooting. By modifying the driver source code, for example, changing the hotkey for "Take Picture" to the "Enter" key, and using the Keyboard hotkey monitoring extension package to globally monitor the "Enter" hotkey, the program can achieve "Take Picture" when the driver is running in the background and the "Enter" hotkey is pressed on the keyboard. Modify MainWindows.cs in the Canon SDK driver. The core code is as follows, consisting of four steps: 1) Add a global hotkey registration function. This code uses the Win32 API's RegisterHotKey and UnregisterHotKey to implement global listening for the hotkey (Enter), so that it can respond even if the window is not focused.
[0045] Add the following before the line `private CameraController _controller = null;`: [DllImport("user32.dll")] private static extern bool RegisterHotKey(IntPtr hWnd, int id, intfsModifiers, Keys vk); [DllImport("user32.dll")] private static extern bool UnregisterHotKey(IntPtr hWnd, int id); private const int HOTKEY_ID = 100; 2) Register hotkeys during window initialization Add the following after InitializeComponent();: RegisterHotKey(this.Handle, HOTKEY_ID, 0, Keys.Enter); 3) Rewrite WndProc to capture hotkey messages. This part of the code captures the WM_HOTKEY message sent by Windows. When our defined HOTKEY_ID is detected, the TriggerTakePicture() method is triggered.
[0046] Add the following code anywhere: protected override void WndProc(ref Message m) { const int WM_HOTKEY = 0x0312; if (m.Msg == WM_HOTKEY&&m.WParam.ToInt32() == HOTKEY_ID) { TriggerTakePicture();} base.WndProc(ref m); } 4) Define the photo-taking trigger function. It calls the existing FireEvent method in the controller, equivalent to the user clicking the photo button, thus achieving the integration of the hotkey and controller logic.
[0047] private void TriggerTakePicture() { _actionSource.FireEvent(ActionEvent.Command.TAKE_PICTURE,IntPtr.Zero); Console.WriteLine("Global Enter key press has triggered photo capture!"); } For interval data acquisition, the program is implemented using programming languages such as Python. Every 5 seconds, the user inputs the hotkey "X" into the computer. An extension box (Pymsgbox) pops up to display the interval time. Pressing the hotkey "Esc" terminates the program. Figure 3 This is the effect of the interval photo-taking program.
[0048] The core code for interval photography is as follows: 1) Automatically send the hotkey "Enter". Automatically send the Enter key once every specified time interval, looping until the "ESC" key is triggered.
[0049] def auto_press_enter(interval): global stop_flag print(f"\nStarted, sending Enter key every {interval} seconds, press ESC to stop.\n") while not stop_flag: keyboard.press_and_release('enter') print(f"[{time.strftime('%H:%M:%S')}] Sent") time.sleep(interval) print("End") def stop_shooting(): global stop_flag stop_flag = True print("ESC detected, end...") 2) Enter the photo interval time. A pop-up window will appear. Enter the desired photo interval time (the default setting is 5 seconds), and you will be prompted to switch to the testing machine software and manually press Enter to start the test.
[0050] if __name__ == "__main__": interval = pymsgbox.prompt(text='Shooting interval (seconds):', title='Timed shooting settings', default='5') interval = int(interval) print("\nPlease switch to the testing machine software interface and manually press Enter to start the test...") keyboard.wait('enter') 3) The Enter key is triggered periodically, and the photo taking ends when "ESC" is detected.
[0051] click_thread = threading.Thread(target=auto_press_enter, args=(interval,)) click_thread.start() keyboard.add_hotkey('esc', stop_shooting) In practice, the two programs can be integrated together.
[0052] When the computer program is invoked and executed, it performs the implementation steps of a DIC data synchronization acquisition method as described above.
[0053] The preferred embodiments of the present invention have been described in detail above. It should be understood that those skilled in the art can make numerous modifications and variations based on the concept of the present invention without creative effort. Therefore, all technical solutions that can be obtained by those skilled in the art based on the concept of the present invention through logical analysis, reasoning, or limited experimentation on the basis of existing technology should be within the scope of protection defined by the claims.
[0054] Finally, it should be noted that the above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art can still modify the technical solutions described in the foregoing embodiments or make equivalent substitutions for some of the technical features. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A method for synchronous acquisition of DIC data, characterized in that, Includes the following steps: Place the DIC sample on the fixture of the universal testing machine, mount the SLR camera on a tripod, align the SLR camera viewfinder with the DIC sample, adjust the focal length and focal length of the SLR camera to achieve the best display effect of the DIC image, and keep it locked, while turning off the autofocus and auto exposure functions of the SLR camera. Connect the DSLR camera to the computer that comes with the universal testing machine, and modify the camera control driver, including binding the "Start Taking Pictures" hotkey of the DSLR camera to the "Start Testing" hotkey in the universal testing machine, opening the camera control driver, and running the hotkey binding in the background. Setting up a program to send hotkey signals at intervals on a computer includes: modifying the hotkey in the corresponding code inside the program to the hotkey bound to "Start Taking Pictures" according to the bound hotkey, opening the program to send hotkey signals at intervals, inputting the interval time as needed, and keeping it running in the background; Open the universal testing machine's operating interface and press the "Start Test" hotkey to start data acquisition simultaneously with the DSLR camera. The data correspondence is completed according to the universal testing machine's data acquisition frequency and interval shooting frequency.
2. The method for synchronous acquisition of DIC data according to claim 1, characterized in that, Before the step of connecting the DSLR camera to the driver, the following steps are also included: Mount the fill light on a tripod, point the light at the DIC sample data acquisition area, and adjust the light angle to make the acquisition area bright but without obvious exposure.
3. The method for synchronous acquisition of DIC data according to claim 1, characterized in that, Before the step of connecting the DSLR camera to the driver, the following steps are also included: To find the keyboard shortcut for "Start Test" in the universal testing machine software, look up the "X" key. Install the Keyboard hotkey monitoring extension package on the computer corresponding to the universal testing machine; Install the corresponding driver package according to the brand of your SLR camera; Configure the driver package to match the "Start Taking Pictures" function in the driver with the "Start Testing" function in the universal testing machine software to the same keyboard hotkey. Use the Keyboard hotkey monitoring extension package to globally monitor the hotkey. That is, when the SLR camera driver is running in the background, it will monitor the hotkey and perform a picture taking operation when the hotkey signal is received.
4. The method for synchronous acquisition of DIC data according to claim 1, characterized in that, The process of binding the "Start Taking Pictures" hotkey on a DSLR camera with the "Start Testing" hotkey on a universal testing machine includes: Change the hotkey for "Take Picture" in the DSLR camera driver to the "X" key. At the same time, use the Keyboard hotkey monitoring extension package to globally monitor the hotkey "X" key. This will enable "Take Picture" when the driver is running in the background and you press the hotkey "X" on the keyboard.
5. The method for synchronous acquisition of DIC data according to claim 1, characterized in that, Before the step of setting up the program for sending hotkey signals at intervals on the computer, the following steps are included: Configure the Python and C++ runtime environments on the computer installed in the universal testing machine; Install the Pymsgbox extension package on the computer where the universal testing machine is installed; Open the program for sending hotkey signals at intervals on the computer corresponding to the universal testing machine; After setting the interval for the program, run the program, check the results, and keep it running in the background.
6. The method for synchronous acquisition of DIC data according to claim 1, characterized in that, The program for setting up interval-based hotkey signal transmission on the computer includes: Use the Python programming language to input the hotkey "X" into the computer every few seconds.
7. The method for synchronous acquisition of DIC data according to claim 6, characterized in that, The program for sending hotkey signals at intervals needs to implement the following functions: Automatically send the hotkey "X" function, automatically sending the "X" key once at a specified time interval, and stopping when the "ESC" key is triggered; Enter the photo interval time. A pop-up window will appear. Enter the required photo interval time and prompt you to switch to the testing machine software and manually press the "X" key to start the test. The "X" key is triggered at regular intervals, and the photo taking ends when "ESC" is detected.
8. The method for synchronous acquisition of DIC data according to claim 1, characterized in that, When performing high-speed continuous shooting, connect the SLR camera to the computer that comes with the universal testing machine, open the control driver, set the shooting mode to high-speed continuous shooting mode in the driver, and run the driver in the background. At this point, there is no need to start the interval hotkey signal sending program. Simply open the universal testing machine operation interface on the computer, set the test parameters, and press the hotkey "X" to make the universal testing machine and the SLR camera start data acquisition simultaneously; then drive automatic control to perform high-speed photography and DIC data acquisition.
9. An electronic device, characterized in that, The device includes a memory and a processor, wherein the processor is used to execute a computer program stored in the memory to implement a method for synchronous acquisition of DIC data as described in any one of claims 1 to 8.
10. A computer-readable storage medium, characterized in that, It stores a computer program, which includes: changing the hotkey for "Take Picture" in the SLR camera driver to the "X" key, and using the Keyboard hotkey monitoring extension package to globally monitor the hotkey "X" key, so that when the driver is running in the background, pressing the hotkey "X" on the keyboard will realize "Take Picture"; and / or using the Python programming language to input the hotkey "X" into the computer every few seconds to realize the input of the interval time; Furthermore, when the computer program is invoked and executed by the computer, it performs a method for synchronous acquisition of DIC data as described in any one of claims 1 to 8.
Citation Information
Patent Citations
DIC experimental data acquisition method, device, equipment and medium
CN117629092A