People have fallen off mountains, tumbled into rivers, crashed airplanes and been struck by trains while taking selfies.

More than one has accidentally pulled the trigger of a gun when they meant to click the shutter, and many have taken friends and relatives who tried to save them into the great beyond.

A man takes a selfie next to a flooded street due to the overflowing of the Mapocho river during heavy rains in Santiago on April 17, 2016. MARTIN BERNETTI / AFP - Getty Images

Now a team of computer experts has analyzed the causes of selfie deaths and they think they have a solution: an app that would warn people they are in a death-by-selfie zone.

“We found that most common reason of selfie death was height-related. These involve people falling off buildings or mountains while trying to take dangerous selfies,” Hemank Lamba of Carnegie Mellon University, Ponnurangam Kumaraguru of the Indraprastha Institute of Information Technology and colleagues wrote in their report, which was published online at the open-access site arXiv.

Drowning and being hit by trains run a close second, the team found.

Related: Mumbai Creates No-Selfie Zones

Kumaraguru, who studied computer science at Carnegie Mellon, said he and the team noticed news reports about the trend and decided to try to use data mining techniques to do something about it.

“We found that most common reason of selfie death was height-related."

“It is important because people are losing their lives because of taking dangerous selfies,” Kumaraguru told NBC News.

The team collated media reports from around the world of selfie-related deaths. They found 127 between 2014 and September of this year.

Related: How Selfies Help Us Claim Our Identities

They include the German tourist killed while trying to catch himself atop a mountain in Peru’s Macchu Picchu in July and a group of five young women in India who drowned in September when one of them fell into a reservoir while taking a selfie — the other four drowned trying to rescue her.

“These are very disturbing,” Kumaraguru said.

There’s the man in Concrete, Washington, who shot himself while taking selfies with a gun — he apparently thought it wasn’t loaded, according to the Skagit Valley Herald. Then there’s the 2015 case of a pilot in Colorado who died, along with a passenger, in a crash that investigators say involved selfie-taking.

Related: Teen Death in Lebanon Sparks Protests

Yaroslav Segeda takes a selfie on top of a building in Kiev, Ukraine in April 2015. Rex Features via AP

Kumaraguru said his team is working to develop software that could warn users they are in a dangerous place or even turn the camera function off if it looks risky.

“It could help users make better decisions,” Kumaraguru said. They’re gathering information on places where actual selfie deaths have occurred, and using it to create algorithms for risk.

“We believe that the study can inspire and provide footprints for technologies which can stop users from clicking dangerous selfies, and thus preventing more of such casualties,” they wrote