In the future, your car will anticipate your every need, from where you're heading to what you'd like to listen to along the way — and, of course, drive itself.

That's the vision automakers are test-driving in Silicon Valley, which has emerged as ground zero in the race to re-imagine the automobile. Car companies ranging from General Motors to Mercedes have set up shop in the nation's hotbed of technology and innovation for a dose of inspiration — and a little wheeling and dealing — as they hash out how their vehicles will connect to the Internet, interact with users and drive autonomously.

And with Apple and Google increasingly eyeing the road, they're shifting their efforts into overdrive.

Cars have remained comparatively low-tech as everything from phones to thermostats have undergone digital makeovers. But automakers can no longer deny that connected cars are the way of the future — and they're pursuing the talent they need to engineer the shift, said Eric Noble, president of the CarLab, a consulting firm in the Los Angeles area.

By focusing on Silicon Valley, automakers are "almost unanimously admitting they don't have the internal resources to address the issue," he said. "Those who do have the knowledge, insight and skills to address the issue are all in one village."

Capped off by Ford's expansion earlier this year, most major automakers now have a presence in Silicon Valley. And even the early entrants have redoubled their efforts in recent years, transforming their Silicon Valley offices from far-flung research outposts to core arms of the company, said Chris Gerdes, who directs the Center for Automotive Research at Stanford University. He credits Google — whose cars routinely whir around sans drivers — with giving the traditional automakers a sense of urgency.

"Companies are realizing that to get the most out of their Silicon Valley offices, they need more than just a few people," Gerdes said. "They need to have an office that is doing exciting work and can compete for the very best talent the valley has to offer."

The pace of innovation is so brisk that some car companies project their vehicles will be running autonomously in at least some situations within the next five years. But when it comes to autonomous driving, honing the technology is just the beginning — the real test will be how drivers react, said Maarten Sierhuis, director of Nissan Research Center Silicon Valley.

At Nissan's Sunnyvale, Calif., office, engineers are working on software for autonomous driving alongside a team of in-house anthropologists and sociologists whose mission is to ensure humans remain at the center of the design so they feel comfortable relinquishing the wheel, whether weaving through traffic in San Francisco or cruising through a neighborhood in Berkeley, Sierhuis said. Working with university partners, Nissan recently launched an ambitious research project to study how cultural norms for driving vary from place to place.

"You can't just rip out the steering wheel without understanding what that means," Sierhuis said.

Outside the confines of their labs, automakers are capitalizing on their offices in the valley to form relationships with the tech industry's key players. BMW has a long track record of working with Apple and will have an app on the new Apple Watch, noted Uwe Higgen, who directs the BMW Group Technology Office in Mountain View, Calif.

Honda collaborates with tech companies large and small and recently opened a studio for developers in Mountain View. The release of Android Auto — Google's platform for apps in cars — and Apple's rival CarPlay has done much to spur developers' work on cars, said Nick Sugimoto, a senior program director at the Honda Silicon Valley Lab.

"Customers are really eager to get this in their cars," he said.

Auto executives stationed in the Bay Area also act as their companies' eyes and ears in the valley, ensuring that they do not fall behind either the technological curve or the whims of modern drivers.

And some automakers are even willing to look beyond the car. Ford is collecting data from cyclists to better understand bike usage, said Jim Buczkowski, Ford's director of Electrical and Electronics Systems for Research and Advanced Engineering. It helps the company prepare for a future in which city dwellers will seamlessly shift between various modes of transportation, perhaps driving their car to a train station, hopping aboard, and then mounting their bikes for the last leg of the journey, he said.

"We know that our cars and trucks are going to have to work very effectively with other forms of transportation to avoid congestion," he said.