According to HDS, there were only 13 soldiers in the Union army named A. Royer--and only one of those was commissioned in as noted by
@lupaglupa. Others among the 13 may have been promoted. What you'll need to do is define the link between your great-grandmother and the soldier. Try to key on her in census records and, once you've identified her, expand your search to determine her parents--continue this way until you hit the surname "Royer". At this point, determine who in that family served in the Union army as a captain. The Pennsylvania records are excellent and the Illinois records are pretty good also.
Of course it may turn out that the captain was simply a family friend but the very fact that your great-grandmother retained his picture would indicate a stronger relationship