Change Contents of the Bubble
Welcome to CS1315. Click on the python to add comments.

Looking for the book? They have it at the Engineer's Bookstore at 748 Marietta St NW. Here is there website: http://www.engrbookstore.com/ - Monica

Hotspots: Slides and CodeTA CornerComments?AnnouncementsFAQStatic Webspace
View this PageEdit this Page (locked)Uploads to this PageHistory of this PageHomeRecent ChangesSearchHelp Guide

Spring 2004 Homework 5 Questions

Questions? Comments? Issues?


For the part of changing the velocity, can we just have it acclurate at a constant rate in one direction? accluration is changing velocity.

I can't get movie maker to work. I have loaded my program in JES. I went to the movie maker and selected the starting and ending frames for my movie. Then an input box popped up, asking for the rate I wanted to view my movie. I tried everything from 30fps to just 30. Whenever I would click "ok" it would just go back to the input screen again without doing anything. I am using the red square program from lecture. Someone please help- I need movie maker to work in order to do this lab.
How many frames do you have? If you have 30 frames, you would probably want 10fps. If you have 75 frames, you would want 25 fps. Ask your professor in lecture or breakout how to use the moviemaker (get them to show you). Or you can come to a TA's office hours and get them to show you. Ashley Coker

I can't find movie maker anywhere.


Go to Course Software (JES) and grab JES. It's in the JES distribution. If you have JES installed, it's there already – find MovieMaker.exe. It's also on the book CD (if'n you got that...) Mark Guzdial

I did that, and I don't see it. All that's there is moviemaker.class. help!
Bring your CD to breakout, and ask your breakout TA/professor to show you where it is. Or you can come to someone's office hours and get them to help you install it. Ashley Coker

Got this error:

I wasn't able to do what you wanted.
The error java.lang.NoClassDefFoundError has occured

I am guessing this is because I do not have the software to PLAY the movie. which is QuickTime I guess? So what do I do, how do I get this?
Amelia Cipolla

When do you get this error, Amelia? In MovieMaker? JES? Yes, to use MovieMaker, you do need to have QuickTime installed, including QuickTime for Java. Go to http://www.apple.com/quicktime/ and install. You will get an "Options" button at some point (Adam, when was that?). Be sure to click "QuickTime for Java" to install it. Mark Guzdial


def hw5(directory):
  flo=getMediaPath(r"flower.jpg")
  pic=makePicture(flo)
  flo2=getMediaPath(r"flower2.jpg")
  pic2=makePicture(flo2)


When I try to run homework five in the command area it tells me that there is no file at flower.jpg, but I know there is. I thought I might be trying to run my program on the wrong directory, but I'm not. I have the right directory name in the command area. Is there anything else that could be causing this error?
Heather Symon

Ok, my program loads, but I don't understand how to use movie maker. Someone walk me through it, pretty please!!! and yes, I've been to lecture.

Heather, you don't need the "R" if you're using getMediaPath, but it shouldn't hurt anything. Did you setMediaPath first? We are demonstrating movie maker in breakout this week. Mark Guzdial


Does it matter if our pictures/objects overlap at any point in the movie?

Nope – perfectly reasonable. Mark Guzdial


Clarification, please: One of the three objects has to either switch directions OR increase speed, not both, right? Also, my program runs fine and saves all of the frames to a folder I have chosen, but then when I try to make and play my movie nothing happens. I see a bunch of text on the black movie maker window, but my movie does not get saved to the folder with my frames. What happened?
Brittany Copeland

Brittany, did you check the individual frames? Do they have more than just text on them? The movie will be saved to your JES folder. Right – you have to change directions or speed. You can do both, but either change is a change to velocity. Mark Guzdial


When I type in the name of my movie when trying to run one of the examples from lecture in MovieMaker, it says it's unable to load the images. Any tips? And for 99 frames, I use 30 fps.
Marggee Godbee

Make sure you are entering just 30 and not 30 fps. Putting in 30 fps will not work. Keith McDermott

I'm not sure what you mean by the individual frames. I have two pictures and a line of text that are each in a new position in each new frame. I have 30 total frames. Is that correct?
Brittany Copeland
Each of those 30 total frames are just JPEG images. Have you looked at them? Do you see both of your pictures and your text? Mark Guzdial

So yeah, I'm trying to run Moviemaker.exe, but when the DOS prompt comes up, it disappears a spit second later and nothing happens. I've got QT for JAVA, and I even dragged the moviemaker.exe file off of the cd into my JES folder and replaced the one I have. It's still not fixed, and when I try to run it directly off of the cd, it tells me "unable to open images" after I set the fps and name the movie. And I've opened all of the pictures I;m trying to use and, sure enough, they are all valid JPEGS. Any idea what is going on?

Okay, I figured out what I did wrong: The folder where I saved the frames needed to be in the JES folder for movie maker to work for me. Thanks for your help, Mark. Check out my movie in the gallery!
Brittany Copeland

Do we create the 30 or 75 frames beore hand and then just execute the program or must the program greate the 30 tp 75 frames first then make the movie. Also when I went to download quicktime it did not give me the option to download for Java will this be a problem if so how and where can I get it for Jave before Friday.
Paula Verden
Your program creates 30-75 frames, then you make the movie. During the installation process for Quicktime (during the wizard, when you're clicking "Next...next"), you'll see a button for "Options." Choose QT for Java then. Mark Guzdial

When I make the movie, I can specify starting frame, ending frame, the frame rate, and the name of the .mov file, but after that step, I get an error message saying: Unable to open image.
The movie is "Simple Motion" - the moving rectangle as mentioned in the notes, and the frames are being created as JPEG images.
Please help.Anu Koppikar

That's the same prob I mentioned 3 posts up from yours, Anu. Except I get that only when I run it off the cd - it doesn't even run out of my JES folder! I don't know how I can do this assignment if this isn't figured out... I even redownloaded JES and replaced my entire folder. Oh well. Any ideas, Mark?
You can't run MovieMaker off the CD – it won't work. You also have to have the frames on the hard disk, too – they can't be on the CD either. Mark Guzdial

i went to open movie maker (from my JES folder) and the program begins to open (shows the worm picture) but then disappears...a bug? or something else?
MovieMaker doesn't show the worm picture. If it's not coming up, you may not have enough memory. If you have lots of applications open (web browser, AIM, email, etc.), you may not have enough memory. Mark Guzdial

Again, my problem exactly. :)

I hope this stuff gets figured out soon; this being Easter weekend, and already having a quiz Monday, things're beginning to look a little overwhelming.
Try running MovieMaker off the library computer or a friend's computer. NOTICE: YOU DO NOT HAVE TO TURN IN THE MOVIE! You can do HW5 WITHOUT ever running MovieMaker. The assignment has you turn in the python program and the composited images. Mark Guzdial

What could possibly explain the fact that my JPEG image looks as though it has a grid over it? Everything else seems to work fine but no matter what picture I use, this happens.
Were you skipping two in both the source and target pointers? That can cause that – that creates a blank pixel between every two colored pixels. Mark Guzdial


Thanks so much! I've got it fixed now!


For people having MovieMaker problems, download MovieMaker from http://coweb.cc.gatech.edu/cs1315/847. Once you have downloaded it, follow the instructions on the webpage. Keith McDermott

