Basic space carving algorithm
I have the following problem as shown in the figure. I have point cloud and a mesh generated by a tetrahedral algorithm. How would I carve the mesh using the that algorithm ? Are landmarks are the point cloud ?
Pseudo code of the algorithm:
for every 3D feature point
convert it 2D projected coordinates
for every 2D feature point
cast a ray toward the polygons of the mesh
get intersection point
if zintersection < z of 3D feature point
for ( every triangle vertices )
cull that triangle.
1 answer

I see it like this:
So you got image from camera with known matrix and FOV and focal length.
From that you know where exactly the focal point is and where the image is proected onto the camera chip (Z_near plane). So any vertex, its corresponding pixel and focal point lies on the same line.
So for each view cas ray from focal point to each visible vertex of the pointcloud. and test if any face of the mesh hits before hitting face containing target vertex. If yes remove it as it would block the visibility.
Landmark in this context is just feature point corresponding to vertex from pointcloud. It can be anything detectable (change of intensity, color, pattern whatever) usually SIFT/SURF is used for this. You should have them located already as that is the input for pointcloud generation. If not you can peek pixel corresponding to each vertex and test for background color.
Not sure how you want to do this without the input images. For that you need to decide which vertex is visible from which side/view. May be it is doable form nearby vertexes somehow (like using vertex density points or corespondence to planar face...) or the algo is changed somehow for finding unused vertexes inside mesh.
To cast a ray do this:
ray_pos=tm_eye*vec4(imgx/aspect,imgy,0.0,1.0); ray_dir=ray_postm_eye*vec4(0.0,0.0,focal_length,1.0);
where
tm_eye
is camera direct transform matrix,imgx,imgy
is the 2D pixel position in image normalized to<1,+1>
where(0,0)
is the middle of image. Thefocal_length
determines the FOV of camera and aspect ratio is ratio of image resolutionimage_ys/image_xs
Ray triangle intersection equation can be found here:
If I extract it:
vec3 v0,v1,v2; // input triangle vertexes vec3 e1,e2,n,p,q,r; float t,u,v,det,idet; //compute ray triangle intersection e1=v1v0; e2=v2v0; // Calculate planes normal vector p=cross(ray[i0].dir,e2); det=dot(e1,p); // Ray is parallel to plane if (abs(det)<1e8) no intersection; idet=1.0/det; r=ray[i0].posv0; u=dot(r,p)*idet; if ((u<0.0)(u>1.0)) no intersection; q=cross(r,e1); v=dot(ray[i0].dir,q)*idet; if ((v<0.0)(u+v>1.0)) no intersection; t=dot(e2,q)*idet; if ((t>_zero)&&((t<=tt)) // tt is distance to target vertex { // intersection }
See also questions close to this topic

Recursive longest common subsequence, incorrect printing
First I'd like to excuse for probably pathetic question. I am writing recursive longest common subsequence program. It usually works fine, but if there are two (or more) equally long results it gets wild. (e.g. jdbac,abjac should give: "bac, jac" but instead it prints jac,jac,bac ); I am using two 2D arrays, first with "way", second with lcs lengths. code:
#include <stdio.h> #include <stdlib.h> #include <string.h> #define max 99 int way[max][max]; int n, m; int PrintLCD(char * subseq1, char * subseq2, int i, int j) { //printf("%d %d \n",i,j); //printf("%d \n",way[i][j]); //if(i==0  j==0)return 0; if (way[i][j] == 1) { PrintLCD(subseq1, subseq2, i  1, j  1); printf("%c", subseq1[i]); } if (way[i][j] == 2) { PrintLCD(subseq1, subseq2, i  1, j); } if (way[i][j] == 3) { PrintLCD(subseq1, subseq2, i, j  1); } if (way[i][j] == 4) { //printf("\n %d",way[i][j]); way[i][j] = 2; PrintLCD(subseq1, subseq2, n  1, m  1); printf("\n"); PrintLCD(subseq1, subseq2, i, j  1); } return 0; } int main() { /* a b d c 0 0 0 0 a0 1 1 1 1 b0 1 2 2 2 c0 1 2 2 3 d0 1 2 3 3 1 3 3 3 2 1 3 3 2 2 4 1 2 2 1 4 */ //1skos 2gora 3lewo 4gora/lewo //1\ 2up 3left 4both int i, j; char A[15], B[15]; char subseq1[16] = {'~'}; char subseq2[16] = {'~'}; printf("Podaj pierwszy ciag: "); scanf("%s", A); printf("\nPodaj drugi ciag: "); scanf("%s", B); printf("\n"); strcat(subseq1, A); strcat(subseq2, B); m = strlen(subseq1); n = strlen(subseq2); int C[n][m]; for (i = 0; i < m; i++) C[i][0] = 0; for (j = 1; j < n; j++) C[0][j] = 0; for (i = 1; i < m; i++) { for (j = 1; j < n; j++) { if (subseq1[i] == subseq2[j]) { C[i][j] = C[i  1][j  1] + 1; way[i][j] = 1; } else if (C[i  1][j] >= C[i][j  1]) { C[i][j] = C[i  1][j]; if (C[i  1][j] == C[i][j  1]) { way[i][j] = 4; } else { way[i][j] = 2; } } else { C[i][j] = C[i][j  1]; way[i][j] = 3; } } } /************* rekurencja(i.j) jezeli w way ij: 4 rekurencja i1j rekurencja ij1 3 rekurencja i1j 2 rekurencja ij1 1 printf("%c",subseq1[i]); *********** */ printf("Najdluzszy podciag to: "); PrintLCD(subseq1, subseq2, n  1, m  1); printf("\n"); return 0; }
Thank You in advance.

