Feed images 1by 1 from folder into function - image

I have an INPUT_IMAGE_CHECK_ALL function that takes image. In INPUT_IMAGE_CHECK_ALL there are 7 functions that image is passed to.
How do I feed images from folder 1 by 1 to the INPUT_IMAGE_CHECK_ALL function?
image = imread('6-Capmissing/capmissing-image078.jpg');
INPUT_IMAGE_CHECK_ALL(image);
INPUT_IMAGE_CHECK_ALL code:
function [ ] = INPUT_IMAGE_CHECK_ALL( image )
CHECK_FOR_CAP(image);
CHECK_FOR_NOLABEL(image);
CHECK_FOR_NOLABELPRINT(image);
CHECK_FOR_OVERFILLED(image);
CHECK_FOR_LABELNOTSTRAIGHT(image);
CHECK_FOR_UNDERFILLED(image);
end
Images that I want to feed into INPUT_IMAGE_CHECK_ALL are in folder "All" named image001 to image141.

Since you know how the name of the images you want to read (image001, image002, ... from 1 to 141) the easiest way is to use a loop in which:
build the names using the function sprintf
read the image whith the name you've build
feed your function with the image data
A possible implementation could be
for img_idx=1:141
img_name=sprintf('All/image%3.3d.jpg',img_idx)
disp(['Reading ' img_name])
the_image=imread(img_name);
INPUT_IMAGE_CHECK_ALL(the_image);
end
In the above code:
notice the format used in the call to sprintf: %3.3d: this allows padding with 0 the number in the buildoing of the filename, so that you can have 001, 002, ... 013 and so on
if the folder All in which your images are stored is not in the MatlLab path you have to specify the folder in building the filename
I've used the_image as name of the variable in which to store the data of the image because image (the varaible you are using) is a MatLab function.
the call to the disp function is used only to print on the CommandWindow a message about what the script is dooing (which image is processing); you can remove it
If the folder All only the images you you want to process, another possibility could be to get the list of images using the function dir to get the filenames of the
The function dir returns a struct in which the information about the files are stored.
In this case you have to loop over the list returned by dir
% Get the filenames of all the images in the folder "All"
img_list=dir('All/image*.jpg')
% Loops over the list of images
for img_idx=1:length(img_list)
img_name=['All/' img_list(img_idx).name]
disp(['Reading ' img_name])
the_image=imread(img_name)
INPUT_IMAGE_CHECK_ALL(the_image);
end
Hope this helps,
Qapla'

Related

i want to arrange the data as in text file but its format has been changed when i tried to get the file from directory and displayed in an app

I want to arrange the data as in a text file but its format has been changed when I tried to get the file from a directory and displayed it in an app the problem for me is it has no reference point at the line ending so I don't know how can I explode it Here is the file format:
This is how data should look
and this is how I am getting data:
This is how m getting the data now
one more thing from these lines I want to pick some data to be stored how can I pick data without reference points?
I mean as you see here:
PIDF***HEMP ZONE ULTRA THIN ROLLING PAPERS 1.25" 25CT~
we have * and ~ to explode and get the data in array format but how can we pick data when the data is like that:
B84921501625VSSE ALTO MENT 463405005397BX00090500360078000
"as I want to pick the name "ALTO MENT" 4, "63405005397
how can I pick that data?
Here is what I did till now:
public function read_confirmation(){
$cpath = public_path('confirmations\pending');
$c_allfiles = scandir($cpath);
$c_allfiles = array_diff(scandir($cpath), array('.', '..'));
foreach ($c_allfiles as $fname) {
$file= File::get(public_path('confirmations\pending/'.$fname));
return $file;}
}

Laravel Multiple Upload File

How to show uploaded files using multiple upload files?
With data like this
Lets consider you name is in this variable = $uploadedFiles;
$uploadedFiles = ["file1","file2","file3"];
$temp = json_decode($uploadedFiles);
foreach($temp as $name) {
echo $name;
}
It will print your file name 1 by 1
It just names you need the files also
but if you want to store only that names then you can do it by taking a loop for that variable array
if it is not an array then convert to array using json_decode(array)

generating multiple pdf document and merge into one

