我有一个包含许多子模块的项目,我试图使它们充当普通文件夹而不是存储库。我已经删除了.git/每个文件夹中的文件夹,但它们仍然像子模块一样,当我运行 a 时,git status它们似乎没有显示为未跟踪的文件。
我在代码块10.05上遇到一些困难,认识到我机器上的GLFW库.当我创建一个空项目,并复制粘贴此GLFW教程中找到的代码>> http://content.gpwiki.org/index.php/GLFW:Tutorials:Basics
#include <stdlib.h>
#include <GL/glfw.h>
void Init(void);
void Shut_Down(int return_code);
void Main_Loop(void);
void Draw_Square(float red, float green, float blue);
void Draw(void);
float rotate_y = 0,
rotate_z = 0;
const float rotations_per_tick = .2;
int main(void)
{
Init();
Main_Loop();
Shut_Down(0);
}
void Init(void)
{
const int window_width = 800,
window_height = 600;
if (glfwInit() != GL_TRUE)
Shut_Down(1);
// 800 x 600, 16 bit color, no depth, alpha or stencil buffers, windowed
if (glfwOpenWindow(window_width, window_height, 5, 6, 5,
0, 0, 0, …Run Code Online (Sandbox Code Playgroud) 我有这个红宝石代码:
def get_sum n
return 0 if n<1
(n%3==0 || n%5==0) ? n+get_sum(n-1) : get_sum(n-1) #continue execution
end
puts get_sum 999
Run Code Online (Sandbox Code Playgroud)
似乎一直在为价值而努力999.当我尝试9999它给我这个:
stack level too deep (SystemStackError)
Run Code Online (Sandbox Code Playgroud)
所以,我补充说:
RubyVM::InstructionSequence.compile_option = {
:tailcall_optimization => true,
:trace_instruction => false
}
Run Code Online (Sandbox Code Playgroud)
但什么都没发生.
我的红宝石版本是:
ruby 1.9.3p392 (2013-02-22 revision 39386) [x86_64-darwin12.2.1]
Run Code Online (Sandbox Code Playgroud)
我还增加了机器的堆栈大小ulimit -s 32768,我认为是32MB?
我不认为这是我的代码的错,因为它适用于较小的数字,我认为9999不是一个大数字.我有8GB的RAM,我认为这已经足够了.任何想法/帮助?
在此之后, Ruby线程限制 - 也适用于任何语言
我试图理解为什么我的线程不起作用.一些答案非常明确,如:
"使用fork创建4个子进程将使用你的4个内核"这将是我的最后一个方法,因为线程在我的情况下似乎不起作用.
这个:
"..Ruby MRI线程本身并不能充分利用运行Ruby代码的多核CPU.但是,这对你来说是否有问题取决于线程正在做什么.如果他们正在对其他人进行长时间运行的I/O调用在同一台机器上进行处理,你将看到好处,而不需要单独的进程.作为主题的线程和多处理可以变得非常复杂甚至做简单的事情.大多数语言都会对容易的和开箱即用的东西做出一些妥协. ......"
考虑到第二个,我从代码中删除了任何处理,只留下了I/O.
这里是:
beginning_time = Time.now
img_processor.load_image(frames_dir+"/frame_0001.png")
img_processor.load_image(frames_dir+"/frame_0002.png")
end_time = Time.now
puts "Time elapsed #{(end_time - beginning_time)*1000} milliseconds"
beginning_time = Time.now
for frame_index in 1..2
greyscale_frames_threads << Thread.new(frame_index) { |frame_number|
puts "Loading Image #{frame_number}"
img_processor.load_image(frames_dir+"/frame_%04d.png"%+frame_number)
}
end
puts "Joining Threads"
greyscale_frames_threads.each { |thread| thread.join } #this blocks the main thread
end_time = Time.now
puts "Time elapsed #{(end_time - beginning_time)*1000} milliseconds"
Run Code Online (Sandbox Code Playgroud)
而我得到的是这......
对于第一个非线程案例:
时间过去15561.358毫秒
对于第二个线程案例:
经过的时间为15442.401毫秒
好的,性能提升在哪里?我错过了什么吗?硬盘阻塞了吗?我是否真的需要生成进程才能在ruby中看到真正的并行性?
我有这段代码CameraPreview从a 获取a的位图TextureView并将其呈现在a上ImageView.
public void onSurfaceTextureUpdated(SurfaceTexture surface) {
// Invoked every time there's a new Camera preview frame
bmp = mTextureView.getBitmap();
bmp2 = bmp.copy(bmp.getConfig(),true);
for(int x=0;x<bmp.getWidth();x++){
for(int y=0;y<bmp.getHeight();y++){
//Log.i("Pixel RGB (Int)", Integer.toString(bmp.getPixel(x,y)));
if(bmp.getPixel(x,y) < -8388608){
bmp2.setPixel(x,y,Color.WHITE);
}else{
bmp2.setPixel(x,y,Color.BLACK);
}
}
}
mImageView.setImageBitmap(bmp2);
}
Run Code Online (Sandbox Code Playgroud)
所以基本上我将在相机显示的任何内容上应用实时图像处理.现在它只是背面和白色像素.它现在有点慢,位图的宽度和高度只有~250像素.
这是推荐的做法吗?
我正在尝试对传入的预览相机帧应用 2D 傅立叶变换。所以这是我在每个上执行的 renderScript 代码onSurfaceTextureUpdated:
#pragma version(1)
#pragma rs java_package_name(foo.camerarealtimefilters)
rs_allocation inPixels;
int height;
int width;
void root(const uchar4 *in, uchar4 *out, uint32_t x, uint32_t y) {
float3 fourierPixel;
for(int k=0; k<=width; k++){
for(int l=0; l<=height; l++){
float3 pixel = convert_float4(rsGetElementAt_uchar4(inPixels, k, l)).rgb;
float greyOrigPixel = (pixel.r + pixel.g + pixel.b)/3;
float angle = 2 * M_PI * ( ((x * k) / width) + ((y * l) / height) );
fourierPixel.rgb = greyOrigPixel*cos(angle);
};
};
out->xyz = …Run Code Online (Sandbox Code Playgroud) 我已经构建了一个包含2个场景的小型JavaFX.用户可以输入3个字段(文本)并上传一些对象的文档.
所以我想在用户点击保存时创建一个json对象并将其附加到Json对象列表中.然后将这些Json对象写入文件中.
这就是我的想法:
{
"objects": {
"object1": {
"field1": "foo"
"field2": "foo"
"field3": "foo"
"folderwithfileslocation": "C:/ProgramFiles/myapp/foobar/"
},
"object2": {
"field1": "foobar"
"field2": "foobar"
"field3": "foobar"
"folderwithfileslocation": "C:/ProgramFiles/myapp/barbar/"
},
.......
....
..
}
Run Code Online (Sandbox Code Playgroud)
这些将在启动时读入对象,因此用户可以访问它们,因此他可以编辑,添加,删除等典型的CRUD.
这是正确的方法吗?将有最多500-600条记录.我应该添加一个唯一的ID(像idk一样randomUUID())吗?
谢谢
我有这个布局:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@color/DeepSkyBlue"
tools:context=".MainPreviewActivity"
android:weightSum="5">
<FrameLayout
android:id="@+id/clean_preview_fragment_container"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="3"/>
<ListView
android:layout_height="0dp"
android:layout_weight="2"
android:layout_width="match_parent"
android:id="@+id/lvImageProcessChoices"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
在我的活动中我得到了这个:
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
if(savedInstanceState != null){
System.out.println("savedInstanceState is NOT null");
return;
}
CleanPreviewFragment cleanPreviewFragment = new CleanPreviewFragment();
processedPreviewFragment = new ProcessedPreviewFragment();
fragmentTransaction.add(R.id.clean_preview_fragment_container,cleanPreviewFragment);
fragmentTransaction.detach(cleanPreviewFragment);
fragmentTransaction.replace(R.id.clean_preview_fragment_container, processedPreviewFragment);
fragmentTransaction.attach(cleanPreviewFragment);
fragmentTransaction.commit();
Run Code Online (Sandbox Code Playgroud)
现在这样做,它开始一个相机预览(在干净的预览片段上),分离它并用另一个预览替换它,这是我修改过的预览,然后再次附加它(干净的预览片段).
Detach():从UI中分离给定的片段.这与放在后台堆栈时的状态相同:片段从UI中删除,但片段管理器仍在主动管理其状态.
所以我拆开它,但相机预览仍然继续?
因为当替换发生时,我可以看到修改后的预览.这是由attach()方法引起的吗?
我的清单中有这个:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.apps.foo.bar" >
<uses-feature android:name="android.hardware.camera" />
<uses-permission android:name="android.permission.CAMERA" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainPreviewActivity"
android:label="@string/app_name"
android:screenOrientation="fullSensor"
android:configChanges="orientation|screenSize" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Run Code Online (Sandbox Code Playgroud)
现在问题就在这里:
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
.............
.................
............
}
Run Code Online (Sandbox Code Playgroud)
当我将屏幕从纵向旋转到横向时,这被称为罚款。但是一旦我处于风景中,如果我转向另一个风景(即 180 度),它就不会射击。奇怪的是它只从portraittolandscape和landscapeto触发portrait。