Building Housing in Roads

I was walking around SF a few days ago, when I had this brilliant realization: why not build housing in the middle of streets?
If you think about it, this makes perfect sense:
By "in the middle of streets", I specifically mean something like: take a four-lane road, turn the middle two lanes into narrow rowhouses; then, you still have two singe-lane one-way roads, and a bunch of new housing in the middle!
As an example, I zoomed into a random street in SF on Google Maps (here). It doesn't seem like a particularly crucial street, since it's one block away from Geary Blvd, a much more major thoroughfare. Here's what it looks like currently:
Here's what it could look like:
Here is another example on Irving Street:
Which, when built up, would look something like this:
And here is another example:
which could look like this:
Of course, I'm only showing one side here.
This sort of thing would need to be planned carefully. Irving Street is about 80 feet wide; the internal living area should probably be at least 12 feet wide, plus another few feet for external walls and curbs, making the building, say, 20 feet wide. This leaves 30 feet on each side—enough for two 10-foot sidewalks and a car lane in the middle.
Now, it seems like this might only be feasible for a small proportion of streets without causing congestion. However, I'm not so sure—especially if coupled with a more robust transit system, or the widespread adoption of self-driving cars. I wonder what else I might be missing—can we really just increase the density of SF for free, while making it a cozier, safer, and more pleasant place to live?