My movie takes FOREVER to compose... It takes like 13 min to run the whole thing... may be its because im doing 75 frames... will the TA's run it through too? I also attached the movie file itself, although I probably didn't need to. Sun Moon Kim
Yes, TA's will run the program. Mark Guzdial

After I set the fps and the movie is created, how do i play it?
If you've installed QuickTime, simply double-click on it. Mark Guzdial


I have three objects, but how do I speed them up. Can someone give me a rough overview, please!!!
Change the multipler that you use with the frame number to determine position. (We discussed this in breakout this week...) Mark Guzdial

How much time should we allot to do this homework being that it will take a little while to render?
Thomas Sobeck
It all depends on what you put into your movie. Don't forget to use subfunctions and test those, and use printNow so that you know when the first frames are done so that you can check them. Mark Guzdial

Help!! We didn't discuss MovieMaker at all in my breakout. I still don't understand how to change speeds and I've read the text...
Look at the first program in the Movies chapter (p. 266), moving the rectangle down and up. Notice how the x position is frame * 10 and the y position is frame * 5. This means that the rectangle moves 10 pixels per frame in the horizontal direction and 5 pixels per frame in the vertical direction. Now, let's imagine that for frames 1 to 25, you actually incremented by 5 and 5, and then went to 10 and 5 for frames 25-50. The rectangle would be perceived as moving slower then faster. Does that make sense? Mark Guzdial



When I put this code from the powerpoint into my code, it only writes the last frame.
def writeFrame(num,directory,framepict):
    # Have to deal with single digit vs. double digit frame numbers differently
    framenum=str(num)
    if num < 10:
      writePictureTo(framepict,directory+"//frame0"+framenum+".jpg")
    if num >= 10:
      writePictureTo(framepict,directory+"//frame"+framenum+".jpg")


Why doesnt it write the rest of them?
You call this function for each picture you want created, Kevin. Mark Guzdial

def makeMovie(directory):
  swanLake=getMediaPath("swanLake.jpg")
  swan= makePicture(swanLake)
  for frame in range(1, 76): 
    printNow("Frame number: "+str(frame))
    canvas = makePicture(getMediaPath("640x480.jpg"))
    sourceX = 1
    #105=width
    for targetX in range(1, 105): 
      sourceY = 1
      #52=height
      for targetY in range(1, 52):
        color = getColor(getPixel(swan, int(sourceX), int(sourceY)))
        setColor(getPixel(canvas, targetX, targetY), color)
        sourceY = sourceY + 1
      sourceX = sourceX + 1
    addRectFilled(canvas, 100+ int(10 * sin(frame)), 4*frame+int(10* cos(frame)), 50, 50, pink)
    writeFrame(frame, directory, canvas)


def writeFrame(num, directory, framepict):
    framenum=str(num)
    if num < 10:
      writePictureTo(framepict, directory+"//frame0"+framenum+".jpg")
    if num >= 10:
      writePictureTo(framepict, directory+"//frame"+framenum+".jpg")

How do I make my swan picture move??? Karin Bowman
Change where you draw it in each frame. Instead of making the targetX go from 1 to 105 in every frame, make targetX go from frame to frame+105. Now, the swan will move slowly across the screen. Mark Guzdial

Here's the program we wrote in my breakout to move the rectangle at different speeds. Mark Guzdial
def movingRectangle(directory):
  for frame in range(1,100): #99 frames
    canvas = makePicture(getMediaPath("640x480.jpg"))
    printNow("Frame:"+str(frame))
    if frame <= 25:
      addRectFilled(canvas,frame*3,frame*3, 50,50,red)
    if 25 < frame < 50: #Less than 50, move down
      # Generate new positions each frame number
      addRectFilled(canvas,frame*10,frame*10, 50,50,red)
    if frame >= 50: #Greater than 50, move up
      addRectFilled(canvas,(50-(frame-50))*10,(50-(frame-50))*5, 50,50,red)
    # Now, write out the frame
    # Have to deal with single digit vs. double digit frame numbers differently
    framenum=str(frame)
    if frame < 10:
      writePictureTo(canvas,directory+"//frame0"+framenum+".jpg")
    if frame >= 10:
      writePictureTo(canvas,directory+"//frame"+framenum+".jpg")



Advice–use small pictures. If your program is taking a really long time, that's your computer saying "AHHHH!!!!! THE PICTURE IS TOO BIG!!!!!" Be nice to the computer and indulge its every desire by using a smaller picture.

So this is my code...

def makeMovie(directory):
  swanLake=getMediaPath("swanLake.jpg")
  swan= makePicture(swanLake)
  string="Wow!!  Yahoo!!"
  for frame in range(1, 76): 
    printNow("Frame number: "+str(frame))
    canvas = makePicture(getMediaPath("640x480.jpg"))
    sourceX = 1
    for targetX in range(frame, frame+104): 
      sourceY = 1
      for targetY in range(frame, frame+50):
        color = getColor(getPixel(swan, int(sourceX), int(sourceY)))
        setColor(getPixel(canvas, targetX, targetY), color)
        sourceY = sourceY + 1
      sourceX = sourceX + 1
    writeFrame(frame, directory, canvas)
    tickertape(directory, string)


def writeFrame(frame, directory, canvas):
  if frame <= 25:
    addRectFilled(canvas, frame*3, frame*3, 50, 50, pink)
  if 25 < frame < 50: #Less than 50, move down
    # Generate new positions each frame number
    addRectFilled(canvas,frame*10,frame*10, 50, 50, pink)
  if frame >= 50: #Greater than 50, move up
    addRectFilled(canvas, (50-(frame-50))*10, (50-(frame-50))*5, 50, 50, pink)
  framenum=str(frame)
  if frame < 10:
    writePictureTo(canvas, directory+"//frame0"+framenum+".jpg")
  if frame >= 10:
    writePictureTo(canvas, directory+"//frame"+framenum+".jpg")

def tickertape(directory, string):
  canvas = makePicture(getMediaPath("640x480.jpg"))
  string="Wow!!  Yahoo!!"
  addText(canvas, 600-(frame*10), 76, string)
  framenum=str(frame)
  if frame < 10:
    writePictureTo(canvas, directory+"//frame0"+framenum+".jpg")
  if frame >= 10:
     writePictureTo(canvas, directory+"//frame"+framenum+".jpg")

Why oh why is Jes saying...
Frame number: 1
A local or global name could not be found. You need to define the function or variable before you try to use it in any way.
 in file C:\JES\hw5.py, on line 17, in function makeMovie
 in file C:\JES\hw5.py, on line 35, in function tickertape
NameError: frame
Please check line 35 of C:\JES\hw5.py

I thought that if I put
for frame in range(1, 76):
at the beginning, it will keep making 75 frames over and over and over...because I tried that when I added in the code similar to the one above and it kept making sequences of 75 frames...any direction on this tickertape stuff? Thanks! Karin Bowman
The function tickertape doesn't have a variable named frame – that's what it's saying. You need to write a different tickertape position for each frame. Put it in your main frame loop and set the position of the text based on the frame. Mark Guzdial


  pic=makePicture(flo)
  flo2=getMediaPath(r"flower2.jpg")
  pic2=makePicture(flo2)
  for frame in range (1,31):
    printNow("Frame number: "+str(frame))
    canvas = makePicture(getMediaPath("store.jpg"))
    sourceX=1
    for targetX in range ( frame, frame+10):
      sourceY= 1
      for targetY in range (frame, frame+10):
        color = getColor(getPixel(pic, int(sourceX), int(sourceY)))
        setColor(getPixel(canvas,targetX,targetY),color)
        sourceY=sourceY+2
      soureceX=sourceX+2
    writeFrame(frame,directory,canvas)