How is Monte Carlo Tree Search implemented in practice
I understand, to a certain degree, how the algorithm works. What I don't fully understand is how the algorithm is actually implemented in practice.
I'm interested in understanding what optimal approaches would be for a fairly complex game (maybe chess). i.e. recursive approach? async? concurrent? parallel? distributed? data structures and/or database(s)?
 What type of limits would we expect to see on a single machine? (could we run concurrently across many cores... gpu maybe?)
 If each branch results in a completely new game being played, (this could reach the millions) how do we keep the overall system stable? & how can we reuse branches already played?

Coin Change Algorithm C
I'm having some trouble coming up with a working algorithm for the following problem.
Given determined quantities of available coins from 100, 50, 25 and 10 cents, I need to find how to fit a combination of these coins into a given value x. (it doesn't have to be optimal, any combination from availables coins will do).
So far, I've got this code, which works only for some cases.
struct coins{ int valor; int quant; }; int change = 0; int changecoins[4] = {0}; struct coins available_coins[4] = { 0 }; moedas_disp[3].value = 10; //10 cents coins moedas_disp[2].value = 25; //25 cents coins moedas_disp[1].value = 50; //50 cents coins moedas_disp[0].value = 100; //100 cents coins //quantity values just for test purposes moedas_disp[3].quant = 10; //10 cents coins moedas_disp[2].quant = 15; //25 cents coins moedas_disp[1].quant = 8; //50 cents coins moedas_disp[0].quant = 12; //100 cents coins for(int i=0; i<4; i++){ while((change/available_coins[i].value>0)&&(available_coins[i].quant>0)){ change = available_coins[i].value; available_coins[i].quant; changecoins[i]++; } } if(change>0){ printf("It was not possible to change the value"); } else{ printf("Change:\n"); printf("\t%d 100 cent coin(s).\n", changecoins[0]); printf("\t%d 50 cent coin(s).\n", changecoins[1]); printf("\t%d 25 cent coin(s).\n", changecoins[2]); printf("\t%d 10 cent coin(s).\n", changecoins[3]); }
However for quantities like 30 this won't work. The program will fit 1 coin of 25 cents, but then have 5 cents left, which will fail to compute. This also occurs with 40, 65, and so on.
Thanks in advance!

How can I use the "Enter Key" for getKey in Graphics.py
I can say  (if key = 'Left') or (if key = 'Right'), but for some reason i can't say  (if key = 'Enter'). Why isn't this working? Can I not use the enter key for getKey in graphics.py?

vec4 light position must be cast as a vec3 and then back to vec4?
I have working code that renders some boxes with lighting. I pass the variables in as a vec4.
glm::vec4 pointLightPosition = glm::vec4( 0.7f, 0.2f, 2.0f, 1.0f); ... glUniform4fv(glGetUniformLocation(id, "light.position"), 1, glm::value_ptr(pointLightPosition));
If I change the line (in the shader) from
vec3 lpos = vec3(VIEW*vec4(vec3(light.position), 1));
to
vec3 lpos = vec3(VIEW*light.position);
Then the lighting stops working as intended. The boxes are too dark, but get bright when you get close.
Not Working Closer Gets Brighter
So why does the first line of code produce the desired result while the second does not?

Blender object manipulation in Rails app
I'm working on a project in Rails and would like to render an simple object of a water glass that's level goes up and down depending on a variable pulled from the database, (postgresql).
Below are the tutorials I'm using for the blender object.
https://www.youtube.com/watch?v=6qVgMJNKCSs
https://www.youtube.com/watch?v=8HxegThjwtw&t=541s
Is it possible to manipulate a blender object in this way?
If anyone has alternative suggestions that would be easier or interact better with rails or postgresql I would also be open to suggestions, I am just more familiar with blender or creating graphics in threejs.

Need advice concerning the creation of open world game in Unity 3D
I just wanted to ask for advice those being an expert in Unity 3d and overall in game industry about how it is possible to create an openworld game by means of Unity 3D, that is, I already tried to combine several tiles of terrains, 4 to be exact, and their respective size is 500x500. However, once I started to add the fifth terrain to those terrains, Unity stopped working. Moreover, another problem that I faced was with light mapping in Unity, that is, the more terrain I add to the scene the more it is difficult to bake the light mapping. The question is if I am doing correctly by adding terrains to each other and how openworld games are actually created. Yes, I heard of chunk loading but is it possible to code it on my own without using ready plugins. Lastly, Is it possible to combine tiles of terrains just manually without using any tools like Terrain Slicing kit or Gaia please I really need your help Thank you for your attention))).

