ssh remotecluster 'bash -s' << EOF
> export TEST="sdfsd"
> echo $TEST
> EOF
Run Code Online (Sandbox Code Playgroud)
这不打印任何内容。
即使我将变量存储到文件中并将其复制到远程,它仍然不起作用。
TEST="sdfsdf"
echo $TEST > temp.par
scp temp.par remotecluster
ssh remotecluster 'bash -s' << EOF
> export test2=`cat temp.par`
> echo $test2
> EOF
Run Code Online (Sandbox Code Playgroud)
仍然没有打印任何内容。
所以我的问题是如何将本地变量作为变量传递给远程机器?
答案已在此给出
我试图从3-d Mat获得最大值,但minmaxIdx和mixmaxloc都没能做到这一点.
int sz[] = {BIN, BIN, BIN};
Mat accumarray(3, sz, CV_8U, Scalar::all(0)) ;
double testMaxval = 0;
int minIdx = accumarray.dims ;
minMaxIdx(accumarray, NULL, &testMaxval,NULL,minIdx ,NULL) ;
cout<<testMaxval<<endl ;
Run Code Online (Sandbox Code Playgroud)
这段代码不起作用,所以我可以使用max(),minmaxidx()或minmaxloc()来有效地获得最大值而无需手动处理整个n维数组吗?
我们从服务器中的工业传感器获得了 50TB 的 16 位未压缩 TIF 图像,我们希望使用 python 通过无损 zip 压缩来压缩它们。使用 python 因为使用 Python 来与我们的数据库通信更容易。
然而经过几个小时的搜索和阅读文档,我发现甚至没有一个成熟的Python库可以将16位TIF转换为zip压缩的tif。最新的 PIL 无法将压缩的 tif、OpenCV 硬编码输出文件写入 LZW tif 而不是 zip(deflate)。而且 smc.freeimage、PythonImageMagick 中没有足够的文档,所以我不知道他们是否可以做到这一点。我还发现了这个tifffile.py,它的源代码中似乎有一些关于压缩的内容,但没有示例代码让我了解如何配置输出的压缩选项。
当然,我可以使用外部可执行文件,但我只是不想在这里使用 python 作为脚本语言。
因此,如果有人在这里给我一个有效的例子,我真的很感激,谢谢。
更新:
cgohlke的代码有效,这里我提供另一个轻量级解决方案。从此处查看修补后的 pythontifflib 代码https://github.com/delmic/pylibtiff。
来自谷歌代码的原始PythonTiffLib不能很好地处理RGB信息,并且它不适用于我的数据,这个修补版本可以工作,但是因为代码非常旧,这意味着PythonTiffLib可能没有得到很好的维护。
使用这样的代码:
from libtiff import TIFF
tif = TIFF.open('Image.tiff', mode='r')
image = tif.read_image()
tifw = TIFF.open('testpylibtiff.tiff', mode='w')
tifw.write_image(image, compression='deflate', write_rgb=True)
Run Code Online (Sandbox Code Playgroud) 有 2D/3D 边界框碰撞检测的答案,但是我的问题是如何将情况发展到多维(4D 或更多)?
这是3D案例的代码。
template<typename T, typename _Prd>
bool BoundingBox3<T,_Prd>::Collision( const BoundingBox3<T,_Prd>& cube ) const
{
Point3<T,_Prd> min_1 = center - Point3<T,_Prd>(length,depth,height)/2.0;
Point3<T,_Prd> max_1 = center + Point3<T,_Prd>(length,depth,height)/2.0;
Point3<T,_Prd> min_2 = cube.Center() - Point3<T,_Prd>(cube.Length(),cube.Depth(),cube.Height())/2.0;
Point3<T,_Prd> max_2 = cube.Center() + Point3<T,_Prd>(cube.Length(),cube.Depth(),cube.Height())/2.0;
if(Volume()<cube.Volume())
{
Vector3D::Swap(min_1,min_2);
Vector3D::Swap(max_1,max_2);
}
if(min_1[0]<=min_2[0] && min_1[1]<=min_2[1] && min_1[2]<=min_2[2]
&& max_1[0]>=min_2[0] && max_1[1]>=min_2[1] && max_1[2]>=min_2[2])
return true;
if(min_1[0]<=max_2[0] && min_1[1]<=max_2[1] && min_1[2]<=max_2[2]
&& max_1[0]>=max_2[0] && max_1[1]>=max_2[1] && max_1[2]>=max_2[2])
return true;
return false;
};
Run Code Online (Sandbox Code Playgroud) 我知道可以离线渲染而不在屏幕上显示.
怎么做,也许吧
创建一个不可见的窗口然后绘制.
渲染时我可以使用特定的fbo吗?
我正在使用libtiff来编写一个加载和写入tiff图像的图像类.但是,使用它们非常困难我不断收到错误,我的代码是:
TIFF *out = TIFFOpen(filename.c_str(),"w") ;
if (out)
{
uint32 imagelength, imagewidth;
uint8 * buf;
uint32 row, col, n;
uint16 config, nsamples;
imagewidth = dims[0] ;
imagelength = dims[1] ;
config = PLANARCONFIG_CONTIG ;
nsamples = cn ;
TIFFSetField(out, TIFFTAG_IMAGELENGTH, &imagelength);
TIFFSetField(out, TIFFTAG_IMAGEWIDTH, &imagewidth);
TIFFSetField(out, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, &nsamples);
TIFFSetField(out, TIFFTAG_COMPRESSION, COMPRESSION_LZW) ;
TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, 8) ;
TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, TIFFDefaultStripSize(out, imagewidth*nsamples));
std::cout <<nsamples << std::endl ;
buf = new uint8 [imagewidth*nsamples] ;
for (row = 0; row < imagelength; …Run Code Online (Sandbox Code Playgroud) 我正在学习 Go 和 Mongodb,目前使用alpha 官方 mongodb 驱动程序。虽然它还处于 alpha 阶段,但我认为它对于基本用途来说已经相当实用了。但我在这个数据库驱动程序中遇到了一个关于时间转换的有趣问题。
基本上,我创建了一个自定义类型的结构对象,并将其封送到 bson 文档,然后将 bson 文档转换回结构对象。
//check github.com/mongodb/mongo-go-driver/blob/master/bson/marshal_test.go
func TestUserStructToBsonAndBackwards(t *testing.T) {
u := user{
Username: "test_bson_username",
Password: "1234",
UserAccessibility: "normal",
RegisterationTime: time.Now(), //.Format(time.RFC3339), adding format result a string
}
//Struct To Bson
bsonByteArray, err := bson.Marshal(u)
if err != nil {
t.Error(err)
}
//.UnmarshalDocument is the same as ReadDocument
bDoc, err := bson.UnmarshalDocument(bsonByteArray)
if err != nil {
t.Error(err)
}
unameFromBson, err := bDoc.LookupErr("username")
//so here the binding is …Run Code Online (Sandbox Code Playgroud)