usdzconvert Doen't match Material .pngs - python

I am having a problem with usdpython tool delivered by Apple.
I'm trying to convert a file.obj linked to a material.mtl file exported by Cinema4D. Inside material.mtl Cinema linked me each material with a specific texture inside the folder /Faces
This is my folder structure:
/Faces
/file.obj
/material.mtl
and this is the command i'm trying to lunch
usdzconvert file.obj -v
I'm also trying to add material references by -m flag but what I get is a 3d object without textures

Obj files dont have any materials or animation attached to it.Why dont you try converting an fbx file.
I tried the usdz tools for .obj files to change colours and add textures.I added a Green color into the material copied the file and gave command usdzconvert file.obj -m Green .The material did not have any effect on the usdz file.I think it is better to apply the texture via commands.
Example:- usdzconvert vase.obj -m bodyMaterial -diffuseColor body.png -opacity a body.png -metallic r metallicRoughness.png -roughness g metallicRoughness.png -normal normal.png -occlusion ao.png .
I tried the material part but did not work.If you have texture give them through commands.Refer this link a half an hour video

Related

I am having trouble with the streamlit I am using a Chromebook and cant keep to insert images

from PIL import Image
import requests
import streamlit as st
from streamlit_lottie import st_lottie
#find more emojis at the link he set line 4 will show how your website would be layedout for users to see
st.set_page_config(page_title="My Webpage", page_icon=":tada:", layout="wide")
def load_lottieurl(url):
r =requests.get(url)
if r.status_code != 200:
return None
return r.json()
#lottie files are for animation to be put on your webiste (pip install requests)(pip install streamlit-lottie)(pip install pillow)
lottie_coding = load_lottieurl("https://assets7.lottiefiles.com/packages/lf20_2znxgjyt.json")
img_william = Image.open("images\william.png")
img_tacos = Image.open("images\tacos.png")
#header section / st.container will organize the code it will work fine without
with st.container():
st.subheader("hello i am william and this is my first website made by python header :wave:")
st.title("this would be were the title would go ")
st.write("this would be a small paragraph you wold write this area")
#st.write is for small paragrahps / st.title is to start the paragraps )
# what i am doing with the 3 lines and quotes on line 15 and that i am diving space on the website
with st.container():
st.write("---")
left_column, right_column = st.columns(2)
with left_column:
st.header("this will be the column for the left side ")
st.write('##')
st.write(
"""
i am currently doing what the tutotial is telling me to do even though i am quite cofnused:
- i will master this and i will understtand the concepts of making a website with this framework
- i will be great i bless god for changing how i act and i am as a person
- i know allot of people do not want to see me win but god does and thats all i need
- rome was not built in a day and they will say the samething about my journey
i am confused but if i keep puttingand effort in everyday i will master this in jesues name
"
""
)
i am having difficulty uploading images to python I am using the framework called streamlit and i have been following a tutorial on how to make my own website and when i do what he does to upload the image it tells me in the terminal that no such file in the directory i have made a file for the images that includes the code in the same file so i am very confused please help i am also using a chromebook
if images folder is in the working directory and you want to display the images, all you need is the code below.
st.image("images/william.png")
st.image("images/tacos.png")
but displaying image with PIL, you can do the following
img_william = Image.open("images/william.png")
img_tacos = Image.open("images/tacos.png")
st.image(img_william)
st.image(img_tacos)
Then apply this last method:
right click on your images folder and copy full path.
from pathlib import Path
SCR_DIR = 'C:\\users\\Desktop\\images' # Edit 'C:\\users\\Desktop\\images' with the coppied path you made at the first step. But maintain \\ when editting
img_william = Image.open(Path(SRC_DIR, "william.png"))
img_tacos = Image.open(Path(SRC_DIR, "tacos.png"))
st.image(img_william)
st.image(img_tacos)
Your scr_dir hould be something like
SCR_DIR = 'C:\\user\\My files\\Webpage\\images'
I am pretty sure you are missing something out.

turi create and label studio, error join annotation with photo

I'm trying to implement a model of Object Detecting using Turi Create.
For simplicity I just use 1 photo which is locate in my Desktop, inside a folder CondaMLProject.
Using the software Label Studio I place the label on this photo and export the csv file annotation
I notice that the csv file is like:
as you can see the image column report a wrong link to the photo, is not my desktop link.
when I run the python script of turi create to join the the image to the annotation I'm getting error
import turicreate as tc
path = "Spikosmall"
pathAnnotation = "Spikosmall/annotation.csv"
images = tc.load_images(path, with_path=True)
annotation = tc.SFrame(pathAnnotation)
data = images.join(annotation)
Error:
Columns image and image do not have the same type in both SFrames
How can I solve this issue?
Not so smart in python .. looking for some code to iterate inside the column image and change the link to match the photo folder..
Is there any other solution?

Increase graph size in plantUML from python?

MWE
To generate PlantUML diagrams in (sub)folder: /Diagrams/ I use the following python script:
from plantuml import PlantUML
import os
from os.path import abspath
from shutil import copyfile
os.environ['PLANTUML_LIMIT_SIZE'] = str(4096 * 4) # set max with to 4 times the default (16,384)
server = PlantUML(url='http://www.plantuml.com/plantuml/img/',
basic_auth={},
form_auth={}, http_opts={}, request_opts={})
diagram_dir = "./Diagrams"
#directory = os.fsencode()
for file in os.listdir(diagram_dir):
filename = os.fsdecode(file)
if filename.endswith(".txt"):
server.processes_file(abspath(f'./Diagrams/{filename}'))
It is used to generate for example the following test.txt file:
#startuml
'Enforce straight lines
skinparam linetype ortho
' Set direction of graph hierarchy
Left to Right direction
' create work package data
rectangle "something something something" as ffd0
rectangle "something something something" as ffd1
rectangle "something something something something something" as ffd2
rectangle "something something something something" as ffd3
rectangle "something something somethingsomethingsomething" as ffd4
rectangle "something something something something something something" as ffd5
rectangle "something something something something" as ffd6
rectangle "something something something " as ffd7
' Implement graph hierarchy
ffd0-->ffd1
ffd1-->ffd2
ffd2-->ffd3
ffd3-->ffd4
ffd4-->ffd5
ffd5-->ffd6
ffd6-->ffd7
#enduml
Expected behavior
Because I set the PLANTUML_LIMIT_SIZE variable to 16384 (pixels) as the FAQ suggests, I would expect this to fill up the picture of the diagram with all the blocks connected side by side up to a max width of 4096 * 4 pixels.
To test whether perhaps setting it from the python script was implemented incorrectly I also tried to set it manually with: set PLANTUML_LIMIT_SIZE=16384 to expect the same behavior as explained in the above paragraph (a picture filled up till 16384 pixels).
Observed behavior
Instead PlantUML cuts off the picture at 2000 horizontal pictures as shown in the figure below:
Question
How can I ensure the PlantUML does not cut off the blocks of the diagrams of n pixels (height or width), from a python script?
The best way I've found to prevent diagrams from being cut off, without trying to guess at the size or picking some arbitrarily large limit, is to select SVG output.
Note that setting PLANTUML_LIMIT_SIZE is only going to have an effect if you're running PlantUML locally, but it appears the Python interface you're using sends the diagram to the online service. I don't know the internals of that interface, but per the documentation you should be able to get SVG output by using http://www.plantuml.com/plantuml/svg/ as the service URL.
If you need the final image in PNG format, you will need to convert it with another tool.
Approach 1:
To prevent the diagram from being cut off I followed the following steps:
Downloaded the plantuml.jar from this location http://sourceforge.net/projects/plantuml/files/plantuml.jar/download
Put the diagram which I wrote in a someLargeDiagram.txt file, in the same directory as the plantuml.jar file.
Opened terminal on Ubuntu 20.04 in that same directory and ran:
java -jar plantuml.jar -verbose someLargeDiagram.txt
That successfully generated the diagram as .png file, which was not cut off.
Approach 2:
After creating even larger graphs, they got cut-off again, and it gave the message to increase the PLANTUML_LIMIT_SIZE. I tried passing the size as an argument in the commandline using: java -jar plantuml.jar -verbose -PLANTUML_LIMIT_SIZE=8192 Diagrams/latest.uml however that did not work, nor did ..-PLANTUML_LIMIT_SIZE 8192... This link suggested one could set it as an environment variable, so I did that in Ubuntu 20.04 using command: export PLANTUML_LIMIT_SIZE 8192, after which I successfully created a larger diagram that was not cut-off with command:
java -jar plantuml.jar -verbose Diagrams/latest.uml

Cannot Embed Cover Art To Mp3 in Python 3.5.2

I have this file "image.jp
and this .mp3 file:
"Green Day - When I Come Around [Official Music Video].mp3"
in the directory "test"
I have already successfully set tags as Author, Title, Album and etc using eyeD3 library.
and then I try to set the Cover Art.
I've tried two possibilities, but none of them worked:
First one: Mutagen:
from mutagen.mp3 import MP3
from mutagen.id3 import ID3, APIC, error
complete_file_path = "test\\"+"Green Day - When I Come Around [Official Music Video].mp3"
path_to_thumb_wf = "test\\"+"image.jpg"
audio = MP3(complete_file_path, ID3=ID3)
# add ID3 tag if it doesn't exist
try:
audio.add_tags()
except error:
pass
print(path_to_thumb_wf)
audio.tags.add(
APIC(
encoding=3, # 3 is for utf-8
mime='image/jpg', # image/jpeg or image/png
type=3, # 3 is for the cover image
desc=u'Cover',
data=open(path_to_thumb_wf, 'rb').read()
)
)
audio.save(v2_version=3)
And the solution using eyeD3
audiofile = eyed3.load(complete_file_path)
# read image into memory
imagedata = open(path_to_thumb_wf,"rb").read()
# append image to tags
audiofile.tag.images.set(3,imagedata,"image/jpeg", u"you can put a description here")
audiofile.tag.save()
I'm using python 3.5.2 on Windows 10. And i don't know if it could influence the result but i'll say anyway, the song has already a cover art that I'd like to change.
As explained in the ID3v2.3 section on APIC:
There may be several pictures attached to one file, each in their individual "APIC" frame, but only one with the same content descriptor. There may only be one picture with the picture type declared as picture type $01 and $02 respectively.
In v2.3, IIRC, "content descriptor" isn't actually documented anywhere, so different clients may do slightly different things here, but most tools will treat it either as the picture type plus description string, or as the entire header (text encoding, MIME type, picture type, and encoded description) as a binary blob. (And some tools just ignore it and allow you to store pictures with completely identical frame headers, but I don't think that's relevant with Mutagen.)
At any rate, this means you're probably just adding another Cover (front) picture, named 'Cover', rather than replacing any existing one.
You haven't explained how you're looking at the file. But I'm guessing you're trying to open it in Windows Media Player or iTunes or some other player, or view it in Windows Explorer (which I think just asks WMP to read the tag), or something like that?
Almost all such tools, when faced with multiple images, just show you the first one. (Some of them don't even distinguish on picture type, and show you the first image of any type, even if it's a 32x32 file icon…)
Some do have a way to view the other pictures, however. For example, in iTunes, if you Get Info or Properties on the track, then go to the Cover Art or similar tab (sorry for the vagueness, but the names have changed across versions), you can see all of the pictures in the tag.
At any rate, if you want to replace the APIC with a different one, you either need to exactly match the descriptor (and, again, that can mean different things to different libraries…), or, more simply, just delete the old one as well as adding the new one.
One more thing to watch out for: both iTunes and WMP cache cover art, and assume that it's never going to change once the file has been imported. And WMP also has various things that can override the image in the file, such as a properly-UUID'd folder cover art image in the same directory.

Saving thumbnails as fits files

Most of my code takes a .fits file and creates small thumbnail images that are based upon certain parameters (they're images of galaxies, and all this is extraneous information . . .)
Anyways, I managed to figure out a way to save the images as a .pdf, but I don't know how to save them as .fits files instead. The solution needs to be something within the "for" loop, so that it can just save the files en masse, because there are way too many thumbnails to iterate through one by one.
The last two lines are the most relevant ones.
for i in range(0,len(ra_new)):
ra_new2=cat['ra'][z&lmass&ra&dec][i]
dec_new2=cat['dec'][z&lmass&ra&dec][i]
target_pixel_x = ((ra_new2-ra_ref)/(pixel_size_x))+reference_pixel_x
target_pixel_y = ((dec_new2-dec_ref)/(pixel_size_y))+reference_pixel_y
value=img[target_pixel_x,target_pixel_y]>0
ra_new3=cat['ra'][z&lmass&ra&dec&value][i]
dec_new_3=cat['dec'][z&lmass&ra&dec&value][i]
new_target_pixel_x = ((ra_new3-ra_ref)/(pixel_size_x))+reference_pixel_x
new_target_pixel_y = ((dec_new3-dec_ref)/(pixel_size_y))+reference_pixel_y
fig = plt.figure(figsize=(5.,5.))
plt.imshow(img[new_target_pixel_x-200:new_target_pixel_x+200, new_target_pixel_y-200:new_target_pixel_y+200], vmin=-0.01, vmax=0.1, cmap='Greys')
fig.savefig(image+"PHOTO"+str(i)+'.pdf')
Any ideas SO?
For converting FITS images to thumbnails, I recommend using the mJPEG tool from the "Montage" software package, available here: http://montage.ipac.caltech.edu/docs/mJPEG.html
For example, to convert a directory of FITS images to JPEG files, and then resize them to thumbnails, I would use a shell script like this:
#!/bin/bash
for FILE in `ls /path/to/images/*.fits`; do
mJPEG -gray $FILE 5% 90% log -out $FILE.jpg
convert $FILE.jpg -resize 64x64 $FILE.thumbnail.jpg
done
You can, of course, call these commands from Python instead of a shell script.
As noted in a comment, the astropy package (if not yet installed) will be useful:
http://astropy.readthedocs.org. You can import the required module at the beginning.
from astropy.io import fits
At the last line, you can save a thumbnail FITS file.
thumb = img[new_target_pixel_x-200:new_target_pixel_x+200,
new_target_pixel_y-200:new_target_pixel_y+200]
fits.writeto(image+str(i).zfill(3)+'.fits',thumb)

Categories

Resources