Why do i only get a tiny white square that moves just a little in the top corner of my screen. If I change the numbers I get a bigger square but it's never the whole picture.
Heather Symon
Because you're only moving it one pixel per frame. That's pretty slow. Multiple the frame number by something in your range and you'll get greater speed. Mark Guzdial

Do we have to turn in the movie file? I don't think it says we do, but if so, how do I compile all of the frames together to make a movie file?

Thanks
Removed
Brad, that question has already been asked several times on this page. No, you don't have to turn in the movie file. You use the program MovieMaker to make a movie from your frames. Mark Guzdial


alright... I have my program creating new frames where my pictures move, BUT they leave a trail behind them (of where they were previously) all of them... what in my code could be causing this to happen??? Thanks!
oh yeah...i think the prob is somewhere in here:
 for frame in range(1,76): #75 frames
    printNow("Frame number: "+str(frame))
    sourceX = 1
    for targetX in range(frame*5,frame*5+112):
      sourceY = 1
      for targetY in range(frame*5,frame*5+111):
        color = getColor(getPixel(oar, int(sourceX), int(sourceY)))
        setColor(getPixel(canvas, targetX, targetY), color)
        sourceY = sourceY + 1
      sourceX = sourceX + 1

Where do you create your canvas? If it's BEFORE your frame loop, then you're always using the same canvas. You're only adding things to the canvas, not making a new blank canvas for each frame. Mark Guzdial

THANK YOU!



Last question...I promise!! Is it bad to keep printNow("Frame number: "+str(frame)) in the code? Thanks...Karin Bowman
Nope – that's fine. Mark Guzdial

Ok, I multiplied the frame number by something in my range, but I still only get a white square that moves across the canvas. It doesn't copy in my entire picture. What am I doing wrong?
flo=getMediaPath(r"flower.jpg")
  pic=makePicture(flo)
  flo2=getMediaPath(r"flower2.jpg")
  pic2=makePicture(flo2)
  for frame in range (1,31):
    printNow("Frame number: "+str(frame))
    canvas = makePicture(getMediaPath("store.jpg"))
    sourceX=1
    for targetX in range ( frame*3, frame*3+((100-10)/2)):
      sourceY= 1
      for targetY in range (frame*3, frame*3+((100-10)/2)):
        color = getColor(getPixel(pic, int(sourceX), int(sourceY)))
        setColor(getPixel(canvas,targetX,targetY),color)
        sourceY=sourceY+2
      soureceX=sourceX+2
    writeFrame(frame,directory,canvas)

Heather Symon
Heather, you're only copying from pic (flower.jpg) into your canvas (movie frame). Did you want to do more than that? Mark Guzdial

I was going to copy both flower pictures in eventually, but I wanted to get the first one to work first. Right now I can't get the entire picture to show up in my movie frame. I guess somehow I am not copying in the entire thing, but I am not sure what I'm doing wrong.
Heather Symon
Heather, you're currently only copying part of the picture, only from (1,1) to (45,45). That's because the range on your target goes from 0 to 45 (i.e., (100-10)/2). If you want to get the whole thing, make your targetX go from frame*3 to frame*3+getWidth(pic). (And the same thing with targetY, but use getHeight(pic)) That way, you'll copy in the whole picture. Mark Guzdial

Okay.. maybe I am just being really slow, but how do we get a movie? I can get a series of frames saved into a folder, but it doesn't create a movie that I can click on and watch... And I was just trying the examples! Can anyone help me understand this? I appreciate it so much!! Jennifer Garrett

I have the same question as above....any help??

i have movie maker on my computer and it will let me load in the first file and last file, and i will click create movie but then nothing happens, it dosent let me adjust the fps rate or anything and i dont see how to play the movie, whats wrong?
stephen rudolph

Jennifer, that's what the program MovieMaker is for. It should be in your JES directory, or follow the link that Keith posted earlier to get it. It asks you for a starting frame, an ending frame, a rate (in frames per second), and a name for your movie, then saves your movie in your JES/MovieMaker directory. Stephen, I don't know what the problem might be. Do you have a console (black with white text) window that opened with MovieMaker? Are there any errors in it? Mark Guzdial



do we have to use movie maker in hw5? i am a little confused on this.

How does one USE Movie Maker? I opened MovieMaker.exe, and a box popped up asking for starting and ending frame. I entered that info, and in the other window (that is black) a bunch of stuff popped into it. It didn't prompt me for the rate (where does that go??????), I've read the book and there are no instructions. Now I am to go into the JES command area and enter openMovie(pickAFile()) - what file? In my file it's all frames and wants me to pick ONE. The book lacks explicit instructions: this is not clear at all. Please elaborate.
Below, I'm repeating Keith's note from earlier, since it seems to have been missed. openMovie only works with movie files, not with individual JPEG frames. Mark Guzdial
For people having MovieMaker problems, download MovieMaker from http://coweb.cc.gatech.edu/cs1315/847. Once you have downloaded it, follow the instructions on the webpage. Keith McDermott

I get a StringIndexOutOfBoundsException error in the MovieMaker.exe program when I try to run the following program from the book:

def movingRectangle2(directory):
  for frame in range(1,100):
    canvas=makePicture(getMediaPath("640X480.jpg"))
    if frame<50:
      addRectFilled(canvas,frame*10,frame*5,50,50, red)
    if frame>=50:
      addRectFilled(canvas, (50-(frame-50))*10,(50-(frame-50))*5,50,50, red)
    addRectFilled(canvas,100+ int(10*sin(frame)),4*frame+int(10*cos(frame)),50,50, blue)
    framenum=str(frame)
    if frame<10:
      writePictureTo(canvas, directory+"//frame0"+framenum+".jpg")
    if frame>=10:
      writePictureTo(canvas, directory+"//frame"+framenum+".jpg")

How can this be? Would this explain why it doesn't save the movie or prompt for a rate? Andrea Dunlop
Any particular line it occurred on? You won't save a movie or get prompted for a rate until you run MovieMaker. Mark Guzdial

See the description on the MovieMaker page (bottom) to see if that helps make sense. Mark Guzdial


There is no error in the program in JES. It runs. Then I run MovieMaker.exe, choose the start and end, and then in the black box with the white letters - at the beginning (first line) it gives the following: StringIndexOutOfBoundsException. And once I click create movie nothing else happens, other than the black box. No "rate" prompt. No "save movie" as prompt. The StringIndexOutOfBoundsException as described in my last post makes no sense - I copied the program exactly from the book and it does run in JES. Any ideas? Andrea Dunlop

I'm having the same problem that Heather was having above (with copying images to the frame). I tried to set the target X and targetY values by adding the width and height of the picture as was suggested above by Mark. However, nothing is showing up in my frames. Any suggestions on why?


