Skip to content

The programs for generating the 40k hair dataset in HairNet: Single-View Hair Reconstruction using Convolutional Neural Networks https://arxiv.org/abs/1806.07467

License

Notifications You must be signed in to change notification settings

minghaoPA/HairNet_DataSetGeneration

 
 

Repository files navigation

#
#  Created by Yi 24 Jan 2019
#

#This repo contains the program and the data to generate blended hair models from 343 3D hair models, and the codes for generating the training data in the paper HairNet: Single-View Hair Reconstruction using Convolutional Neural Networks.


#####################################STEP ONE##################################################################
#Blend new hair models from  from a small hair dataset.

#The compiled program is HairMix_run. The system for running the program is ubuntu 16.04 LTS. We will not share the source codes for it.
#You also need to have the following third party library installed.
#OpenGL
#GLEW
#glfw3
#GLUT
#OPENCV
#OPENMP
#OpenMesh-6.3


#The arguments of HairMix_run are hair_classes_folder src_hair_data_folder center_strands_folder output_blended_hair_folder k_start k_end
#An example bash to run the the HairMix program.
./HairMix_run HairClasses/ /home/yi/Documents/Hair/DeepHairData_old/hairstyles/ cstrands/ blend_hairs/ 1 32

#The hair_classes_folder contains 10 folders with each folder contains the images in the same classes of hair styles. The image name is the same as the hair names in the src_hair_data_folder. The program will look for the hair names in each class and blend each pair of the hairs in the same class. Make sure the program can find the corresponding hair data in src_hair_data_folder of the image in each of the subfolder in hair_classes_folder.

#The src_hair_data_folder contains the source hair data. First, please download the 343 hair models from http://www-scf.usc.edu/~liwenhu/SHM/database.html 

#The center_strands_folder contains the corresponding guide strands of each hair data in src_hair_data_folder. Each of the guide strands file contains 5 guide strands of the source hair. Those guide strands were generated by clustering the strands on the source hair.

#The output_blended_hair_folder is where you want to save the blended hair. The program will generate new hairs that each of them contains 10K strands with the same root positions. The root positions are in rootPosition_new.txt which contains the x,y,z positions and the normal vectors. Please create the folder first.

#For each pair of two hairs, the program can generate 2^5=32 different blended hairs by choosing the guide strand in order either from hair1 or hair2. For example, 01001 means to choose the 2nd and fifth guide strands from hair2 and the 1rst, third and fourth strand from hair1, and 00000 means to choose the guide strands only from hair 1 which will give you a new hair almost identical to hair1. The output hair will be named as strands<hair1_id>_<hair2_id>_<binary_choice>.data. k_start and k_end is the decimal number of the binary choice. For example, given k_start=1 and k_end=3 will give you hairs 00001, 00010 and 00011. 1<=K_start<=k_end<=31

#The unit of the 3D hair is around 0.82 meter

#Note: all the directory arguments need to have "/" at the end of the string.

#####################################STEP TWO##################################################################
#Generate the training data in the paper HairNet: Single-View Hair Reconstruction using Convolutional Neural Networks.

#The code is Hair_generate_convdata_and_imgs
#Please check the CMakeLists for dependencies.
#The arguments of Hair_generate_convdata_and_imgs are hair_folder convdata_folder map_roots_fn orient_img_folder view_num
#hair_folder is the folder that contains the hair.data, convdata_folder is the folder to save the hair.convdata, map_roots_fn is in /roots1024/map_roots1024.data, orient_img_folder is the folder to save the rendered images, view_num is the number of views you want to render.

#An example bash to run the HairMix program.
./Hair_generate_convdata_and_imgs ../../blend_hairs/ ../../blend_hairs_convdata/ ../../roots1024/map_roots1024.data ../../blend_hairs_imgs/ 4

#You also need /body_model/female_halfbody_medium.obj to render the image. Please purchase the model from https://www.turbosquid.com/3d-models/female-male-3d-model/552628 
#After purchasing the model, please email me ([email protected]) to get the transformed body model.
#You can use your own body obj model if you can find a model that fits the roots of the hair as in /roots1024/map_roots1024.obj


################################################
#strandsXXXXX_YYYYY_AAAAA_mBB.convdata
#The geometry of the hair 
#Each hair has 32*32 strands, each strands are sampled by 100 3D points. All hairs have the same order and coordinates of root points. 
#v=numpy.load(filename).reshape(100,4,32,32)
#Dimension: 100*4*32*32  
#v[i,0:3,n,m] is the x,y,z position of the ith point on the [n,m]th strand.
#v[i,3,n,m] is a value related to the curvature of that point. 
#if v[:,:,n,m] all equals to 0, it means it is an empty strand.
#You will only need the x,y,z position to represent the geometry of the hair. 

################################################
#strandsXXXXX_YYYYY_AAAAA_mBB.exr
#The image rendered from a random view (close to front)
#B: 0.0-1.0 (orient2D.x/2+0.5)
#G: 0.0-1.0 orient2D.y
#R: background is 0, body is 0.5, hair is 1.0.
#Use cv2.imread for loading it.

################################################
#strandsXXXXX_YYYYY_AAAAA_mBB.vismap

#v=numpy.load(filename)
#Dimension: 400*32*32
#v[i,n,m] is the visibility of the ith point on the [n,m]th strand. 1 means visible, 0 means invisible. The visibility is computed from the view of the image.

################################################
#strandsXXXXX_YYYYY_AAAAA_mBB.txt
#The rotation (Euler angles) and the position of the head. 
#R_x, R_y, Rz, X, Y, Z


#I put an example in blend_hairs, blend_hairs_convdata and blend_hairs_imgs folder.

#I hardcode the paths of the shaders, please modify it in main.cpp if you move the compiled program outside the release folder.
 








About

The programs for generating the 40k hair dataset in HairNet: Single-View Hair Reconstruction using Convolutional Neural Networks https://arxiv.org/abs/1806.07467

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 98.7%
  • CMake 1.3%