Problem with Wavefront read_wobj function to read an .obj file into MATLAB

13 views (last 30 days)
REZA
REZA on 10 May 2018
Answered: Ajay Joseph on 25 Jan 2021
I am currently using MATLAB R2017a and have installed the Wavefront toolbox. I run read_wobj function to open a .obj 3D file. But everytime the following message is shown:
Reading Object file : nf_6_new_double.obj
%
% Wavefront OBJ file
% Created in RealityCapture v1.0.3.3939
%www.capturingreality.com
% 2031735 vertices, 4063610 faces
%
Reading Material file : nf_6_new.mtl
%
% Wavefront material file
% Created in RealityCapture v1.0.3.3939
%www.capturingreality.com
%
Finished Reading Material file
Lines processed : 10000
Lines processed : 20000
Lines processed : 30000
Lines processed : 40000
Lines processed : 50000
Lines processed : 2780000
Lines processed : 2790000
Lines processed : 2800000
Lines processed : 2810000
Lines processed : 2820000
Lines processed : 2830000
Field assignment to a non-structure array object.
Error in read_wobj (line 198) objects(no).data.vertices=array_vertices(findex);
Error in Angle_3DF (line 7) OBJ=read_wobj('nf_6_new_double.obj');
Similar problem is mentioned in this link:
https://www.mathworks.com/matlabcentral/answers/300038-has-anyone-tried-to-use-wavefront-read_wobj-function-to-read-an-obj-file-into-matlab
I also tried according to the answers in that link. But still the same. Anyone have a solution for this situation? Thanks in advance.

Answers (1)

Ajay Joseph
Ajay Joseph on 25 Jan 2021
Dont use read_wobj() use readobj(). It take a little longer to extract the data. Once the obj data is extracted using readobj(). I saved the file as a mat file to matlab's current folder using save('OBJ'). If you manage to save it then use the following to read vertices and faces.
load (OBJ.mat)
Vert = OBJ.v;
Fac = OBJ.f.v;
Happy days

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!