How to display a point cloud inside MATLAB GUI? - matlab

I am building a GUI in MATLAB and I want to display point clouds in a figure inside this GUI. The GUI plays a 3D recording and enables me to pause/play, change speeds and change the video I am playing.
So far I've used pcplayer to display point clouds. For example:
player = pcplayer(xlimits, ylimits, zlimits, 'MarkerSize', 100);
view(player,point_cloud);
However this opens up a new figure. I've tried using pcshow:
pcshow(point_cloud, 'Parent', axes_to_plot);
This worked, but only for the first frame of the video. Afterwards I receive an error:
Property assignment is not allowed when the object is empty. Use subscripted assignment to create an array element.
This is not a problem with the clouds that I am trying to draw: they are not empty, and in addition trying to draw the same cloud twice results in the same error. There is something happening there that I do not understand.
Does anyone know how to solve my problem?
I am using MATLAB version 2016a.

Hi I have the same problem with the exact same error. This started since I have started to use matlab 2016b, did not have this problem with 2015b. I don't have exact solution, but what I did is that I put the pcshow to try catch environment to suppress the error. It works for me because pcshow makes the figure and then throws the error.
try
pcshow(point_cloud, 'Parent', axes_to_plot);
catch
end
Again this is not the solution to resolve the error, but could make your code work, it did mine.

Related

3D viewing program in Scratch.mit rotation problem

Whenever I rotate the object it squishes along either the x or z directions. I’m using this equation for the rotations.
x = x2cosθ−y2sinθ and y=x2sinθ+y2cosθ. x2=xcosθ+ysinθ and y2=−xsinθ+y*cosθ.
θ is the angle you are setting it to.
I tried making a second list for each coordinate line but it gave me me problems like possible 4d rotations
Never mind, I got it working. Also sry for not responding, I don’t have notifications as an available option. Here’s the project link though https://scratch.mit.edu/projects/790020886/

How to get the current Axes.View after using rotate3d interaction in MATLAB appdesigner?

I'm using MATLAB R2021b appdesigner to design a UI . And my request is that I want to get the current axes view (azimuth & elevation data) after rotating my plot via rotate3d interation tool using my mouse. I have checked the related documentation and found that the following code worked well in the script form:
function demo_mbd2
% Listen to rotate events
surf(peaks);
h = rotate3d;
h.ActionPreCallback = #myprecallback;
h.ActionPostCallback = #mypostcallback;
h.Enable = 'on';
function myprecallback(obj,evd)
disp('A rotation is about to occur.');
function mypostcallback(obj,evd)
newView = round(evd.Axes.View);
msgbox(sprintf('The new view is [%d %d].',newView));
However, I have no idea of how to embed it in the appdesigner environment. For example, I'm not aware of the right form of callback function - neither mypostcallback(app, obj, evd) nor mypostcallback(obj, evd) worked.
I haven't learned so much about call back functions yet I'm in desperate need of solving this specific problem. Could anyone lend me a hand? Are there any feasible ways to use the previous codes, or do we have any other solutions?
Huge thanks!!!

ROS ORB-Slam2 Map Point Vector is Empty

I am trying to get mapping to work with ROS. I have a Raspberry Pi 3B+ with a Picamera v2 running ROS Noetic. It is running cv_camera_node to broadcast the camera images. I also have an Ubuntu 20.04.1 running ROS Noetic along with ORB-SLAM2. I was able to get the debug_image to display the grayscale image with the green lines. I can't get it to pass the initialization stage. The debug image keeps on saying "Trying to initialize" and the output of the ORB Slam launch file says, "Map point vector is empty!" I was able to get it to work twice but I don't know how. How do I properly calibrate it?
I have faced this issue before. I was able to get around this by applying this patch and trying different image sizes to see what worked best.
You need a lot of points, about 300, to get it to pass this stage. Try to find a thing with an intricate design like a fan that has the fancy blade guard or a messy desk. That will have close to 300 points needed for calibration.

impoly become slow in MATLAB deployed standalone application

I'm building a standalone guide application which uses impoly inside.
When I drag the vertices of polygon created using impoly or drag the polygon itself, there's noticeable delay for actions, this doesn't happen in the MATLAB script file.
Even a simple script like the code below will create the delay after being converted to executable.
figure, imshow('peppers.png')
h = impoly(gca, []);
What is causing the delay here, and how can I solve this?
I know that using self defined drawing functions and windowbutton functions is faster but I don't want to lose the ease of using an impoly object because it's handled by internal codes.
The compiler version is R2011a.
Updates:
Not only impoly becomes slow when deployed. All rendering of graphic objects become slow. Pan tool and zoom tools have delays as well.
The solution is using uiwait to block the execution before exit. But I don't know why that solves the problem.

Using Haar features for cascade object detector MATLAB

I am trying to use the vision.cascadeObjectDetector (MATLAB) to detect heads from a CCTV footage(and not faces). Till now, I have tried the following:
Used vision.cascadeObjectDetector to detect faces.
trained it to detect a sign (an example shown in read me file)
created a folder with positive & negative training HEAD images & same for testing
tried to create a .mat file using trainingImageLabeler (although it gave me an error when trying to pass it as param to the object detector).
Can someone try to put me in the right track, to start detecting heads using Viola-Jones Haar features please?