sourceX=1
    for targetX in range (frame*3, frame*3+getWidth(pic)):
      sourceY= 1
      for targetY in range (frame*3, frame*3+getHeight(pic)):
        color = getColor(getPixel(pic, int(sourceX), int(sourceY)))
        setColor(getPixel(canvas,targetX,targetY),color)
        sourceY=sourceY+2
      soureceX=sourceX+2

I don't see the problem here. Are you sure that you're writing out the frame after this code executes? Mark Guzdial

Alright, I am having some major trouble with this one. I have been just trying to run some of the code out of the book (moveahead, movingrectangle2, etc.), but cannot get it to run. The problem is with the saving of the frames that the program is generating. JES runs though frames 1-10, but reads an error for anything above that. I don't have any typing mistakes in the code and it is exactly the code from the book. JES is also not actually saving the frames in my folder, so I can't run MovieMaker. PLEASE HELP Justin DeMeester

Justin, if you could tell us what the error is and on what line, that would help alot. Is your disk too full? Mark Guzdial

def moveahead(directory):
  barbf=getMediaPath("barbara.jpg")
  barb = makePicture(barbf)
  for frame in range(1,100):
    printNow("Frame number: "+str(frame))
    canvas = makePicture(getMediaPath("640x480.jpg"))
    sourceX = 45
    for targetX in range(frame*3,frame*3+((200-25)/2)):
      sourceY = 25
      for targetY in range(frame*3,frame*3+((200-25)/2)):
        color = getColor(getPixel(barb,int(sourceX), int(sourceY)))
        setColor(getPixel(canvas,targetX,targetY), color)
        sourceY = sourceY + 2
      sourceX = sourceX +2
    writeFrame(frame,directory,canvas)

def writeFrame(num,directory,framepict):
  framenum=str(num)
  if str(num) < 10:
    writePictureTo(framepict,directory+"\\frame0"+framenum+".jpg")
  if str(num) >=10:
    writePictureTo(framepict,directory+"\\frame"+framenum+".jpg")


I go to the command area and type in moveahead(getMediaPath) and get this error:

Frame number: 1
An attempt was made to call a function with a parameter of an invalid type. This means that you did something such as trying to pass a string to a method that is expecting an integer.
in file C:\Documents and Settings\Justin\My Documents\moving barb, on line 15, in function moveahead
in file C:\Documents and Settings\Justin\My Documents\moving barb, on line 22, in function writeFrame
TypeError: __add__ nor __radd__ defined for these operands
Please check line 22 of C:\Documents and Settings\Justin\My Documents\moving barb

i have been trying to save the frames to the mediasources folder, not a disk

thanks Justin DeMeester

Why are you going moveahead(getMediaPath)??? Your program takes in a directory and your use of getMediaPath is incorrect. You should try doing something like this moveahead(r"C:\Documents and Settings\Justin\My Documents\My Picture"), where the thing in quotes is the path to the directory where you want your frames to be saved. Keith McDermott


What page in the book can we find how to change the velocity of one of our animations?

Can the hw please be postponed for Tuesday???....coweb was down the whole day today until now (4 p.m.)...I tried to work on it with the ta's but they couldn't be of much help without the hw directions and the lecture slides....it would be great if it was moved to Tuesday so that we can concentrate on the quiz that is on Monday...PLEASE postpone it...


I agree! Having a homework due, a pre-quiz due, and a quiz in one day is a bit much for one class! At least postpone the homework due date until tuesday or later on monday night.

I am SO lost on this HW. We are supposed to write a program in JES that will do something to frames, correct? But then we have to run movie maker and chose a beginning and ending fram? How does that make sure we have atleast 3 pictures? I am SOOOO lost....and I have read the book, slides, etc. Can this HW please be pushed back!? IT'S EASTER WEEKEND..at this rate I'm going to NOT be able to go home tomorrow so that I can stay here and FINISH this HW!! :(
You do not HAVE to run MovieMaker!! You just have to run JES. Mark Guzdial

My program runs fine, but when I play the movie when the pic changes velocity, it jumps a few frames it seems. Is this normal?
Amanda Cook
Yes, that's normal, Amanda. Mark Guzdial

Could someone who has a working code post it so the rest of us can see what we're doing wrong? I would REALLY appreciate it.

If anyone has had the same problem, please, let me know... I'm perfectly able to create the frames into a folder (30 frames). After downlonding MovieMaker from the Coweb, I unziped it, and clicked on the moviemaker.exe on JES folder. Double-clicked on it and the screen popped up asking for a starting frame and an ending frame. I gave them to MovieMaker by clicking on the "browse" button. It also asked me for the rate and I wrote 10 (not 10 fps). Then it asked me for a name for the movie that was about to be created and I wrote "hw5.mov". Then it did something funny. It created the movie file not on the folder where the frames were, but outside, in the JES folder (contrary to predicted). Worse than that: my "movie" consisted only of my FIRST and 30th frames! :) Do you think my objects may be moving to fast? All I get is the first change, and the rest is the last frame being displayed for ~3secs... Any suggestions? Thanks...
PS: the folder where the frames are stored is under the JES folder. Before it was under mediasources, but it makes no difference, it still doesn't work...
no more

Are your sure your program is creating 30 different frames? Have you looked at the images to see if they are all different before running MovieMaker. If so, post information about what you are saying is the starting frame and the ending frame. Keith McDermott


i haven't been in class lately and i don't know where to start for HW5. can some1 tell me what chapters I need to read to get going for this hw?
thanx

I posted a question last night about hw5 and cannot go further with the assignment until the question is answered. I am now at home, away from my school computer, so I no longer have access to JES. Tomorrow is Easter and I intend to spend it with my family rather than doing a cs assignment. I started the assignment early so that I could finish it early and spend the weekend with my family. The website was down for a better part of the day and seeing as how we have so much to do in class tomorrow, I really feel that hw 5 should be postponed. Justin DeMeester

The chapter that really deals with it in the book is chapter 10. I did read it and try the examples. I, personally however, am still having difficulty understanding some stuff. But hopefully it will help you. ;)

Thanks for responding. I also have read chapter 10, but the problem I am having is with my actual code. Justin DeMeester


What do we type in the command area to run this once its loading w/o problems? Do we have to use SetMediaPath, or do we just type directory=(something or other)?
Thanks.
You should be passing a directory into your program. The directory represents where you want all your frames to be when the program is running. Something like this hw5(r"C:\Documents and Settings\Justin\My Documents\My Frames"). Keith McDermott


After my program is done, the only thing in the JPEG images is the text. I'm pretty sure that's because the last WritePictureTo Function writes over everything else. How do we get each thing to save to the picture without writing over the existing picture? Thanks
Meghan Quinlan
def hw5(directory):
  thetask=makePicture(getMediaPath("thetask.jpg"))
  string= "Oh my!!!"
  for frame in range(1, 76): 
    printNow("Frame number: "+str(frame))
    canvas = makePicture(getMediaPath("640x480.jpg"))
    sourceX = 1
    for targetX in range(frame, frame+104): 
      sourceY = 1
      for targetY in range(frame, frame+50):
        color = getColor(getPixel(thetask, int(sourceX), int(sourceY)))
        setColor(getPixel(canvas, targetX, targetY), color)
        sourceY = sourceY + 1
      sourceX = sourceX + 1
    framenum=str(frame)
    if frame < 10:
      writePictureTo(canvas, directory+"//frame0"+framenum+".jpg")
    if frame >= 10:
      writePictureTo(canvas, directory+"//frame"+framenum+".jpg")
    writeFrame(frame, directory, canvas)
    tickertape(directory, string)

def writeFrame(frame, directory, canvas):
  if frame <= 25:
    addRectFilled(canvas, frame*3, frame*3, 50, 50, blue)
  if 25 < frame < 50:
    addRectFilled(canvas,frame*10,frame*10, 50, 50, blue)
  if frame >= 50: 
    addRectFilled(canvas, (50-(frame-50))*10, (50-(frame-50))*5, 50, 50, blue)
  framenum=str(frame)
  if frame < 10:
    writePictureTo(canvas, directory+"//frame0"+framenum+".jpg")
  if frame >= 10:
    writePictureTo(canvas, directory+"//frame"+framenum+".jpg")

def tickertape(directory, string):
  for frame in range(1,76):
    canvas = makePicture(getMediaPath("640x480.jpg"))
    string= "Oh my!!!"
    addText(canvas, 600-(frame*10), 76, string)
    framenum=str(frame)
    if frame < 10:
      writePictureTo(canvas, directory+"//frame0"+framenum+".jpg")
    if frame >= 10:
      writePictureTo(canvas, directory+"//frame"+framenum+".jpg")
|

Page has been removed



Hi, it's officially EASTER and I should be home right now, but instead I'm at home trying to figure out HW5! I started early, but was confused and needed help..I gave myself time away from it so that I could come back with a fresh brain...and, well..it didn't really help. I know we all complain a lot, but it would be WONDERFUL if the Profs would understand that it is EASTER Weekend and many of us do not get to go home that often to spend time with our family because Tech requires more than 100% of our time. PLEASE consider that we have worked hard this semester and would REALLY appreciate it if a) the HW was moved to say, Wednesday or b)the quiz/prequiz was moved to Friday? PLEASE consider everyone's frustrations.
I'm sorry, but no. We've already postponed the HW5 and HW6 deadlines, and we can't push them back further. Mark Guzdial

It is Easter weekend. I spent most of Friday and Saturday trying to figure out how to do this assignment. I posted a question on this page and recieved NO help from the prof/TA. Now I am spending MY Easter trying to figure out this assignment and do the prequiz and study for quiz 3 instead of spending quality time with my family. Thank you very much.
And what's worse, we didn't give you the pre-quiz or homework 5 until Friday, so that you HAD to work on Saturday and Sunday! Mark Guzdial

I am having the same problem as Meghan Quinlan but am not sure what section to find the write File function. I have looked but can't seem to locate it. Anybody know? Thank you~ Lauren Patton
The index to the book says that writePicture is on page. 49. Mark Guzdial

For some reason I receive an error on line 29 of my code - the last line:
writePictureTo(pict,filename): Path is not valid
An error occurred attempting to pass an argument to a function.
Please check line 29 of C:\Documents and Settings\Andrea\My Documents\hw5.py

Here's the code:
def makeMovie(directory):
  barbf=getMediaPath("barbara.jpg")
  barb=makePicture(barbf)
  for frame in range (1,100):
    printNow("Frame number: "+str(frame))
    canvas=makePicture(getMediaPath("640X480.jpg"))
    sourceX=45
    for targetX in range(frame*3,frame*3+((200-45)/2)):
      sourceY=25
      for targetY in range(frame*3,frame*3+((200-25)/2)):
        color=getColor(getPixel(barb,int(sourceX),int(sourceY)))
        setColor(getPixel(canvas, targetX, targetY), color)
        sourceY=sourceY+2
      sourceX=sourceX+2
  writeFrame(frame, directory, canvas)

def writeFrame(frame, directory, canvas):
  if frame <= 25:
    addRectFilled(canvas, frame*3, frame*3, 50, 50, red)
  if 25 < frame < 50:
    addRectFilled(canvas,frame*10,frame*10, 50, 50, red)
  if frame >= 50: 
    addRectFilled(canvas, (50-(frame-50))*10, (50-(frame-50))*5, 50, 50, red)
  addRectFilled(canvas,100+ int(10*sin(frame)),4*frame+int(10*cos(frame)),50,50, blue)
  framenum=str(frame)
  if frame < 10:
    writePictureTo(canvas, directory+"//frame0"+framenum+".jpg")
  if frame >= 10:
    writePictureTo(canvas,directory+"//frame"+framenum+".jpg")

Any insight? Andrea Dunlop
What are you providing as the directory for your program? Maybe it's not a valid path? Mark Guzdial

Yeah, Lauren, I don't understand what that means either. Meghan Quinlan

Hey meghan,
it might be easier if you just use addText() in your writeFrame() function instead of a separate function (tickertape). In the writeframe function dont writePicture just return the frame.
you seem to be saving the frame several times. instead save the frame only at the END of the loop, i.e at the end of "for frame in range(1, 76):"

I am starting to panic because I am pretty sure that I have written my program correctly (it is loading into JES properly without errors and it has ran without errors.) However, I cannot see if I am correct or not because I cannot get my MediaPlayer to work. I have downloaded QuikTime (for Java) and everytime I click on the MediaPlayer file in the JES folder it is saying that I don't have the appropriate program to run it. Then, I select QuikTime and it says that QuikTime cannot read it either... Any suggestions!? thanks :) Lori Beth Morris
There is an alternative way to test your movie besides MovieMaker – use the MediaTools application. There are instructions in JES Help and on your CD for doing it. Mark Guzdial

