2016-06-24 5 views
1

dlib에 관해서는 멍청한 놈입니다. 파일에서 직접 얼굴 모양 모델을로드하는 방법을 알고 작동합니다.Dlib은 istream을 사용하여 얼굴 모양 모델을 비 직렬화합니다.

dlib::shape_predictor face_shape_predictor_; 
dlib::deserialize("shape_predictor_68_face_landmarks.dat") >> face_shape_predictor_; 

어떻게 istream에서 deserialize합니까?

나는 다음과 같은 코드가 있습니다

dlib::shape_predictor face_shape_predictor_; 
std::stringstream face_data_stream; 

loadDataToStream(face_data_stream); 
dlib::deserialize(face_shape_predictor_, face_data_stream); 

을 그리고 나는 그것이 작동 얻을하는 방법을 모르겠어요.

using namespace dlib; 

컴파일 문제를 해결 : 다음 코드를 추가) 사실

There are two global functions in the dlib namespace that provide serialization and 
deserialization support. Their signatures and specifications are as follows: 

    void serialize (
     const serializable_type& item, 
     std::ostream& out 
    ); 
    /!* 
     ensures 
      - writes the state of item to the output stream out 
      - if (serializable_type implements the enumerable interface) then 
       - item.at_start() == true 
     throws      
      - serialization_error 
       This exception is thrown if there is some problem which prevents 
       us from successfully writing item to the output stream. 
      - any other exception 
    *!/ 

    void deserialize (
     serializable_type& item, 
     std::istream& in 
    ); 
    /!* 
     ensures 
      - #item == a deserialized copy of the serializable_type that was 
       in the input stream in. 
      - Reads all the bytes associated with the serialized serializable_type 
       contained inside the input stream and no more. This means you 
       can serialize multiple objects to an output stream and then read 
       them all back in, one after another, using deserialize(). 
      - if (serializable_type implements the enumerable interface) then 
       - item.at_start() == true 
     throws      
      - serialization_error 
       This exception is thrown if there is some problem which prevents 
       us from successfully deserializing item from the input stream. 
       If this exception is thrown then item will have an initial value 
       for its type. 
      - any other exception 
    *!/ 

For convenience, you can also serialize to a file using this syntax: 
    serialize("your_file.dat") << some_object << another_object; 

That overwrites the contents of your_file.dat with the serialized data from some_object 
and another_object. Then to recall the objects from the file you can do: 
    deserialize("your_file.dat") >> some_object >> another_object; 
+0

답변은 여기에서 찾을 수 있습니다. http://stackoverflow.com/questions/37724457/is-it-possible-to-load-read-shape-predictor-68-face-landmarks-dat-at-compile- 팀 – Evgeniy

답변

1

"dlib deserailize"에 대한 구글의 첫 번째 검색 결과는이 텍스트에 연결됩니다.