function [ tform, orez, error ] = urciTfotmAOrez( pic, cameraParams, worldPoints )

tform=[];
orez=[];
prah=prah4(imhist(sepBC(pic,1)));
bin=(sepBC(pic,1)<prah);
[binWithHoles,~] = undistortImage(bin,cameraParams);
bin=imfill(binWithHoles, 'holes');
s1 = regionprops(bin, 'Area', 'BoundingBox');

imagePointsRaw=double(souradniceKrizku(bin, s1, size(bin)));

[imagePoints, error]=spravPoradiIP(worldPoints, imagePointsRaw);
if error==0
tform = fitgeotrans(imagePoints,worldPoints,'projective');
binS=imwarp(bin, tform);


s1 = regionprops(binS, 'Area', 'BoundingBox');
imagePointsRaw=double(souradniceKrizku(binS, s1, size(binS)));
[imagePoints, error]=spravPoradiIP(worldPoints, imagePointsRaw);

if error==0

    [~,maxInd]=max(sum(imagePoints,2));
    [~,minInd]=min(sum(imagePoints,2));
    orez(1,1:2)=imagePoints(minInd,:);
    orez(1,3:4)=imagePoints(maxInd,:)-imagePoints(minInd,:);
    
end
end


end

