There isn't a universally accepted definition but we (RAF that is) tend to regard anything above 14.7mm as a cannon but other factors are considered too. Cannon projectiles are typically large enough to accept an HE charge (amongst other options) and usually fired via an electric impulse (rather than striker fired) and typically employ either a rotating breach or barrel (rather than a simple reciprocating mechanism).
For aircraft the 'cannon' term is an abridged form of auto cannon or rotary cannon, but most aircrew just call it a gun.