You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This student completed the EC601 mini-project with one file, Twitter.py. It contained three functions, get_all_tweets(screen_name), labelPic(numa), and tweetsvideo(). get_all_tweets() downloads images from twitter feed, numbers the downloaded files. labelPic(numa) accesses the google vision API to acquire labels for all the downloaded pictures. Lastly tweetsvideo() compiles all the pictures stored in JPEG format into video using a ffmpeg subprocess. Generally the naming conventions and code structure are adequate. Also, there are a large number of comments which helps first time users understand whats happening.
Review
Overall the code works well enough, it succeeds in creating an MP4 file from images downloaded from twitter at least for the first time it is run and with the existing handle. However there are some issues
No sources?
The condensed structure of the code is nice however it makes it hard to diagnose any errors since the entire functionality of the software is written in one file
The code provides extremely minimal, if any, error checking. If an incorrect twitter handle is passed the program exits with a nonspecific tweepy library error. If the API credentials are incorrect it also exits with a nonspecific message. If the picture formats from twitter are wonkey the ffmpeg function will simply exit with "conversion failed"
The video does not actually label all the pictures with their google vision API description, instead it simply prints the labels to the terminal and then prints all the labels for the entire video on the last image. This seems to be an issue with understanding of python for loops in the code shown below.
img = Image.open(file_name_jpg)
#save the text on selected pics
img.save(str(i)+".jpg")
where "i" here has already been looped through and is at it's maximum value, therefore only
referencing and labeling only the last image in the video.
The code does not scrub the working directory of the raw JPEG files after the video is created. This makes it impossible to then change the twitter handle and create a new video, since it sees that the pictures have already been found
If I change the twitter handle to @extremesailing I get the following error "[libx264 @alexlin0625 0x7fdb6700b000] height not divisible by 2 (1200x675)
Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height" and the video is not created.
If there are no Pictures within the first 20 tweets the code will not be able to work
The Frame-rate for the video is extremely slow
Possible Future Changes
Be sure to add sources used
Break up the functionality into modules, 1. get twitter pics 2. label pictures 3. create video
More error checking all over the place. I.E twitter handle errors, twitter API errors, Google API errors, JPG fomat errors, conflicts with existing files in the directory
Allow the user to enter twitter handle and number of tweets to query
Ensure every picture is labeled correctly before using ffmpeg to create a mp4
Maybe have a function to resize the images, which should solve the ffmpeg error encountered when trying to change twitter handles.
Create a new directory to store all the raw JPEG files so that the CWD is not polluted, and then make sure to include a function which will scrub the working directory of all the image files once they are labeled and converted to an MP4.
Speed up the frame-rate, if the user wanted to query more pictures the video would be too long
The text was updated successfully, but these errors were encountered:
OverView
This student completed the EC601 mini-project with one file, Twitter.py. It contained three functions, get_all_tweets(screen_name), labelPic(numa), and tweetsvideo(). get_all_tweets() downloads images from twitter feed, numbers the downloaded files. labelPic(numa) accesses the google vision API to acquire labels for all the downloaded pictures. Lastly tweetsvideo() compiles all the pictures stored in JPEG format into video using a ffmpeg subprocess. Generally the naming conventions and code structure are adequate. Also, there are a large number of comments which helps first time users understand whats happening.
Review
Overall the code works well enough, it succeeds in creating an MP4 file from images downloaded from twitter at least for the first time it is run and with the existing handle. However there are some issues
No sources?
The condensed structure of the code is nice however it makes it hard to diagnose any errors since the entire functionality of the software is written in one file
The code provides extremely minimal, if any, error checking. If an incorrect twitter handle is passed the program exits with a nonspecific tweepy library error. If the API credentials are incorrect it also exits with a nonspecific message. If the picture formats from twitter are wonkey the ffmpeg function will simply exit with "conversion failed"
The video does not actually label all the pictures with their google vision API description, instead it simply prints the labels to the terminal and then prints all the labels for the entire video on the last image. This seems to be an issue with understanding of python for loops in the code shown below.
img = Image.open(file_name_jpg)
draw = ImageDraw.Draw(img)
#(Position, content, color)
draw.text((0, 0), str(labels), (255, 255, 255))
#save the text on selected pics
img.save(str(i)+".jpg")
where "i" here has already been looped through and is at it's maximum value, therefore only
referencing and labeling only the last image in the video.
The code does not scrub the working directory of the raw JPEG files after the video is created. This makes it impossible to then change the twitter handle and create a new video, since it sees that the pictures have already been found
If I change the twitter handle to @extremesailing I get the following error "[libx264 @alexlin0625 0x7fdb6700b000] height not divisible by 2 (1200x675)
Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height" and the video is not created.
If there are no Pictures within the first 20 tweets the code will not be able to work
The Frame-rate for the video is extremely slow
Possible Future Changes
Be sure to add sources used
Break up the functionality into modules, 1. get twitter pics 2. label pictures 3. create video
More error checking all over the place. I.E twitter handle errors, twitter API errors, Google API errors, JPG fomat errors, conflicts with existing files in the directory
Allow the user to enter twitter handle and number of tweets to query
Ensure every picture is labeled correctly before using ffmpeg to create a mp4
Maybe have a function to resize the images, which should solve the ffmpeg error encountered when trying to change twitter handles.
Create a new directory to store all the raw JPEG files so that the CWD is not polluted, and then make sure to include a function which will scrub the working directory of all the image files once they are labeled and converted to an MP4.
Speed up the frame-rate, if the user wanted to query more pictures the video would be too long
The text was updated successfully, but these errors were encountered: