Msl.cpp 611 Bytes
Newer Older
Nianchen Deng's avatar
Nianchen Deng committed
1
2
3
#include "Msl.h"
#include <time.h>

Nianchen Deng's avatar
sync    
Nianchen Deng committed
4
Msl::Msl() : net(nullptr) {}
Nianchen Deng's avatar
Nianchen Deng committed
5

Nianchen Deng's avatar
sync    
Nianchen Deng committed
6
bool Msl::load(const std::string &netPath) {
Nianchen Deng's avatar
Nianchen Deng committed
7
    net = new Net();
Nianchen Deng's avatar
sync    
Nianchen Deng committed
8
9
10
11
    if (net->load(netPath))
        return true;
    dispose();
    return false;
Nianchen Deng's avatar
Nianchen Deng committed
12
13
}

Nianchen Deng's avatar
sync    
Nianchen Deng committed
14
void Msl::bindResources(Resource *resEncoded, Resource *resDepths, Resource *resColors) {
Nianchen Deng's avatar
Nianchen Deng committed
15
16
17
18
19
    net->bindResource("Encoded", resEncoded);
    net->bindResource("Depths", resDepths);
    net->bindResource("Colors", resColors);
}

Nianchen Deng's avatar
sync    
Nianchen Deng committed
20
bool Msl::infer() { return net->infer(); }
Nianchen Deng's avatar
Nianchen Deng committed
21

Nianchen Deng's avatar
sync    
Nianchen Deng committed
22
23
void Msl::dispose() {
    if (net != nullptr) {
Nianchen Deng's avatar
Nianchen Deng committed
24
25
26
27
28
        net->dispose();
        delete net;
        net = nullptr;
    }
}