ok, I got MovieMaker (finally) but I have one last question. Where are all my frames saving? They are not in the folder that I setMediaPath to or in the JES folder. Where else could they be? (I know this is probably a silly question, but it's really confusing me :) thanks! Lori Beth Morris
Your program should take a directory as input, Lori. That's where you should be writing your frames. Mark Guzdial

Ok, I've read all the posts, and I'm still really confused as to how to run this. I'd really appreciate it if some one would post, step by step, what I do to see if my code works. I've written it in JES, downloaded the moviemaker.exe, but don't know what to do next. What do I type in the command area and when? What do I put as my first and last frames, etc.? Can someone help me?

Andrea Tice
Andrea, run your program, then look in the directory where you're writing the frames. Check a few of them by double-clicking on them. Do you see your objects? Are they in different positions in different frames? Then you're doing the right thing. I put extensive directions on the MovieMaker page on how to run it. Mark Guzdial

I still can not figure out why my function keeps writing over my images instead of playing the three at the same time. Lauren Patton
Where do you create your frame, Lauren? If it's BEFORE the frame loop, then you'll just be adding things to the frame, not starting from a blank frame each time. Mark Guzdial

you know what i find funny? There are ALL these questions from students and not a SINGLE TA or PROF has bothered to check on here for advice...wonder why...perhaps because ITS EASTER AND THEY ARE SPENDING TIME WITH THEIR FAMILY!! Perhaps, they should thnk about the fact that MOST of us haven't been able to do that!! CS makes me very angry!!! :(
I'm really glad I spent an hour building that MovieMaker example for you. Mark Guzdial

AH!! Thank you Mark for coming to help us out!! We do appreciat the MovieMaker Example. I think we are just overwhelmed with the amount of stuff that's due tomororw.


Lauren, I changed my program to this and it works now. Meghan Quinlan
def hw5(directory):
  thetask=makePicture(getMediaPath("thetask.jpg"))
  string= "Oh my!!!"
  for frame in range(1, 76): 
    printNow("Frame number: "+str(frame))
    canvas = makePicture(getMediaPath("640x480.jpg"))
    sourceX = 1
    for targetX in range(frame, frame+250): 
      sourceY = 1
      for targetY in range(frame, frame+185):
        color = getColor(getPixel(thetask, int(sourceX), int(sourceY)))
        setColor(getPixel(canvas, targetX, targetY), color)
        sourceY = sourceY + 1
      sourceX = sourceX + 1
    string= "Oh my!!!"
    addText(canvas, 600-(frame*10), 76, string)
    writeFrame(frame, directory, canvas)
    framenum=str(frame)
    if frame < 10:
      writePictureTo(canvas, directory+"//frame0"+framenum+".jpg")
    if frame >= 10:
      writePictureTo(canvas, directory+"//frame"+framenum+".jpg")

def writeFrame(frame, directory, canvas):
  if frame <= 25:
    addRectFilled(canvas, frame*3, frame*3, 50, 50, blue)
  if 25 < frame < 50:
    addRectFilled(canvas,frame*10,frame*10, 50, 50, blue)
  if frame >= 50: 
    addRectFilled(canvas, (50-(frame-50))*10, (50-(frame-50))*5, 50, 50, blue)


Meghan, I have the same code as you, but with a different string and colors, but I am having an error come up.
The line that is causing the error is:
if frame 10:
writePictureTo(canvas, directory+"//frame0"+framenum+".jpg")
JES says wrtePictureTopict,filename):path is not valid. An error occured attempting to pass an argument to a function. Please check line 15 of /Users/....(it give my complete directory) Whywould it do this? Any TA or Prof advice?

wrtePictureTopict,filename):
If that's exactly what you put in, fix the spelling. Do have the if statements for less than and greater than 10? If it's greater than 10, it should read writePictureTo(canvas, directory+"//frame"+framenum+".jpg"). Take the 0 off of the "//frame0".

What directory are you specifying? Does it actually exist? What is framenum? Mark Guzdial


My directory does exist. I can try and switch it directly to the desktop and see if that helps. The frame humb? What do you mean?




I am typing >>>setMediaPath and choosing my folder and then running >>>hw5(directory)...I've also tried hw5(r"C://etc.) and i am getting the same message everytime that I need to define the function or variable. Am I putting the correct thing in the command area?

Thanks Meghan~ Lauren Patton


That wouldn't be causing the error. Notice that the code says "framenum". What is the "framenum"? It's a number, you're cool. If it's a picture (by accident), it won't work. Mark Guzdial


About that MovieMaker-only-showing-first-and-30th-frames question: Yes, they are all different and appear to follow a logical sequence. The path to my first frame reads as follows: "C:\Pedro\GATECH\mediasources\HW5A\frame01.jpg". The 30th frame is like this: "C:\Pedro\GATECH\mediasources\HW5A\frame30.jpg". I tried creating the picture folder under JES and under Mediasources, but it makes no difference. Do I have to first start QuickTime and THEN call the .mov file from the QuickTime program? Because the MovieMaker creates this .mov file on JES folder and I simply click on it. The screen pops up showing the first frame. But when I press the play button on the bottom, it shifts to the last frame and stays still for 3 secs. It seems to me that it should work either way, since the program opens up, but again....... Thanks, no more

Pedro, double click on the second frame. Does it look like your 30th frame? I don't know why MovieMaker might not be working for you. If you have 30 different frames, then you've completed the program – you're done. Go ahead and submit. Mark Guzdial


I kept getting an out of bounds error in moviemaker like several other people, and the way I fixed it is by adding an extra 0 in front of everything...for example, my frames are "001" through "039". I have NO IDEA why that works. Jennifer Blake

Page 271 shows you how to do three digit frame numbers. We had this issue with Moviemaker previously (that it prefers three digit frame numbers), but I thought that that one was fixed. Mark Guzdial


yeah, i can also email it unless someone can tell me a better way to post it because i guess i dont know how.


here is the code:

