Yes you are correct .Just putting amswer into programmatic way
First get the Id in URL parameter and then on page fetch using
Id recId=ApexPages.CurrentPage().getparameters().get('id');
Secondly use Select statement and get the ownerId(Assuming object is Account)
ID ownerId=[Select Id,ownerId from Account where Id=:recId].ownerId
Update:
After the comments looks like this has to be dynamic solution
id testid=ApexPages.CurrentPage().getparameters().get('id');
String objecttype=testid.getSobjectType().getDescribe().getName();
try{
Sobject s=(Database.query('Select Id,ownerId from '+objecttype+' where Id=:testid LIMIT 1'));
}
catch(exception e){
}
Id ownerid=(ID)s.get('ownerId');