I've read the A-Frame documentation and copied the code directly from it, but I'm having trouble displaying a 3D object in .obj and .mtl formats. This is what I have:
<a-assets>
<a-asset-item id="chair-obj" src="obj/chair1.obj"></a-asset-item>
<a-asset-item id="chair-mtl" src="obj/chair1.mtl"></a-asset-item>
</a-assets>
<a-entity obj-model="obj: #chair-obj; mtl: #chair-mtl" position="0 1 -1" scale="0.000001 0.000001 0.000001"></a-entity>
The documentation suggests this might be a problem with mis-matched scales between A-Frame's scale and the object's native scale. It suggests scaling it down so I did so in steps from 0.1 to 0.000001 but still cannot see the object displayed (the object, and other test objects, were downloaded from TurboSquid but none display).
I've used slightly different syntax which worked for me: <a-obj-model src="#chair-obj" mtl="#chair-mtl" scale="0.001 0.001 0.001"></a-obj-model>
Related
I don't seem to be able to correctly import an exam generated with this lm template.
The exams2canvas("lm.Rmd", n = 10) function will generate the following error:
Error in switch(type, num = "numerical_question", schoice = "multiple_choice_question", :
EXPR must be a length 1 vector
I can export it with exams2qti21, but then Canvas will not offer the supplemental file (without generating any import error). This is the HTML of the question
<p> </p>
<p>Using the data provided in <a>regression.csv</a> estimate a linear regression of <code>y</code> on <code>x</code> and answer the following questions.</p>
<p><br /><br />b. Estimated slope with respect to <code>x</code>:<br /><br /><br /></p>
As you can see no href...
TL;DR
This is not about the supplementary files but about the question type. Using supplementary files with a single question (num, schoice, mchoice) works correctly in exams2canvas().
Background
The error in exams2canvas() is caused by the "cloze" question with schoice and num elements. Canvas supports only cloze questions with schoice elements placed in the text (displayed as multiple dropdowns). Hence, the question cannot be prepared for Canvas correctly.
Clearly, the error message was not helpful in pointing to this problem. In the devel version of the package I have now added an explicit error message for this.
The problems with the exams2qti21() output are probably due to insufficient customizations for Canvas. Internally, exams2canvas() interfaces exams2qti12() (QTI 1.2 not 2.1) but with several tweaks so that the resulting output can be imported correctly into Canvas. For the output from exams2qti21() we have not been able to do similar tweaks to make it work correctly.
The problem with the missing supplements is most likely caused by the default base64 = TRUE in exams2qti21(). Base64 encoding is not supported in Canvas and such content is simply stripped upon import, hence the missing href.
I am hoping to create a complex Venn Diagram with my own data in R using the nVennR package created by PĂ©rez-Silva et al. 2018. I am running the sample code in this vignette.
When I run the sample code, R shows a warning message:
The figure cannot be rendered in the plot window. Please, use the arguments outFile and/or systemShow.
After setting the systemShow argument to TRUE, Chrome attempts to open the SVG file and displays the following error:
error on line 74 at column 45: Namespace prefix xlink for href on use is not defined.
Not sure why I'm unable to generate an image using the code provided!
After installing the rsvg and grImport2 packages, the plot should be displayed as in the vignette:
plotVenn(list(SAS=sas, PYTHON=python, R=rr), nCycles = 2000)
If you want to view the plot in a web browser, save it to a file
plotVenn(list(SAS=sas, PYTHON=python, R=rr), nCycles = 2000, outFile="a.svg")
and change the first line
<svg width="700" height="500">
to
<svg width="700" height="500" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
The file can be viewed in SVG editors such as Inkscape without modification.
I am trying to recreate the game tutorial from the version 0.2.0 docs using 0.3.0:
https://aframe.io/docs/0.2.0/guide/building-an-advanced-scene.html
The collider component uses the following statement:
var vertices = mesh.geometry.vertices;
In 0.3.0 it returns the error:
vertices undefined
If you print
console.log(mesh.geometry);
In version 0.2.0 vertices is returned as an attribute of geometry, but in 0.3.0 there is no such attribute.
How should I work around this?
They now default to BufferGeometry.
You can opt-out: <a-entity geometry="buffer: false">
Or old data before conversion is also stored in this.geometry.metadata.
I know this has been asked before but the existing answers seem out of date, as I can't install either Bio7 or rimage using install.packages and searching the cran repository for Bio7 gives a 404 link (am I missing something?).
So as of now, what are the right packages for loading / saving images in R so one can process the pixels from within R?
I don't need it to provide processing routines. As long as it can reliably turn a jpeg into a grid of pixel values and vice versa (and preferably do the same for a png) I can write processing code.
I think raster is what you need.
library(png)
img <- readPNG(system.file("img", "Rlogo.png", package="png"))
## convert it to a raster, interpolate =F to select only sample of pixels of img
img.r <- as.raster(img,interpolate=F)
Now you have a vector of color:
str(img.r)
'raster' chr [1:76, 1:100] "#00000000" "#0
I am currently working on an application of Principal Component Analysis to visual data in R.
In Matlab, one can invoke commands such as "im2double" and "mat2gray" to convert a bitmap into a numerical matrix and back again to an image.
I was wondering whether this can be achieved in R, maybe via additional packages.
I've used the EBImage package (vignette here) available on bioconductor to work with and manipulate images:
# installing package if needed
source("http://bioconductor.org/biocLite.R")
biocLite("EBImage")
library(EBImage)
f = readImage(system.file("images", "lena-color.png", package="EBImage"))
str(f)
#Formal class 'Image' [package "EBImage"] with 2 slots
# ..# .Data : num [1:512, 1:512, 1:3] 0.886 0.886 0.875 0.875 0.886 ...
# ..# colormode: int 2
I was curious enough to try this out; clearly a package is a better solution, but if you really want to stick to base R, this will load a png (albeit upside down and backwards; that's probably fixable). It assumes the presence of the netpbm tools, so probably won't work out of the box on Windows systems.
readPng <- function(pngFile) {
contents <- system(paste('pngtopnm',pngFile,'| pnmtoplainpnm'),intern=TRUE)
imgDims <- strsplit(contents[2], ' ')
width <- as.numeric(imgDims[[1]][1])
height <- as.numeric(imgDims[[1]][2])
rawimg <- scan(textConnection(contents),skip=3)
return(list(
x=1:width,
y=1:height,
z=matrix(rawimg,width),
width=width,
height=height))
}
You can run image(img) on the list returned from this function directly, or access the per-pixel values using img$z.
Two methods to install the package.
install through command line if you have no Editor like RStudio
install the command line by entering into R interpreter using R command in bash.
Go to prompt where you can execute R commands. here these the basic image processing command.
execute this command to install the Bio conductor backage biocLite, which will help to install the EBIMage package( This package is used widely for image processing)
source("http://bioconductor.org/biocLite.R")
install the EMImage package to use image processing commands.
biocLite("EBImage")
Load the EBIMage package to use the image processing
library("EBImage")
# Reading image from computer
img=readImage(files="~/Desktop/Prog/R/tinago.JPG")
display(img)
img1=img+ 0.2 # increase brightness
img2=img- 0.2 # decrease brightness
display(img1) # Display images in browser or graphical window
display(img2) # Display images in browser or graphical window
img3= img * 0.5 # decrease contrast
img4=img * 2 # increase contrast
display(img3); display(img4) # show result images
img5=img^2 # increase Gamma correction
img6=img^0.7 # decrease Gamma correction
display(img5); display(img6) # Display result images
Note : readImage to read the image. Display is used to view the image in Graphical Window.
The relatively new package tiff will read and write TIF images quite nicely.
All the same, for anything other than relatively simple image manipulation, I'd recommend using ImageJ or SAOImage9 from the Harvard-Smithsonian group: http://www.cfa.harvard.edu/resources/software.html .
I've written tools in R to do pixel merging, pixel splitting, Sobel & Hough transforms, decolorization, etc., with great success. Ultimately the choice of application depends on the size of your images and the type of processing you need to do.