It's not about the object. Your first sentence has one more object ('the garden') which is an indirect object.
The second sentence is a complex one: it has one independent clause (with the subject 'she') and two dependent ones (with subjects 'people' and 'she'). There are two objectsThere's a direct object 'her' in the second clause: 'her' (a direct object) and 'the'people visited her in the hospital': visited (an direct objectwhom?).
These explanations might be useful: