Forum

Author Topic: Screenshot of model in "ModelViewSolid" from various angle  (Read 2123 times)

linshuh

  • Newbie
  • *
  • Posts: 7
    • View Profile
Screenshot of model in "ModelViewSolid" from various angle
« on: September 19, 2020, 03:02:25 AM »
Hi all,
I have Metashape Pro version 1.6.4 and I wonder how to take screenshot of my model in 'solid mesh mode'?
renderPreview() will able to rotate the model and take screenshot in its own texture color.
However, I want the 'solid mesh' color but renderPreview() cannot do that.

I've also tried:
* renderImage() and captureView() cannot rotate model
* export model in .stl format and reimport to chunk and take screenshot --> screenshot loose the surface 3D (depth) info, it's just a chunk of region with same color.
*
Code: [Select]
Metashape.Application().model_view_mode = Metashape.Application.ModelView.ModelViewSolid
... making chunk
chunk.renderPreview(rotation_matrix)
I tried renderPreview() after buildDenseCloud(), buildModel(), buildUV(), buildTexture(), they all give me the color screenshot instead of 'solid mode'

Thanks advanced!

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14855
    • View Profile
Re: Screenshot of model in "ModelViewSolid" from various angle
« Reply #1 on: September 19, 2020, 06:36:33 PM »
Hello Linshuh,

Solid view mesh display in Metashape GUI is applying light to the model, which is not considered when renderImage or renderPreview method is used, so the only easy way is to use Metashape.app.model_view.captureView() command. The point of view can be changed using Metashape.app.model_view.viewpoint
Best regards,
Alexey Pasumansky,
Agisoft LLC

linshuh

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Screenshot of model in "ModelViewSolid" from various angle
« Reply #2 on: September 23, 2020, 07:53:17 PM »
Hi Alexey,
Thank you for the reply, but based on the 1.6.4 doc,
Quote
Application.ModelView.captureView([width][, height][, transparent][, hide_items ])
which cannot change the ModelViewMode.

I have a couple of question related to this:
(1) Whether following code is the proper way to switch the view mode?
Code: [Select]
Metashape.app.model_view.model_view_mode = Metashape.Application.ModelView.ModelViewSolid

(2) whether the following code is proper way to change viewpoint? (I haven't test since cannot get captureView() working)
* yrotdegree is float between [0, 360]
Code: [Select]
yrot = int(yrotdegree) * math.pi / 180
C, D = math.cos(yrot), math.sin(yrot)
ym = Metashape.Matrix([[C,0,-D,0],[0,1,0,0],[D,0,C,0],[0,0,0,1]])

Metashape.app.model_view.viewpoint.rot = ym


(3) How can captureView know which chunk it need to take screenshot?
Based on your code in other pose, I tried:
Code: [Select]
doc = Metashape.Document()
chunk = doc.addChunk()
chunk align photos ....... chunk.buildModel()
image = Metashape.app.model_view.captureView(width = 1024, height = 1024,transparent = False, hide_items = True)
image.save('testimage.png')
Then I got error: "RuntimeError: Can't save image: testimage.png"
I wonder why this happen?


The workflow I plan to use so far is:
1) Making chunk ->
2) change to "ModelViewSolid" after buildModel() ->
3) captureView() based on degree

Could you answer the three questions mentioned above?
By the way, if you see any error within these steps, please let me know.

Thank you!
« Last Edit: September 24, 2020, 02:41:52 AM by Linshuh@outlook.com »

mtbouchard

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Screenshot of model in "ModelViewSolid" from various angle
« Reply #3 on: September 23, 2020, 09:28:19 PM »
Hello Linshuh,

Solid view mesh display in Metashape GUI is applying light to the model, which is not considered when renderImage or renderPreview method is used, so the only easy way is to use Metashape.app.model_view.captureView() command. The point of view can be changed using Metashape.app.model_view.viewpoint

Heya Alexey,

I am also interested in this topic - to procedurally render non-texture view of the mesh from various angles (saw 45deg around y) to evaluate the mesh quality better for a few thousand automated scans.

So, running via python only(no UI): use the app captureView() function? And pass 'Metashape.ModelViewMode.ShadedModelView' as the mode? No code  needed, just verification is cool.

I appreciate how responsive you are on these forums Alexey...and thank you for the great product and support!

Matt Bouchard