Export Haskell OpenGL to STL for 3D printing
I've found how to export a 3D OpenGL scene to
ppm
. But is it possible to export to theSTL
format ? This is the format required for 3D printing.There's a package for STL parsing but I don't know whether it is possible to use it with OpenGL.
Someone proposes to close this question for unclearness. I just want to know whether it is possible to export a 3D Haskell OpenGL graphic to a file appropriate for 3D printing (not necessarily STL, but as far as I know this is the only way  I may be wrong.) Sorry if it's still unclear, it may be due to my wording and my English. I do the best I can.
Just for info, here is an example with the R package
rgl
:And here is how the
STL
file looks like in ASCII representation (it takes 3.7 MB):solid testSTL.stl produced by RGL facet normal 0.9965197 0.05894169 0.05894333 outer loop vertex 0.8633249 0 0 vertex 0.8656725 0 0.03968928 vertex 0.8642709 0.0237557 0.03974825 endloop endfacet facet normal 0.9965196 0.05894321 0.05894424 outer loop vertex 0.8633249 0 0 vertex 0.8642709 0.0237557 0.03974825 vertex 0.8619304 0.0235772 0 endloop endfacet facet normal 0.9827041 0.05841724 0.1757272 outer loop vertex 0.8656725 0 0.03968928 vertex 0.8726366 0 0.07863396 vertex 0.8712143 0.02428522 0.0787534 endloop endfacet ...
So that does not sound impossible to have a STL converter for Haskell...
EDIT
There's a possible way but I didn't manage on Windows (that's frustrating)
convert the OpenGL graphic to
ppm
using theglcapture
library; convert theppm
tosvg
using ImageMagick (or perhaps don't necessarily convert  theppm
can be opened in InkScape, see next steps)install OpenSCAD and InkScape (there exist portable versions)
install this InkScape extension and follow the instructions
EDIT
Another possible way here. Similarly, I've failed.

Letter head date curve using css
I am not sure about the exact statement I should use but I want a style as in the image below in css: I tried find out but didn't find style like this.

TensorFlow: lambda use out of session
I am reading a snippet of TensorFlow codes (line 8589) and get confused. I made some changes to clarify:
with tf.Graph().as_default(): gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=gpu_memory_fraction) sess = tf.Session(config=tf.ConfigProto(gpu_options=gpu_options, log_device_placement=False)) with sess.as_default(): pnet = align.detect_face.create_mtcnn(sess, None) out = pnet(img_y)
The
create_mtcnn
is defined as:def create_mtcnn(sess, model_path): if not model_path: model_path,_ = os.path.split(os.path.realpath(__file__)) with tf.variable_scope('pnet'): data = tf.placeholder(tf.float32, (None,None,None,3), 'input') pnet = PNet({'data':data}) pnet.load(os.path.join(model_path, 'det1.npy'), sess) pnet_fun = lambda img : sess.run(('pnet/conv42/BiasAdd:0', 'pnet/prob1:0'), feed_dict={'pnet/input:0':img}) return pnet_fun
My question is why
out = pnet(img_y)
does not throw an error since the graph and session is closed? 
Extracting text from a grid image
I need to extract text segments from a grid image for OCR. I have tried multiple approaches such as HoughLines, Connected Components, Morpological operations etc. but I haven't got satisfactory results. Could anyone suggest a better approach? I have attached a few sample images

