It’s not easy being a whale. Even if you elude the whalers who still operate in some parts of the world and find enough to eat in waters rendered inhospitable by noise or chemical pollution, there’s always a chance you’ll be struck by a passing ship.

Reliable statistics on ship strikes are hard to find, since many go unreported. But about 1,200 were reported between 2007 and 2016, according to the International Whaling Commission. At least four gray whales have been killed by ships this year in the San Francisco area alone. And a recent analysis of North Atlantic right whale deaths showed that of 43 whales with a known cause of death, 16 died from vessel strikes.

Ship operators have had some luck using technology, like the WhaleAlert app and acoustic sensors, to avoid the deadly collisions. And in the Gulf Islands, off the coast of British Columbia, researchers are now testing a whale-detection system that could someday make busy shipping corridors a safer place for endangered whales.

If ship operators are alerted to the whales' presence, said Dan Zitterbart, a physicist at the Woods Hole Oceanographic Institution in Massachusetts and the scientist leading the test of the new system, “everybody goes slower” and fewer whales are struck.

The system consists of a series of infrared cameras that detect whales by sensing temperature differences between the warm-blooded mammals and the cooler seawater in which they swim. A computer linked to the cameras uses machine learning to distinguish surfacing whales from vessels, birds and more, improving the accuracy of the alerts sent to ship operators.

Researchers are testing the effectiveness of thermal infrared cameras for automated whale detection, which could help prevent collisions. Dan Zitterbart / Woods Hole Oceanographic Institution

Zitterbart said the system had been in development for years but that the bulky equipment and its high cost limited its practicality. “Now we’re experimenting with better algorithms and trying to use much simpler systems that could be easily and affordably installed on a variety of vessels to alert the vessel when a whale is in its path,” he said.

The latest version of the system will be mounted on a ferry dock on Galiano Island off the coast of Vancouver. There, it will scan waters abundant in whales and other large marine animals, detecting orcas in a narrow strait where ferries and marine life are at risk of colliding.

The orcas around the Gulf Islands are endangered, with fewer than 80 remaining.

If the tests go as planned, Zitterbart said, the system could be used to build real-time models of whales’ locations, giving ship operators a heads-up to slow down and maneuver carefully to avoid striking marine life.

In oceans increasingly dominated by large cargo ships, many large species of marine life are at risk of strikes. But those that spend significant time near the surface — such as right whales and humpbacks — are especially vulnerable, said Vanessa Pirotta, a marine biologist at Macquarie University in Sydney. In a 2019 study, she and her colleagues likened the threat faced by terrestrial animals whose habitats have been crossed by highways — car strikes and chemical and noise pollution — with the threat of collisions facing whales who spend time near major shipping routes.

“Ship strike is essentially roadkill,” she said.

Pirotta praised Zitterbart’s system, calling it “a piece in the puzzle” of preventing whale strikes. “It may not be the entire solution,” she added, “but it is a step forward.”

Zitterbart acknowledged that the system is designed to complement rather than replace other detection methods. “There is not the grand unified solution for all the places and all the species,” he said. “Everything needs to be targeted just because animals behave so differently. It will be a mix of solutions adjusted for the specific region.”

Want more stories about animals?

SIGN UP FOR THE MACH NEWSLETTER AND FOLLOW NBC NEWS MACH ON TWITTER, FACEBOOK, AND INSTAGRAM.