my problem is that after it finishes, i only find the last fram (#99) in my directory, saved.

def hw5(directory):
barbf=getMediaPath("barbara.jpg")
barb=makePicture(barbf)
for frame in range (1,100):
printNow("Frame number: "+str(frame))
canvas=makePicture(getMediaPath("640X480.jpg"))
sourceX=45
for targetX in range(frame3,frame3+((200-45)/2)):
sourceY=25
for targetY in range(frame3,frame3+((200-25)/2)):
color=getColor(getPixel(barb,int(sourceX),int(sourceY)))
setColor(getPixel(canvas, targetX, targetY), color)
sourceY=sourceY+2
sourceX=sourceX+2
writeFrame(frame, directory, canvas)

def writeFrame(frame, directory, canvas):
if frame = 25:
addRectFilled(canvas, frame3, frame3, 50, 50, red)
if 25 frame 50:
addRectFilled(canvas,frame10,frame10, 50, 50, red)
if frame >= 50:
addRectFilled(canvas, (50-(frame-50))10, (50-(frame-50))5, 50, 50, red)
addRectFilled(canvas,100+ int(10sin(frame)),4frame+int(10cos(frame)),50,50, blue)
framenum=str(frame)
if frame 10:
writePictureTo(canvas, directory+"//frame0"+framenum+".jpg")
if frame >= 10:
writePictureTo(canvas,directory+"//frame"+framenum+".jpg")

AH HA! i figured it out!!!

def hw5(directory):
  barbf=getMediaPath("barbara.jpg")
  barb=makePicture(barbf)
  for frame in range (1,100):
    printNow("Frame number: "+str(frame))
    canvas=makePicture(getMediaPath("640X480.jpg"))
    sourceX=45
    for targetX in range(frame*3,frame*3+((200-45)/2)):
      sourceY=25
      for targetY in range(frame*3,frame*3+((200-25)/2)):
        color=getColor(getPixel(barb,int(sourceX),int(sourceY)))
        setColor(getPixel(canvas, targetX, targetY), color)
        sourceY=sourceY+2
      sourceX=sourceX+2
  writeFrame(frame, directory, canvas)

def writeFrame(frame, directory, canvas):
  if frame <= 25:
    addRectFilled(canvas, frame*3, frame*3, 50, 50, red)
  if 25 < frame < 50:
    addRectFilled(canvas,frame*10,frame*10, 50, 50, red)
  if frame >= 50: 
    addRectFilled(canvas, (50-(frame-50))*10, (50-(frame-50))*5, 50, 50, red)
    addRectFilled(canvas,100+ int(10*sin(frame)),4*frame+int(10*cos(frame)),50,50, blue)
    framenum=str(frame)
  if frame < 10:
    writePictureTo(canvas, directory+"//frame0"+framenum+".jpg")
  if frame >= 10:
    writePictureTo(canvas,directory+"//frame"+framenum+".jpg")

The problem is that after if finishes there is only the last frame saved in my directory.  

Trevor Spring

Your call to writeFrame(frame, directory, canvas) is not inside of your loop that makes all the frames. If you want all your frames to be written out, you need to indent that line of code so it is apart of the loop. Keith McDermott

Okay, so below is my code. I'm confused because I think I've messed up with the targetX and targetY values and when I run my program all I see are the squares, no string and no picture of tinkerbell. What am I doing wrong? All the help that is out there is much appreciated! Happy Easter Everyone!
def hw5(directory):
  tinkerbell=makePicture(getMediaPath("tinkerbell.jpg"))
  string= "Isn't she colorful?!"
  for frame in range(1, 76):#75 frames 
    canvas = makePicture(getMediaPath("640x480.jpg"))
    sourceX = 1
    for targetX in range(frame, frame+1): 
      sourceY = 1
      for targetY in range(frame, frame+1):
        color = getColor(getPixel(tinkerbell,(sourceX),(sourceY)))
        setColor(getPixel(canvas, targetX, targetY), color)
        sourceY = sourceY + 1
      sourceX = sourceX + 1
    string= "Isn't she colorful?!"
    addText(canvas, 600-(frame*10), 76, string)
    writeFrame(frame, directory, canvas)
    framenum=str(frame)
    if frame < 10:
      writePictureTo(canvas, directory+"//frame0"+framenum+".jpg")
    if frame >= 10:
      writePictureTo(canvas, directory+"//frame"+framenum+".jpg")

def writeFrame(frame, directory, canvas):
  if frame <= 25:
    addRectFilled(canvas, frame*3, frame*3, 50, 50, pink)
  if 25 < frame < 50:
    addRectFilled(canvas,frame*10,frame*10, 50, 50, blue)
  if frame >= 50: 
    addRectFilled(canvas, (50-(frame-50))*10, (50-(frame-50))*5, 50, 50, green)

Kyla LeCroy

Do we have to attach the blank canvas to our homework on the turnin? or will the T'A's already have the 640X480 in the input directory?
It is helpful if you attach the canvas, but is not necessary. Keith McDermott

I now have the same program problem as Trevor - the program runs but there is only one frame in the directory - frame99.jpg.
Andrea Dunlop

You need to make sure your call to writeFrame is inside of the loop that creates all your frames. See the answer to Trevor's problem. Keith McDermott

When I get to the part in my code that says :
"color = getColor(getPixel(picture, int(sourceX), int(sourceY)))"
I get an error which says:
"I wasn't able to do what you wanted. The error java.lang.ArrayIndexOutOfBoundsException has occured. Please check line 19 of" and then it says my filename.
What is going on? Everyone else seems to have the same thing that is working.

That error is telling you that your picture has reached the bottom of the canvas and can not move down anymore...it ran out of space. So, you have to adjust your target x so that it goes down slower...allowing for the last frame to be within the canvas...you can do this by dividing your target x frame values by 2. That should solve the problem...it worked for me.

same code as before with one adjustment:

def hw5(directory):
  barbf=getMediaPath("barbara.jpg")
  barb=makePicture(barbf)
  for frame in range (1,100):
    printNow("Frame number: "+str(frame))
    canvas=makePicture(getMediaPath("640X480.jpg"))
    sourceX=45
    for targetX in range(frame*3,frame*3+((200-45)/2)):
      sourceY=25
      for targetY in range(frame*3,frame*3+((200-25)/2)):
        color=getColor(getPixel(barb,int(sourceX),int(sourceY)))
        setColor(getPixel(canvas, targetX, targetY), color)
        sourceY=sourceY+2
      sourceX=sourceX+2
      writeFrame(frame, directory, canvas)

def writeFrame(frame, directory, canvas):
  if frame <= 25:
    addRectFilled(canvas, frame*3, frame*3, 50, 50, red)
  if 25 < frame < 50:
    addRectFilled(canvas,frame*10,frame*10, 50, 50, red)
  if frame >= 50: 
    addRectFilled(canvas, (50-(frame-50))*10, (50-(frame-50))*5, 50, 50, red)
    addRectFilled(canvas,100+ int(10*sin(frame)),4*frame+int(10*cos(frame)),50,50, blue)
    framenum=str(frame)
  if frame < 10:
    writePictureTo(canvas,directory+"//frame0"+framenum+".jpg")
  if frame >= 10:
    writePictureTo(canvas,directory+"//frame"+framenum+".jpg")

HERE IS THE ERROR:
>>> hw5(r"C:\Documents and Settings\Trevor\Desktop\cs1315\JES\mediasources-for-Fall2003\mediasources")
Frame number: 1
A local name was used before it was created. You need to define the method or variable before you try to use it.
 in file C:\Documents and Settings\Trevor\Desktop\cs1315\please work, on line 15, in function hw5
 in file C:\Documents and Settings\Trevor\Desktop\cs1315\please work, on line 27, in function writeFrame
UnboundLocalError: local: 'framenum'
Please check line 27 of C:\Documents and Settings\Trevor\Desktop\cs1315\please work

what should i do?
i dont understand.


So your problem is with framenum as the error tells you. If you look at your code, you'll notice that framenum is within an if statement. So on frame number 1, no framenum variable exists. You need to move framenum out, so that it is not within the if statement. Keith McDermott

Trevor - hit tab once! Andrea

Yes, I am the 54 thousandth person to say this... but MovieMaker won't work for me. It was popping up and asking me for start and end frame, which I gave it but then a black DOS looking window popped up and it didn't do anything. Now it won't even work! I looked at all my frames and they look good... but what should I do???
Do what we have told everyone else on this page and turn it in. Keith McDermott

I'm pleased to report that Barb is happily bouncing around my computer screen. Movie Maker works, too. You'll also be pleased to know that I will not be applying to TA for CS1315 (ever).... :) Thanks for the help with HW5! :) Andrea Dunlop

I keep entering this code


def copyTechsealPicture(canvas, picture, x, y):
    # Now, do the actual copying
    sourceX = 1
    for targetX in range(x,x+250):
      sourceY = 1
      for targetY in range(y,y+250):
        color = getColor(getPixel(picture,int(sourceX),int(sourceY)))
        setColor(getPixel(canvas,targetX,targetY), color)
        sourceY = sourceY + 1
      sourceX = sourceX + 1


and keep getting this error:

I wasn't able to do what you wanted.
The error java.lang.ArrayIndexOutOfBoundsException has occured
Please check line 29 of C:\Documents and Settings\Bryan Grant\My Documents\JES\Homeworks\HW5\hw5.py

line 29 is this:

color = getColor(getPixel(picture,int(sourceX),int(sourceY)))

any thoughts? I'm trying to get my picture to bounce around but I'm not having much luck yet. Thanks.

Bryan W. Grant


are we required to do the assignment through moviemaker? i have the code working in jes. is that all i need to turn into the ta? whats with all this moviemaker talk?

You don't need to use MovieMaker EXCEPT for making a movie for looking at or posting here on Spring 2004 HW5 Movies. You can turn in HW5 without MovieMaker. Mark Guzdial

i'm going to to apologize for all of us that complained. The TA's and Profs work really hard to help us and sometimes we get carried away with and overwhelmed with the amount of work we have here at Tech. Sorry Mark, and all the others for being rude...and this is coming from all of us (even those that may still be angry)