Issue: Model Classification cats and dogs (keras)
Read this text only after reading everything else: "check the second model at the end.There i try to classify cars and planes from cifar dataset: that model is reproducible"
I am trying to build a model that classifies cats and dogs, something that should not be a real problem. So, here what I am doing:
I created a folder with two labeled subfolders: cats and dogs. In each folder I have 1000 image of cats/dogs.
I built iteratively an numpy array in which I put my images after converting them to arrays ( I have chosen (200,200,3) size for each image) and I have upscaled the array by dividing it by 255. So I got a (2000,200,200,3) upscaled array.
Then, I create an array for the labels. Since I have two categories, I will have 2 biniary digits for each row of the array: (1,0) if cat and (0,1) if a dog. So I found myself with a (2000,2) array of labels.
Next, I create X_train,Y_train and X_valid,Y_valid ( 70% for train and 30% for valid).
Then I create a neural network with this architecture:
Dense(200x200x3,1000,relu)>>> Dense(1000,500,sigmoid)>>>Dense(500,100,sigmoid)>>>Dense(100,2,softmax) : BACKPROP:loss=categorical_crossentropy,optimizer=adam.Till now, everything looks fine, the model is trained. But then, when I try to predict values: the model always gives back the same value whatever is the input ( even if i try to predict elements with the training set , i always get the same constant output= array([[0.5188029 , 0.48119715]] )
I do really need help, i don't know why this is happening.. So in order to guide you guys I'll write down all the code corresponding to what I did:
Importing libraries function: preprocess_image
def preprocess_image(img_path, model_image_size): image_type = imghdr.what(img_path) image = Image.open(img_path) resized_image = image.resize(tuple(reversed(model_image_size)), Image.BICUBIC) image_data = np.array(resized_image, dtype='float32') image_data /= 255. image_data = np.expand_dims(image_data, 0) # Add batch dimension. return image, image_data ###################################### import libraries ##########################################################
import argparse import os import matplotlib.pyplot as plt from matplotlib.pyplot import imshow import scipy.io import scipy.misc import numpy as np import pandas as pd import PIL import tensorflow as tf from keras import backend as K from keras.preprocessing import image from keras.layers import Input, Lambda, Conv2D from keras.models import load_model, Model from yolo_utils import read_classes, read_anchors, generate_colors, preprocess_image, draw_boxes, scale_boxes from yad2k.models.keras_yolo import yolo_head, yolo_boxes_to_corners, preprocess_true_boxes, yolo_loss, yolo_body from keras.models import Sequential from scipy.misc import imread get_ipython().magic('matplotlib inline') import matplotlib.pyplot as plt import numpy as np import keras from keras.layers import Dense import pandas as pd %matplotlib inline
Importing the images
train_img=[] for i in range(1000,2000): (img, train_img_data)=preprocess_image('kaggle/PetImages/Cat/'+str(i)+'.jpg',model_image_size = (200, 200)) train_img.append(train_img_data) for i in range(1000): (img, train_img_data)=preprocess_image('kaggle/PetImages/Dog/'+str(i)+'.jpg',model_image_size = (200, 200)) train_img.append(train_img_data) train_img= np.array(train_img).reshape(2000,200,200,3)
Creating the training and validation sets
x_train= train_img.reshape(train_img.shape[0],1) y_train = np.zeros((2000, 2)) for i in range(1000): y_train[i,0]=1 for i in range(1000,2000): y_train[i,1]=1 from sklearn.model_selection import train_test_split X_train, X_valid, Y_train, Y_valid=train_test_split(x_train,y_train,test_size=0.3, random_state=42)
Creating the model structure (using keras)
from keras.layers import Dense, Activation model=Sequential() model.add(Dense(1000, input_dim=200*200*3, activation='relu',kernel_initializer='uniform')) keras.layers.core.Dropout(0.3, noise_shape=None, seed=None) model.add(Dense(500,input_dim=1000,activation='sigmoid')) keras.layers.core.Dropout(0.4, noise_shape=None, seed=None) model.add(Dense(150,input_dim=500,activation='sigmoid')) keras.layers.core.Dropout(0.2, noise_shape=None, seed=None) model.add(Dense(units=2)) model.add(Activation('softmax')) model.compile(loss='categorical_crossentropy', optimizer="adam", metrics=['accuracy']) # fitting the model model.fit(X_train, Y_train, epochs=20, batch_size=50,validation_data=(X_valid,Y_valid))
fitting the model
model.fit(X_train, Y_train, epochs=20, batch_size=50,validation_data=(X_valid,Y_valid))
Output of fitting the model
Train on 1400 samples, validate on 600 samples Epoch 1/20 1400/1400 [==============================]  73s 52ms/step  loss: 0.8065  acc: 0.4814  val_loss: 0.6939  val_acc: 0.5033 Epoch 2/20 1400/1400 [==============================]  72s 51ms/step  loss: 0.7166  acc: 0.5043  val_loss: 0.7023  val_acc: 0.4967 Epoch 3/20 1400/1400 [==============================]  73s 52ms/step  loss: 0.6969  acc: 0.5214  val_loss: 0.6966  val_acc: 0.4967 Epoch 4/20 1400/1400 [==============================]  71s 51ms/step  loss: 0.6986  acc: 0.4857  val_loss: 0.6932  val_acc: 0.4967 Epoch 5/20 1400/1400 [==============================]  74s 53ms/step  loss: 0.7018  acc: 0.4686  val_loss: 0.7080  val_acc: 0.4967 Epoch 6/20 1400/1400 [==============================]  76s 54ms/step  loss: 0.7041  acc: 0.4843  val_loss: 0.6931  val_acc: 0.5033 Epoch 7/20 1400/1400 [==============================]  73s 52ms/step  loss: 0.7002  acc: 0.4771  val_loss: 0.6973  val_acc: 0.4967 Epoch 8/20 1400/1400 [==============================]  70s 50ms/step  loss: 0.7039  acc: 0.5014  val_loss: 0.6931  val_acc: 0.5033 Epoch 9/20 1400/1400 [==============================]  72s 51ms/step  loss: 0.6983  acc: 0.4971  val_loss: 0.7109  val_acc: 0.5033 Epoch 10/20 1400/1400 [==============================]  72s 51ms/step  loss: 0.7063  acc: 0.4986  val_loss: 0.7151  val_acc: 0.4967 Epoch 11/20 1400/1400 [==============================]  78s 55ms/step  loss: 0.6984  acc: 0.5043  val_loss: 0.7026  val_acc: 0.5033 Epoch 12/20 1400/1400 [==============================]  78s 55ms/step  loss: 0.6993  acc: 0.4929  val_loss: 0.6958  val_acc: 0.4967 Epoch 13/20 1400/1400 [==============================]  90s 65ms/step  loss: 0.7000  acc: 0.4843  val_loss: 0.6970  val_acc: 0.4967 Epoch 14/20 1400/1400 [==============================]  78s 56ms/step  loss: 0.7052  acc: 0.4829  val_loss: 0.7029  val_acc: 0.4967 Epoch 15/20 1400/1400 [==============================]  80s 57ms/step  loss: 0.7003  acc: 0.5014  val_loss: 0.6993  val_acc: 0.5033 Epoch 16/20 1400/1400 [==============================]  77s 55ms/step  loss: 0.6933  acc: 0.5200  val_loss: 0.6985  val_acc: 0.5033 Epoch 17/20 1400/1400 [==============================]  78s 56ms/step  loss: 0.6962  acc: 0.4871  val_loss: 0.7086  val_acc: 0.4967 Epoch 18/20 1400/1400 [==============================]  81s 58ms/step  loss: 0.6987  acc: 0.4971  val_loss: 0.7119  val_acc: 0.4967 Epoch 19/20 1400/1400 [==============================]  77s 55ms/step  loss: 0.7010  acc: 0.5171  val_loss: 0.6969  val_acc: 0.4967 Epoch 20/20 1400/1400 [==============================]  74s 53ms/step  loss: 0.6984  acc: 0.5057  val_loss: 0.6936  val_acc: 0.5033 <keras.callbacks.History at 0x23903fc7c88>
Prediction on elements of training set:
print(model.predict(X_train[240].reshape(1,120000))) print(model.predict(X_train[350].reshape(1,120000))) print(model.predict(X_train[555].reshape(1,120000))) print(model.predict(X_train[666].reshape(1,120000))) print(model.predict(X_train[777].reshape(1,120000)))
Output of these operations
[[0.5188029 0.48119715]] [[0.5188029 0.48119715]] [[0.5188029 0.48119715]] [[0.5188029 0.48119715]] [[0.5188029 0.48119715]]
Prediction on elements of validation set
print(model.predict(X_valid[10].reshape(1,120000))) print(model.predict(X_valid[20].reshape(1,120000))) print(model.predict(X_valid[30].reshape(1,120000))) print(model.predict(X_valid[40].reshape(1,120000))) print(model.predict(X_valid[50].reshape(1,120000)))
Output of these operations
[[0.5188029 0.48119715]] [[0.5188029 0.48119715]] [[0.5188029 0.48119715]] [[0.5188029 0.48119715]] [[0.5188029 0.48119715]]
I am really confused because I don't know why do I got this result. I also tried another classification for gender (men/women) and also got similar result, in other words I do get a fixed value output whatever is the value of the input ( basically telling me that all observations are women)....
Here is the part I am talking about in the begining of the thread:
Classifying cars and planes ( reproduciable)#importing keras cifar from keras.datasets import cifar10 (x_train, y_train), (x_test, y_test) = cifar10.load_data() #Building labeled arrays of cars and planes: 5000 first are plane, 5000 last are car #Building x_train_our a=(y_train==0) x_plane=x_train[list(a[:,0])] a=(y_train==1) x_car=x_train[list(a[:,0])] x_train_our=np.append(x_plane,x_car,axis=0) #Building y_train_our y_train_our = np.zeros((10000, 2)) for i in range(5000): y_train_our[i,0]=1 for i in range(5000,10000): y_train_our[i,1]=1 print('x_train_our shape: ',x_train_our.shape) print('y_train_our shape: ',y_train_our.shape) #Train set and valid set x_train_our= x_train_our.reshape(x_train_our.shape[0],1) y_train_our=y_train_our print('x_train_our shape: ',x_train_our.shape) print('y_train_our shape: ',y_train_our.shape) from sklearn.model_selection import train_test_split X_train_our, X_valid_our, Y_train_our, Y_valid_our=train_test_split(x_train_our,y_train_our,test_size=0.3, random_state=42) #testing typology of different elements print("testing size of different elements et toplogie: ") print("x_train_our size: ",x_train_our.shape) print("y_train_our size: ",y_train_our.shape) print("X_train_our size: ",X_train_our.shape) print("X_valid_our size: ",X_valid_our.shape) print("Y_train_our size: ",Y_train_our.shape) print("Y_valid_our size: ",Y_valid_our.shape) #Mode1: creating a mlp model which is going to be the output for the YOLO model from keras.layers import Dense, Activation model=Sequential() model.add(Dense(1000, input_dim=32*32*3, activation='relu',kernel_initializer='uniform')) keras.layers.core.Dropout(0.3, noise_shape=None, seed=None) model.add(Dense(500,input_dim=1000,activation='sigmoid')) keras.layers.core.Dropout(0.4, noise_shape=None, seed=None) model.add(Dense(150,input_dim=500,activation='sigmoid')) keras.layers.core.Dropout(0.2, noise_shape=None, seed=None) model.add(Dense(units=2)) model.add(Activation('softmax')) model.compile(loss='categorical_crossentropy', optimizer="adam", metrics=['accuracy']) # fitting the model model.fit(X_train_our, Y_train_our, epochs=20, batch_size=10,validation_data=(X_valid_our,Y_valid_our)) #Build test set a=(y_test==0) x_test_plane=x_test[list(a[:,0])] a=(y_test==1) x_test_car=x_test[list(a[:,0])] # Test model for i in range(1000): print('it should be a plane: ',model.predict(x_plane[i].reshape(1,1))) for i in range(1000): print('it should be a car: ',model.predict(x_car[i].reshape(1,1)))
Output
x_train_our shape: (10000, 32, 32, 3) y_train_our shape: (10000, 2) x_train_our shape: (10000, 3072) y_train_our shape: (10000, 2) testing size of different elements et toplogie: x_train_our size: (10000, 3072) y_train_our size: (10000, 2) X_train_our size: (7000, 3072) X_valid_our size: (3000, 3072) Y_train_our size: (7000, 2) Y_valid_our size: (3000, 2) Train on 7000 samples, validate on 3000 samples Epoch 1/20 7000/7000 [==============================]  52s 7ms/step  loss: 0.7114  acc: 0.4907  val_loss: 0.7237  val_acc: 0.4877 Epoch 2/20 7000/7000 [==============================]  51s 7ms/step  loss: 0.7004  acc: 0.4967  val_loss: 0.7065  val_acc: 0.4877 Epoch 3/20 7000/7000 [==============================]  51s 7ms/step  loss: 0.6979  acc: 0.4981  val_loss: 0.6977  val_acc: 0.4877 Epoch 4/20 7000/7000 [==============================]  52s 7ms/step  loss: 0.6990  acc: 0.4959  val_loss: 0.6970  val_acc: 0.4877 Epoch 5/20 7000/7000 [==============================]  53s 8ms/step  loss: 0.6985  acc: 0.5030  val_loss: 0.6929  val_acc: 0.5123 Epoch 6/20 7000/7000 [==============================]  52s 7ms/step  loss: 0.6970  acc: 0.5036  val_loss: 0.7254  val_acc: 0.4877 Epoch 7/20 7000/7000 [==============================]  51s 7ms/step  loss: 0.6968  acc: 0.5047  val_loss: 0.6935  val_acc: 0.5123 Epoch 8/20 7000/7000 [==============================]  47s 7ms/step  loss: 0.6970  acc: 0.5076  val_loss: 0.6941  val_acc: 0.5123 Epoch 9/20 7000/7000 [==============================]  50s 7ms/step  loss: 0.6982  acc: 0.5024  val_loss: 0.6928  val_acc: 0.5123 Epoch 10/20 7000/7000 [==============================]  47s 7ms/step  loss: 0.6974  acc: 0.5010  val_loss: 0.7222  val_acc: 0.4877 Epoch 11/20 7000/7000 [==============================]  51s 7ms/step  loss: 0.6975  acc: 0.5087  val_loss: 0.6936  val_acc: 0.4877 Epoch 12/20 7000/7000 [==============================]  49s 7ms/step  loss: 0.6991  acc: 0.5021  val_loss: 0.6938  val_acc: 0.4877 Epoch 13/20 7000/7000 [==============================]  49s 7ms/step  loss: 0.6976  acc: 0.4996  val_loss: 0.6983  val_acc: 0.4877 Epoch 14/20 7000/7000 [==============================]  49s 7ms/step  loss: 0.6978  acc: 0.5064  val_loss: 0.6944  val_acc: 0.5123 Epoch 15/20 7000/7000 [==============================]  49s 7ms/step  loss: 0.6993  acc: 0.5019  val_loss: 0.6937  val_acc: 0.5123 Epoch 16/20 7000/7000 [==============================]  49s 7ms/step  loss: 0.6969  acc: 0.5027  val_loss: 0.6930  val_acc: 0.5123 Epoch 17/20 7000/7000 [==============================]  49s 7ms/step  loss: 0.6981  acc: 0.4939  val_loss: 0.6953  val_acc: 0.4877 Epoch 18/20 7000/7000 [==============================]  51s 7ms/step  loss: 0.6969  acc: 0.5030  val_loss: 0.7020  val_acc: 0.4877 Epoch 19/20 7000/7000 [==============================]  51s 7ms/step  loss: 0.6984  acc: 0.5039  val_loss: 0.6973  val_acc: 0.5123 Epoch 20/20 7000/7000 [==============================]  51s 7ms/step  loss: 0.6981  acc: 0.5053  val_loss: 0.6940  val_acc: 0.5123 it should be a plane: [[0.5358367 0.46416324]] it should be a plane: [[0.5358367 0.46416324]] it should be a plane: [[0.5358367 0.46416324]] it should be a plane: [[0.5358367 0.46416324]] it should be a plane: [[0.5358367 0.46416324]] it should be a plane: [[0.5358367 0.46416324]] it should be a plane: [[0.5358367 0.46416324]] it should be a plane: [[0.5358367 0.46416324]] it should be a plane: [[0.5358367 0.46416324]] it should be a plane: [[0.5358367 0.46416324]] it should be a plane: [[0.5358367 0.46416324]] it should be a plane: [[0.5358367 0.46416324]] it should be a plane: [[0.5358367 0.46416324]] it should be a plane: [[0.5358367 0.46416324]] it should be a car: [[0.5358367 0.46416324]] it should be a car: [[0.5358367 0.46416324]] it should be a car: [[0.5358367 0.46416324]] it should be a car: [[0.5358367 0.46416324]] it should be a car: [[0.5358367 0.46416324]] it should be a car: [[0.5358367 0.46416324]] it should be a car: [[0.5358367 0.46416324]] it should be a car: [[0.5358367 0.46416324]] it should be a car: [[0.5358367 0.46416324]] it should be a car: [[0.5358367 0.46416324]]

calibrating nonparallel stereo camera through opencv on python causes a great distortion
opencv = 3.4 python = 3.5 ubuntu 16.04
I tried to use the following functions in opencv 3.4 to calibrate my stereo camera and then reconstruct the points on my chessboard:
 cv2.calibrateCamera
 cv2.stereoCalibrate
 cv2.stereoRectify
 cv2.triangulatePoints
The result should be a set of rectangles approximately on the same plane and the distances between each points should be the same. However, the result shows that the distances seem to be larger and larger in a specific direction. The last distance on one chessboard is about 23 times bigger than the first distance.
We have tried our algorithm on opencv dataset (left0114, right0114): https://github.com/opencv/opencv/tree/master/samples/data The result is quite good.
Guessed Key Points:
I notice that the key difference of us is how we set two cameras. The example images are taken from two parallel cameras with small distance. But my images are taken from two nonparallel cameras with a relative big distance.
More information: I've checked the undistorted images from intrinsic parameters separately and the figures are good.
Does that mean I must only keep the cameras parallel with each other

high accuracy 3d point cloud
I need to get a point cloud with Zaxis error ~0.5 mm (and with minimum percent of noise, yeah I'm a dreamer) but the scene is controlled by me  it's a small box (0.5x0.5 m) which I can light up and paint as I want. Right now, I'm trying stereo pair with 2 cameras and opencv. The box contains the mesuarable objects, depth map is built from Top view. Distance from cameras to scene can be controlled too. I need only top view btw.
1) Should I use that method with stereo pair and opencv algorithms, or it's too hard or even impossible to get that accuracy?
2) If it is than what should I look for  I know about a method with thin laser line and 1 camera, scene is moving by the engine, I take a hundered pictures while its moving through laser and than calculate the hight of points that are under laser so in the end I should get my point cloud. What do you think about it?
3) If not sure can you please give me advice where should I look for more information.

3D Dense Reconstruction with Single Camera
I am trying to develop a 3D reconstruction program, using single ordinary webcam. Webcam stays still, when I am rotating the object and taking consecutive 2 pictures of it. I am using two pictures to reconstruct the scene.
My workflow as follows:
 Calibrate camera
 Undistort images
 Estimate essential matrix
 Find relative camera poses
 Detect thousands of features to reconstruct the scene
 Triangulate
 Show the point cloud
Here is an example of this workflow:
and This is the corresponding scene:
My question is, How can I increase the density of my reconstruction? Any algorithm, method, workflow or any hint would be appreciated.