That's a very tricky problem.
On the one hand you don't want them to bump into you, on the other hand cultural norms (here in South-East England) forbid you from invading the privacy of strangers by speaking to them - or, god forbid, even perhaps startling them, which would be rude.
I would cough loudly to make them aware of my presence. If they're actually moving in your direction and are inches from hitting you then a "sorry!" is culturally permitted. "um!" or "ooh!" is also a last-minute option. As @Andrey suggests, "behind you!" would also be ok if a collision is otherwise unavoidable.
If you are actually bumped into then normal usage is for you to immediately apologise ("sorry!"). You can pre-empt this a little bit by acting as though the collision has taken place when actually it's about to take place ("sorry!"), thereby preventing it from taking place.
I believe that in other English-speaking countries around the world, the problem does not exist (or not to this extent), and a cheery "hey there buddy, mind you don't bump into me!" may be allowed.
Rather than trying to say something, a simpler option may be for you (as potential bump-ee) to silently take evasive action.
If you're riding a bicycle then two dings are appropriate,
Use a bell, giving Two Tings when approaching pedestrians to let them know you are there. (Please note this is not an order to pedestrians to get out of the way.)
Towpath cycling code of conduct, British Waterways
although remember to look embarrassed and say "sorry!" or "thanks!" as you pass, in order to soften the "undertone of reprimand":
I have [a bell] – but I don't know how to use it. I either ring it too close, and the victim jumps three feet into the air and presses themselves against the wall with an expression that clearly says "Holy crap, a cyclist passing me in a blur", even when I've slowed down to my customary 4mph. Or I do it from too far away, and because of the wind speed on that particular day, or a hearing impairment, nobody notices, and then it's too late to ring again, or even say "I wonder if I could just squeeze past on your left/right" without incurring the holy-crap response. ...
Personally, when I'm on foot, I don't like bells. I can never get past the undertone of reprimand. The Highway Code says car horns should only be used "to warn other road users of your presence"; and bells are to "let [road users] know you are there when necessary". Yeah yeah. The fact is that car horns don't say "Ahem...", they say "Oi, dickhead!", and for many pedestrians, bells do too.
One cyclist's bell has turned into hell on the towpath, Ben Thomas, The Guardian, 22 Oct 2009
If you're driving a vehicle and a pedestrian is about to step backwards into the road and be run over by you then it is permissible for you to toot your horn, but expect them to be annoyed at your rudeness rather than grateful that you've saved their life.
Anthropolgist Kate Fox has conducted extensive experiments in the bumping of English people:
I spent several amusing afternoons in busy, crowded public places (train stations, tube stations, bus stations, shopping centres, street corners, etc.) accidentally-on-purpose bumping into people to see if they would say ‘sorry’. A number of my informants, both natives and visitors, had cited this ‘reflex apology’ as a particularly striking example of English courtesy, and I was fairly sure I had experienced it myself – but I felt obliged to do the proper scientific thing and actually test the theory in a field-experiment or two.
My bumping got off to a rather poor start. The first few bumps were technically successful, in that I managed to make them seem convincingly accidental, but I kept messing up the experiment by blurting out an apology before the other person had a chance to speak. As usual, this turned out to be a test of my own Englishness: I found that I could not bump into someone, however gently, without automatically saying ‘sorry’. After several of these false starts, I finally managed to control my knee-jerk apologies by biting my lip – firmly and rather painfully – as I did the bumps. Having perfected the technique, I tried to make my experiments as scientific as possible by bumping into a representative cross-section of the English population, in a representative sample of locations. Somewhat to my surprise, the English lived up to their reputation: about 80 per cent of my victims said ‘sorry’ when I lurched into them, even though the collisions were quite clearly my fault.
There were some minor variations in the response: I found that older people were slightly more likely to apologize than younger people (late-teenage males were the least apologetic, particularly when in groups), and British Asians seemed to have a somewhat stronger sorry-reflex than British Afro-Caribbeans (possibly a reflection of the negative-politeness tendency in Indian culture – such apologies being a clear example of politeness that is primarily concerned with the avoidance of imposition or intrusion). But these differences were marginal: the vast majority of the bumped, of all ages, classes and ethnic origin, apologized when I ‘accidentally’ jostled them.
These experiments would tell us little or nothing about Englishness if exactly the same results were obtained in other countries, so by way of ‘controls’ I diligently bumped into as many people as I could in France, Belgium, Italy, Russia, Poland and Lebanon. Recognising that this would not constitute a representative international sample, I also bumped into tourists of different nationalities (American, German, Japanese, Spanish, Australian, Scandinavian) at tourist-trap locations in London and Oxford. Only the Japanese (surprise, surprise) seemed to have anything even approaching the English sorry-reflex, and they were frustratingly difficult to experiment on, as they appeared to be remarkably adept at sidestepping my attempted collisions. This is not to say that my bumpees of other nationalities were discourteous or unpleasant – most just said ‘Careful!’ or ‘Watch out!’ (or the equivalent in their own language), and many reacted in a positively friendly manner, putting out a helpful arm to steady me, sometimes even solicitously checking that I was unhurt before moving on – but the automatic ‘sorry’ did seem to be a peculiarly English response.
Watching the English, The Hidden Rules of English Behaviour, Kate Fox, ISBN 0340818867
However, the 'you've just bumped into me' "sorry!" is not necessarily a sincere apology:
The English “sorry” is a marker not of grace and decorum, but rather of a belief that one magic word has the power to decontaminate the world even as it both pacifies and reproves those who pollute it. “Sorry” is a mixture of decayed piety and passive-aggressive guile. ...
Today, the English appear to be very good at apologizing for things they haven’t done, but not very good at apologizing for things they have done. They have a copious vocabulary of suave aversion and strategic self-effacement. ...
“It’s my fault,” say the English when they are sure it’s your fault and want you to squirm.
A Poor Apology for a Word, Henry Hitchings, New York Times 13 Dec 2013
Of course none of these shenanigans are necessary or desirable in other parts of the British Isles, or even in the North of England, where all this ritualised politeness is often perceived as an affectation of effete middle-class Southerners.[linked video contains swearing, may be NSFW]