def hw5(directory):
  for frame in range (1,31):  
    flo=getMediaPath(r"flower.jpg")
    pic=makePicture(flo)
    flo2=getMediaPath(r"flower2.jpg")
    pic2=makePicture(flo2)
    printNow("Frame number: "+str(frame))
    canvas = makePicture(getMediaPath("store.jpg"))
    sourceX=1
    for targetX in range (frame*2, frame*2+getWidth(pic)):
      sourceY=1
      for targetY in range (frame*2, frame*2+getHeight(pic)):
        color = getColor(getPixel(pic, int(sourceX), int(sourceY)))
        setColor(getPixel(canvas,targetX,targetY),color)
        sourceY=sourceY+1
      soureceX=sourceX+1
    writeFrame(frame,directory,canvas)


def writeFrame(num, directory, framepict):
  framenum=str(num)
  if num < 10:
    writePictureTo(framepict, directory+"//frame0"+framenum+".jpg")
  if num >=10:
    writePictureTo(framepict, directory+"//frame"+framenum+".jpg")


I still only get a big white square where my picture is supposed to be. It's the right size but the picture is not there. What's the problem?
Heather Symon
check your spelling ;-) Page has been removed

I doubt that it matters, but is it okay if one object covers up another for a few frames of the movie, but may be seen otherwise? Basically, the two objects cross paths.
Kelly Keevan

Click "edit" then find, and type "overlap." Should net you an answer. (in other words, yes, it's okay)

This is a question for the quiz.
What's the diff. b/w interpreted and compiled?
I tried to understand it from chapter but haven't figured it out yet.
Jonathan Laing

I think...
A compiler is something that converts a programming language into machine language and stores it as a machine level program. so the program is slow only when you run it the 1st time but from the 2nd time on since the machine level program is already stored there's one step less, or maybe many steps lesser( i dont understand the concept of steps in that chapter) so it's faster. on the other hand an interpreter does this translation from programming language to machine level every single time the program is executed. so i think that's the difference. I hope that's right.
Well done, Anu! Mark Guzdial

does any1 know how to solve the 2nd problem on the QUIZ?
I tried several programs but they don't work. Here are the 2 that i think should work...if any of you figure out whats wrong with them please tell me!-Anu Akkineni.
program1:
def commonLetters(string):
  listS=string.split()
  countE=listS.count("e")
  countS=listS.count("s")
  countT=listS.count("t")
  countR=listS.count("r")
  listC=[countE,countS,countT,countR]
  maxvalue=listC.max()
  if maxValue==countE:
    print "e is the letter with the highest count. The count is "+countE
  if maxValue==countT:
    print "t is the letter with the highest count. The count is "+countT
  if maxValue==countR:
    print "r is the letter with the highest count. The count is "+countR
  if maxValue==countS:
    print "s is the letter with the highest count. The count is "+countS

program2:
def commonLetters(string):
  countE=0
  countT=0
  countR=0
  countS=0
  for letter in string:
     if letter == "e":
       countE=countE+1
     if letter == "E":
       countE=countE+1
     if letter == "t":
       countT=countT+1
     if letter == "T":
       countT=countT+1
     if letter == "r":
       countR=countR+1
     if letter == "R":
       countR=countR+1
     if letter == "s":
       countS=countS+1
     if letter == "S":
       countS=countS+1
  list=[countE,countT,countR,countS]
  maxValue=list.max()
  if maxValue==countE:
    print "e is the letter with the highest count. The count is "+countE
  if maxValue==countT:
    print "t is the letter with the highest count. The count is "+countT
  if maxValue==countR:
    print "r is the letter with the highest count. The count is "+countR
  if maxValue==countS:
    print "s is the letter with the highest count. The count is "+countS


What errors are you getting, Anu? Mark Guzdial


um...There was a question asked above about Compilers. I do not see that on my prequiz, does that mean that I have the wrong prequiz or are there different prequizes for each class? Kyla LeCroy

I tried this code and got this error: >>> commonLetter("AMERICA")
An attempt was made to call a function with a parameter of an invalid type. This means that you did something such as trying to pass a string to a method that is expecting an integer.
in file C:\Documents and Settings\Kyla\My Documents\blah.py, on line 17, in function commonLetter
TypeError: __add__ nor __radd__ defined for these operands
Please check line 17 of C:\Documents and Settings\Kyla\My Documents\blah.py...why? I am really confused. Here's my code:
def commonLetter(string):
  countE=0
  countT=0
  countR=0
  countS=0
  for letter in string:
    if letter =='E':
      countE=countE+1
    if letter=='T':
      countT=countT+1
    if letter=='R':
      countR=countR+1
    if letter=='S':
      countS=countS+1 
    maxValue=max(countE,countT,countR,countS)
    if maxValue==countE:
      print "e is the letter with the highest count. The count is" +countE


I FIGURED IT OUT!! I changed the last line of my code to read:
print "e is the letter with the highest count. The count is" ,countE
Kyla LeCroy
In order to do it the way you were before you need to convert countE to a string. Using str(countE) would do that for you. Keith McDermott

def hw5(directory):
thetask=makePicture(getMediaPath("thetask.jpg"))
string= "Oh my!!!"
for frame in range(1, 76):
printNow("Frame number: "+str(frame))
canvas = makePicture(getMediaPath("640x480.jpg"))
sourceX = 1
for targetX in range(frame, frame+250):
sourceY = 1
for targetY in range(frame, frame+185):
color = getColor(getPixel(thetask, int(sourceX), int(sourceY)))
setColor(getPixel(canvas, targetX, targetY), color)
sourceY = sourceY + 1
sourceX = sourceX + 1
string= "Oh my!!!"
addText(canvas, 600-(frame10), 76, string)
writeFrame(frame, directory, canvas)
framenum=str(frame)
if frame 10:
writePictureTo(canvas, directory+"//frame0"+framenum+".jpg")
if frame >= 10:
writePictureTo(canvas, directory+"//frame"+framenum+".jpg")

def writeFrame(frame, directory, canvas):
if frame = 25:
addRectFilled(canvas, frame3, frame3, 50, 50, blue)
if 25 frame 50:
addRectFilled(canvas,frame10,frame10, 50, 50, blue)
if frame >= 50:
addRectFilled(canvas, (50-(frame-50))10, (50-(frame-50))5, 50, 50, blue)

how do I add a different picture, instead of the moving rectangle?

sorry, I borrowed someone elses code for this question, i left mine at home


My dog ate my code

How do you convert a string to a list? I'm trying this for the pre-quiz.
In Kyla's code, it seems like you already have to know that E occurs the most times to have written that code. Please explain. Thanks!
Jonathan Laing

What frame rate are the TA's going to enter, or are they even actually goign to look at the movies? Basically how can we ensure that it is 3 seconds long - because you can make it shorter or longer depending on the frame rate. If we make 99 frames, and at 25 frames a second, all of the necessary action occurs, is this acceptable? Bryan W. Grant

I'll bet that the TA's can look at your number of slides and figure out the right number for a 3 second movie - or they'll always use 10 fps and deal with differences in speed. Longer is fine. Mark Guzdial




qweqweqwe



Link to this Page