Welcome to mirror list, hosted at ThFree Co, Russian Federation.

qttorch.cpp - github.com/torch/qttorch.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 9216b07233483dc7c688c40d2e6f2d0c5ade2c78 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// -*- C++ -*-

#include "qttorch.h"

#include <QColor>
#include <QDebug>
#include <QImage>
#include <QMetaType>

#include "TH.h"
#include "luaT.h"

#define torch_Tensor TH_CONCAT_STRING_3(torch.,Real,Tensor)
#define qttorch_(NAME) TH_CONCAT_3(qttorch_, Real, NAME)

#include "generic/qttorch.cpp"
#include "THGenerateAllTypes.h"

struct luaL_Reg qttorch_qimage_lib[] = {
  {"toByteTensor", qttorch_Byteqimage_totensor},
  {"toCharTensor", qttorch_Charqimage_totensor},
  {"toShortTensor", qttorch_Shortqimage_totensor},
  {"toIntTensor", qttorch_Intqimage_totensor},
  {"toLongTensor", qttorch_Longqimage_totensor},
  {"toFloatTensor", qttorch_Floatqimage_totensor},
  {"toDoubleTensor", qttorch_Doubleqimage_totensor},
  {0,0}
};

int luaopen_libqttorch(lua_State *L)
{
  // load module 'qt'
  if (luaL_dostring(L, "require 'qt'"))
    lua_error(L);
  // load modules 'torch'
  if (luaL_dostring(L, "require 'torch'"))
    lua_error(L);

  qttorch_ByteTensor_init(L);
  qttorch_CharTensor_init(L);
  qttorch_ShortTensor_init(L);
  qttorch_IntTensor_init(L);
  qttorch_LongTensor_init(L);
  qttorch_FloatTensor_init(L);
  qttorch_DoubleTensor_init(L);

  // enrichs QImage
  luaQ_pushmeta(L, QMetaType::QImage);
  luaQ_getfield(L, -1, "__metatable");
  luaT_setfuncs(L, qttorch_qimage_lib, 0);

  return 0;
}



/* -------------------------------------------------------------
   Local Variables:
   c++-font-lock-extra-types: ("\\sw+_t" "\\(lua_\\)?[A-Z]\\sw*[a-z]\\sw*")
   End:
   ------------------------------------------------------------- */