# ChatGPT Translation of Program Code for Image Sketch Abstraction
## 5 Motion Detection with ChatGPT-4  
Once the MATLAB skeleton code was translated to Python, and the M-to-PY converter, together with the Skeleton app, was fully tested and deployed [21; 22], it was decided to create a case study of conducting motion detection supervised by ChatGPT. Following the logic of the original Skeleton project [2], the ChatGPT-4 model was set to do an Advanced Data Analysis, last updated on 25 September 2023. It was asked to walk the researcher through the process of motion detection based on the information it contains. The chats with the chatbots and generated code outcomes were all recorded and can be found publicly [23; 24]. More examples can be provided on demand. Table 3 explains the applications, pros, and cons of creating Object Outlines and Skeletons in such a study. \begin{table}
\begin{tabular}{c c c} \hline \hline
**Criteria** & **Object Outlines** & **Skeletons** \\ \hline Representation & The complete boundary of the object & Simplified, centerline representation of the object \\ \hline Pros & A clear understanding of shape and orientation & Simplified analysis of complex shapes \\  & Easy calculation of features such as area and perimeter & Less sensitive to boundary noise \\  & Sensitive to noise and small & Useful for analyzing the movement of object parts \\ \hline Cons & \begin{tabular}{c} Sensitive to noise and small \\ boundary variations \\ \end{tabular} & \
\begin{tabular}{c} Loss information about object’s \\ width and shape \\ \end{tabular} \\ \hline Application to & Better for understanding overall & Better for analyzing the movement of \\ Motion Detection &
\begin{tabular}{c} object movement and \\ shape changes \\ \end{tabular} & specific object parts \\ \hline \hline \end{tabular}
\end{table} 
Table 3: Object Outlines vs. Skeletons for Motion Detection. As can be seen from Table 3. Both object representation types are used for motion detection and contribute to the results in various ways. A high-view logic of the code created under the guidance of ChatGPT can be seen below (Algorithm 1):  
```
Input: A GIF file containing multiple frames Output: GIF files with outlined objects, skeletons of objects, prominent objects circled, and motion detection
1. Function process_gif(input_gif):
2. frames = load_gif(input_gif)
3. max_width, max_height = get_max_dimensions(frames)
4. outlined_frames = []
5. skeletons_frames = []
6. prominent_objects_frames = []
7. motion_detection_frames = []
8. previous_skeleton = None
9. for frame in frames:
10. resized_frame = resize_frame(frame, max_width, max_height)
11. outlined_frame = create_outline(resized_frame)//Outline Creation
12. outlined_frames.append(outlined_frame)
13. skeleton = create_skeleton(outlined_frame)//Skeleton Creation
14. skeletons_frames.append(skeleton)
15. prominent_object_frame = highlight_prominent_object(outlined_frame)//Prominent
16. prominent_objects_frames.append(prominent_object_frame)//Object Highlighting
17. if previous_skeleton is not None://Motion Detection
18. motion_frame = detect_motion(previous_skeleton, skeleton)
19. motion_detection_frames.append(motion_frame)
20. previous_skeleton = skeleton
21. outlined_objects_gif = save_gifoutlined_frames)
22. skeletons_gif = save_gif(skelotons_frames)
23. prominent_objects_gif = save_gif(prominent_objects_frames)
24. motion_detection_gif = save_gif(motion_detection_frames)
25. return outlined_objects_gif, skeletons_gif, prominent_objects_gif, motion_detection_gif
```  
**Algorithm 1**High-view pseudocode of the case study  
In this pseudocode:  
_load_gif()_ is responsible for loading the GIF and converting its frames to a format suitable for processing, _get_max_dimensions()_ calculates the maximum width and height across all frames to ensure consistent sizing, _resize_frame()_ resizes a frame to the maximum dimensions, _create_outline()_ generates an outline of objects in a frame, _create_skeleton()_ computes the skeleton of objects in a frame.