Thu, 04/15/2010 - 11:11
Hi all,
As explained in the previous "Camera Vision Simulation" post, I would like to simulate the vision of a camera. The problem is that the result is not realistic and really, I don't know why.
Below, my code:
// A simple box 100x100x100 centered at (0,0,0)
BRepPrimAPI_MakeBox B(gp_Pnt(-50,-50,-50),100,100,100);
Handle(AIS_Shape) Box = new AIS_Shape(B.Shape());
AISContext->SetDisplayMode(Box,0,Standard_False);
AISContext->Display(Box);
double Focal=50, CCDSizeX=10, CCDSizeY=10; // Aperture: 11.4°
// Step 1: Mapping definition
Visual3d_ViewMapping Mapping = View->ViewMapping();
Mapping.SetProjection(Visual3d_TOP_PERSPECTIVE);
Mapping.SetProjectionReferencePoint( Graphic3d_Vertex(0,0,Focal) ); // Eye() position in View Reference Coordinate system
Mapping.SetFrontPlaneDistance(0);
Mapping.SetViewPlaneDistance(0); // ViewPlane = FrontPlane
Mapping.SetBackPlaneDistance(2000);
Mapping.SetWindowLimit( -CCDSizeX/2, -CCDSizeY/2, +CCDSizeX/2, +CCDSizeY/2 ); // Not sure ???
View->SetViewMapping(Mapping);
// Step 2: Orientation definition
Visual3d_ViewOrientation Orient = View->ViewOrientation();
Orient.SetViewReferencePoint( Graphic3d_Vertex(0,-1000,0) ); // At() position = CCD position
Orient.SetViewReferencePlane( Graphic3d_Vector(0,-1,0) ); // Camera Axis = OY Axis
Orient.SetViewReferenceUp( Graphic3d_Vector(0,0,1) );
View->SetViewOrientation(Orient);
// Positionning Analyze
double X, Y, Z;
View->At(X, Y, Z); // OK = (0,-1000,0)
View->Eye(X, Y, Z); // OK = (0,-1050,0)
View->FocalReferencePoint(X, Y, Z); // OK = (0,-1050,0)
View->Proj(X, Y, Z); // OK = (0,-1,0)
double angle = (Handle(V3d_PerspectiveView)::DownCast(View))->Angle(); // OK = 0.199rad = 11.4°
double focale = View->Focale(); // OK = 50
double depth = View->Depth(); // OK = 50
// Invalid Drawing: very small cube !!!
View->Update();
View->Redraw();
If someone can help me...
Fred
Thu, 09/25/2014 - 13:42
Hello Jallon,
it's been a couple of years since you asked this question, but have you found a solution after all?
Thu, 09/25/2014 - 13:55
Dear Laszlo,
Last time manipulation of the viewer has been seriously revised.
Coming soon OCCT 6.8.0 will support notion of the camera thus allowing natural manipulations with it.
Best regards
FSR
Thu, 09/25/2014 - 14:41
Dear Laszlo,
See also link to related discussion at development portal: http://dev.opencascade.org/index.php?q=node/939.
Mys be it will be useful for you too.
FSR
Thu, 09/25/2014 - 22:04
Okay, thanks.
Is there going to be a meaningful description in the guide about how the projection pipeline works?
László
Fri, 09/26/2014 - 18:39
Dear Laszlo,
We plan to make update of OCCT 6.8.0 visualization User's Guide in part regarding new camera API usage in an application.
Best regards
Sergey
Thu, 09/25/2014 - 22:10
I mean, what the guide says about SetWindowLimits is probably true, but regardless of what value I set there, I always get the same view. (I tried a lot of different combinations)