How to pass a node|entity|domain object to custom cypher?

Snippet below doesn't work (always 0), how should I do it then?

@Query("""
    MATCH (i:Image) -[:DEPICTS] -> (p:Person)
    WHERE p = $person
    RETURN count(i)
    """)
public Integer countByPeopleContains(Person person);

In Person class there is a @Id @GeneratedValue private String id;. I have failed all attempts of checking equality with id too.

In SDN docs it says:

Mapped entities (everything with a @Node ) passed as parameter to a function that is annotated with a custom query will be turned into a nested map.

And an example:

@Query("MATCH (m:Movie {title: $movie.__id__})\n"
           + "MATCH (m) <- [r:DIRECTED|REVIEWED|ACTED_IN] - (p:Person)\n"
           + "return m, collect(r), collect(p)")
    Movie findByMovie(@Param("movie") Movie movie);

I don't understand why would anyone use movie title as it's natural id. What is the correct way?

Additional failed attempts can be found in this SO question.

If person is turned into a map, then try the following predicate instead:

where p.id = $person.id

It results in 0 being returned, which is wrong. Below are some of another failed attempts. And this is a minimal reproducible example.

// @Query("""
	// MATCH (i:Image) -[:DEPICTS] -> (p:Person)
	// WHERE id(p) = id($person)
	// RETURN count(i)
	// """)
// Invalid input for function 'id()': to be a node or relationship, but it was `Map`;
/* @Query("""
	MATCH (i:Image) -[:DEPICTS] -> (p:Person)
	WHERE p = $person
	RETURN count(i)
	""") */
/* @Query("""
	MATCH (i:Image) -[:DEPICTS] -> (p:Person)
	WHERE p.id = $person.__id__
	RETURN count(i)
	""")  */
/* @Query("""
	MATCH (i:Image) -[:DEPICTS] -> (p:Person)
	WHERE p.id = $person.id
	RETURN count(i)
	""") */ 
/* @Query("""
	MATCH (i:Image) -[:DEPICTS] -> (p:Person)
	WHERE id(p) = $person.id
	RETURN count(i)
	""") */
/* @Query("""
	MATCH (i:Image) -[:DEPICTS] -> (p:Person)
	WHERE id(p) = $person.__id__
	RETURN count(i)
	""") */
@Query("""
	MATCH (i:Image) -[:DEPICTS] -> (p:Person {id: $person.__id__})
	RETURN count(i)
	""")
public Integer countByPeopleContains(Person person);