m8ta
use https for features.
text: sort by
tags: modified
type: chronology
{1471}
hide / / print
ref: -0 tags: python timelapse script date: 07-30-2019 20:45 gmt revision:3 [2] [1] [0] [head]

Edited Terrence Eden's script to average multiple frames when producing a time-lapse video from a continuous video. Frames are averaged together before decimation, rather than pure decimation, as with ffmpeg. Produces appealing results on subjects like water. Also, outputs a video directly, without having to write individual images.

python
#!/usr/bin/python
import cv2
import sys

#   Video to read
print str(sys.argv[1])
vidcap = cv2.VideoCapture(sys.argv[1])

#   Which frame to start from, how many frames to go through
start_frame = 0
frames = 61000

#   Counters
count = 0
save_seq = 0
decimate = 10
rolling = 16 # average over N output frames
transpose = False

if(transpose):
	h = vidcap.get(3)
	w = vidcap.get(4)
else:
	w = vidcap.get(3)
	h = vidcap.get(4)

fourcc = cv2.VideoWriter_fourcc(*'mp4v')
writer = cv2.VideoWriter("timelapse.mp4", fourcc, 30, (int(w), int(h)), True)

avglist = []

while True:
	#   Read a frame
	success,image = vidcap.read()
	if not success:
		break
	if count > start_frame+frames:
		break
	if count >= start_frame:
		if (count % decimate == 0):
			#   Extract the frame and convert to float
			avg = image.astype('uint16') # max 255 frames averaged. 
		if (count % decimate > 0 and count % decimate <= (decimate-1)):
			avg = avg + image.astype('uint16')
		if (count % decimate == (decimate-1)):
			#   Every 100 frames (3 seconds @ 30fps)
			avg = avg / decimate
			if(transpose):
				avg = cv2.transpose(avg)
				avg = cv2.flip(avg, 1)
			avg2 = avg; 
			for a in avglist:
				avg2 = avg2 + a
			avg2 = avg2 / rolling; 
			avglist.append(avg); 
			if len(avglist) >= rolling:
				avglist.pop(0) # remove the first item. 
			
			avg2 = avg2.astype('uint8')
			print("saving "+str(save_seq))
			#   Save Image
			# cv2.imwrite(filename+str('{0:03d}'.format(save_seq))+".png", avg)
			save_seq += 1
			writer.write(avg2)
			if count == frames + start_frame:
				break
	count += 1
writer.release()

{536}
hide / / print
ref: bookmark-0 tags: Ocaml python paradox programming finance date: 03-10-2008 21:29 gmt revision:2 [1] [0] [head]

  • this trading firm used OCaml, apparently to exclusion: http://www.janestcapital.com/yaron_minsky-cufp_2006.pdf
  • they also reference the python paradox. interesting, I'll have to check into Ocaml.
  • or, rather, Lisp. this article is quite convincing!
    • quote: If you're trying to solve a hard problem with a language that's too low-level, you reach a point where there is just too much to keep in your head at once.
    • quote: Any sufficiently complicated C or Fortran program contains an ad hoc informally-specified bug-ridden slow implementation of half of Common Lisp.
      • well, yes, this happened a bit in BMI with variables that were indexed by name :(
  • also see this excellent, extensive article.

{226}
hide / / print
ref: work notes-0 tags: web stimulator SUNY ICMS python webinterface project date: 03-26-2007 04:26 gmt revision:1 [0] [head]

we are proud of this :)

{16}
hide / / print
ref: bookmark-0 tags: pythong c howto date: 0-0-2006 0:0 revision:0 [head]

http://www.linuxjournal.com/article/8497

here you go timmyh, enjoy..

/joeyo