This is my controller function where i am running a loop to create multiple document pdf
and merge into one.
public function tick_pdf(){
$tt='';
$name="iftekhar";
$title="Event Football";
$num=4;
for($i=0;$i<4;$i++){
$this->pdfHeader($row->EventId);
$this->pdf->fontpath = 'font/';
//$this->pdf->AddPage();
$this->pdf->Ln(10);
$this->pdf->SetFont('Arial','B',12);
$this->pdf->Cell(10);
$this->pdf->Cell(60,10,"Name",0,0,'L');
$this->pdf->Cell(10,10,":",0,0,'L');
$this->pdf->MultiCell(60,10,$name,0,1);
$this->pdf->SetFont('Arial','B',12);
$this->pdf->Cell(10);
$this->pdf->Cell(60,10,"Title",0,0,'L');
$this->pdf->Cell(10,10,":",0,0,'L');
$this->pdf->MultiCell(60,10,$title,0,1);
$this->pdf->SetFont('Arial','B',12);
$this->pdf->Cell(10);
$this->pdf->Cell(60,10,"Number",0,0,'L');
$this->pdf->Cell(10,10,":",0,0,'L');
$this->pdf->MultiCell(60,10,$num,0,1);
$this->pdf->SetFont('Arial','B',12);
$this->pdf->Cell(10);
$this->pdf->Cell(60,10,"Date",0,0,'L');
$this->pdf->Cell(10,10,":",0,0,'L');
$this->pdf->MultiCell(60,10,$date,0,1);
$tt.=$this->pdf->Output('', 'S');
}
echo $tt;
}
but I am gettiin an error in browser
"Undefined index: data
Filename: libraries/fpdf.php
Line Number: 1659" I am using fpdf for generating pdf
If you need to create multiple PDF documents you will need several class instances. Actually you're working with only one instance.
Also it is not possible to concatenate a PDF document by simply concatenating their bytes ($tt .= ...). Generally it is not possible to send multiple PDF documents to the client in a single request.
If you want to create multiple pages, just remove the comment before AddPage(), delete the variable $tt and move the Output() call outside of the loop.

Accessing temporary file from upload in django view

Just as the title says, I want to know how to access the data from the temporary file stored by Django, when a file is uploaded, inside a view.
I want to read the data uploaded values so I can make a progress bar. My methodology is to perform a jquery getJSON request:
function update_progress_info() {
$progress.show();
$.getJSON(progress_url, function(data, status){
if (data) {
var progress = parseInt(data.uploaded) / parseInt(data.length);
var width = $progress.find('.progress-container').width()
var progress_width = width * progress;
$progress.find('.progress-bar').width(progress_width);
$progress.find('.progress-info').text('uploading ' + parseInt(progress*100) + '%');
}
window.setTimeout(update_progress_info, freq);
});
};
where progress_url is the view I have that handles the uploaded file data:
# views.py (I don't know what to do here):
def upload_progress(request):
for line in UploadedFile.temporary_file_path
response = (line)
return response
Django handles uploaded files with UploadHandler defined in settings.py with this name FILE_UPLOAD_HANDLERS that defaults to this tuple:
FILE_UPLOAD_HANDLERS =
("django.core.files.uploadhandler.MemoryFileUploadHandler",
"django.core.files.uploadhandler.TemporaryFileUploadHandler",)
The behavior with file uploads is that if the file is less than 2.5 mg then it will be kept on memory, hence, they will not be written in disk as temporary files.
If the file weights more, it will be written in chunks in the FILE_UPLOAD_TEMP_DIR in the settings.py. That's the file you'll have to query to know how many bytes have been uploaded.
You can access the uploaded/uploading files through your request variables in views like this: file = requests.FILES['file'] . There, file variable will have the type UploadedFile which contains a method temporary_file_path with the address of the file in the disk being uploaded. (Note: only files larger than 2.5 mg will have this methods) so there you may get the size of the file being uploaded.
Another way to do this is create your own UploadHandler like a ProgressBarUploadHandler and add it to your file upload handlers. This is the way the docs recommend it. Here are some snippets and tutorials for doing it.
If you need any more info the doc is really well documented.
I hope you find this helpful. Good luck.

Display of MATLAB workspace variable into GUI function

I have a variable in the MATLAB workspace and I want to pass this variable to a function in my GUI.
How do I achieve this task?
You can use the function EVALIN in your GUI to get the value of a variable from the base workspace. The following example extracts the value of the variable A in the base workspace and places that value in the local variable B:
B = evalin('base','A');
You could, for example, have an editable text box in your GUI that allows the user to enter the name of a variable to import from the base workspace. One of your GUI functions could then read the string from the editable text box and attempt to fetch that variable from the base workspace to use in some computation:
varName = get(hEditText,'String'); %# Get the string value from the uicontrol
%# object with handle hEditText
try %# Make an attempt to...
varValue = evalin('base',varName); %# get the value from the base workspace
catch exception %# Catch the exception if the above fails
error(['Variable ''' varName ... %# Throw an error
''' doesn''t exist in workspace.']);
end
You can use SETAPPDATA (in the main workpsace) and GETAPPDATA (in GUI) functions.
If you variable is someMatrix
setappdata(0,'someMatrix',someMatrix) % in the main workspace
someMatrix = getappdata(0,'someMatrix') % in GUI

Resources