Python Image Cropper for Time Lapses

While making my Pasta Machine, I took quite a few screen grabs of the CAD. I wanted to make a time lapse of all the images, but cropped such that they did not include the solidworks headers and my other monitors. I tried doing the cropping in Windows Movie Maker with no luck. I was able to crop all the photos in Adobe Premier Elements, but at a huge cost of resolution (the photos got scaled down to 240p or something stupid). So I built a pyhton script to crop all the images automatically.

# Time Lapse Image Cropper
# used first for Pasta Machine

from PIL import Image

center = 1400
halfX = 600

top = 130
bot = 970

img_list = ["1.png", "2.png", "3.png", "4.png", "5.png", "6.png", "7.png", "8.png", "9.png", "10.png",
"11.png", "12.png", "13.png", "14.png", "15.png", "16.png", "17.png", "18.png", "19.png", "20.png",
"20.png", "21.png", "22.png", "23.png", "24.png", "25.png", "26.png", "27.png", "28.png", "29.png",
"30.png", "31.png", "32.png", "33.png", "34.png", "35.png", "36.png", "37.png", "38.png", "39.png",
"40.png", "41.png", "42.png", "43.png", "44.png", "45.png", "46.png", "47.png", "48.png", "49.png",
"50.png", "51.png", "52.png", "53.png", "54.png", "55.png", "56.png", "57.png", "58.png", "59.png",
"60.png", "61.png", "62.png", "63.png", "64.png"]

for i in range(len(img_list)):
	img = Image.open(img_list[i])
	area = (center-halfX, top, center+halfX, bot)
	cropped_img = img.crop(area)
	#cropped_img.show()  #if you want all the images to show up
	new_title = "a" + img_list[i]
	print (new_title)
	cropped_img.save(new_title)

Results:
Before:

59

After:

a59

Cook-Me-Pasta: A New Machine

Recently I constructed a rather interesting machine. The machine was the result of several factors: Last spring a project vacuum was created after I finished the Granite Mini-Mill. The granite mini-mill was very legitimate, and therefore it was time to create something illegitimate. Preferably, something really, really illegitimate. Time is finite. This is a stunning realization: […]

Motor Control: The Velocity Estimator Saga

Last time, I’d managed to make current control work on my new board, and now it was time for servo position control. After a bit of hacking around and trying random PID gains, I wrote some code to generate a position profile for the motor to track. Using this framework I could easily run sinusoid or step response tests and […]

Motor Controller: Board 5!!!

When we left off last time, I’d dealt with a bunch of issues with misused current sensors. Here is a photo of the lovely Motor Science Rig in all its glory, taken with Bayley’s ViewCamera. With the current sensors installed properly, it was time to move from voltage-mode FOC to current-mode FOC. I had some minor issues doing […]

FOC PART 4: More Hardware Debugging!!!

The Motor Science Rig. When I left off last time, I had bestowed the ADCs with capacitor-based magic which caused them to function properly. The next step was to hook up the current sensors and forcefully request that they, too, function properly. Wary of hardware problems, I collected some data before jumping straight to current-mode FOC. Through […]

FOC Motor Controller part 3: The Delinquent Current Sensors Persist

Welcome back to the motor control suite. After blowing up the last board, I decided to design a new one.  Changes included new current sense amplifiers and a different power regulator setup. The current sense amps were the LMP8481, which required an additional 3.3v trace to be routed to the sense amplifier area. This proved […]