It's a Dahlgren gun, a type of cannon developed by John Dahlgren, "The Father of Naval Ordnance." Dahlgren designed a new breed of cannon which had further range and accuracy, and most importantly was much safer, as previous cannons had a tendency to burst in the midst of their crews when fired. Dahlgren guns are identified by their distinctive soda-bottle shape.
The carriage looks like the drawing below, which identifies it as an 8 inch gun, but I've found photos of identical cannons, such as this one in Hartford, and people who seem to know a lot about cannons say it's a nine-inch. Either way, it was manufactured at the Fort Pitt Foundry in Pittsburgh in the 1860s. Wikipedia tells me that there were 355 8-inch cannons made, and 1,185 of the 9-inch, and this cannon has engraved on it "FP No 675," so I'm assuming it is indeed a 9-inch gun.
The Navy Yard is full of finds like this, often squirrelled away in corners. This cannon is intact, and I've seen one other that was refinished and looks new and fancy. And then the other day I found this, a pile of Dahlgren guns in a pile behind a building in a far corner of the yard. Probably too rusty and incomplete to be worth anyone's while to restore.