Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Check your <code>fetchedBytes</code> array to see if you are consistently getting <em>just</em> a stream of bytes representing a BMP image (starting with <code>0x42 0x4D</code>), or if there may be "other stuff" in there, too.</p> <p>Depending on how the BMP data was inserted into the Access database it <em>may</em> contain an OLE "wrapper". For example, an 8x8 24-bit BMP image of pure red is saved by MSPAINT.EXE like this</p> <p><img src="https://i.stack.imgur.com/gtBGn.png" alt="bmpDump.png"></p> <p>If I copy that file and paste it into a Bound Object Frame in an Access form then Access wraps the BMP data in some "OLE stuff" before writing it to the table. Later, if I try to retrieve the BMP image via code, using something like this...</p> <pre class="lang-vbs prettyprint-override"><code>Sub oleDumpTest() Dim rst As ADODB.Recordset, ads As ADODB.Stream Set rst = New ADODB.Recordset rst.Open "SELECT * FROM TrainingSet1 WHERE ID = 1", Application.CurrentProject.Connection Set ads = New ADODB.Stream ads.Type = adTypeBinary ads.Open ads.Write rst("FaceImage").Value rst.Close Set rst = Nothing ads.SaveToFile "C:\Users\Gord\Pictures\oleDump_red." ads.Close Set ads = Nothing End Sub </code></pre> <p>...then the resulting file also contains the OLE "wrapper"...</p> <p><a href="https://i.stack.imgur.com/KhXcL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KhXcL.png" alt="oleDump.png"></a></p> <p>...and obviously is not a valid stand-alone BMP file. If I rename that file to give it a <code>.bmp</code> extension and try to open it in Paint, I get</p> <p><img src="https://i.stack.imgur.com/fNuOj.png" alt="paintError.png"></p> <p>So maybe (some of) the [FaceImage] objects in your database are not raw BMP data, and perhaps the other software is rejecting them (or simply not able to understand them).</p> <h2>Edit</h2> <p>Another possible issue is that when you get the images from files in a folder you hand the <code>Image</code> object a string containing the file path...</p> <pre><code>trainingImages.Add(new Image&lt;Gray, byte&gt;(Application.StartupPath + "\\TrainedFaces\\" + LoadFaces)); </code></pre> <p>...but when you try to retrieve the images from the database you hand the same object a <code>Bitmap</code> object</p> <pre><code>MemoryStream stream = new MemoryStream(fetchedBytes); bmpImage = new Bitmap(stream); trainingImages.Add(new Emgu.CV.Image&lt;Gray, Byte&gt;(bmpImage)); </code></pre> <p>I have no way of knowing whether the <code>Emgu.CV.Image</code> object might behave differently depending on the type of object it is given, but a quick+dirty workaround might be to write <code>bmpImage</code> to a temporary file, hand <code>trainingImages.Add</code> the path to that file, and then delete the file.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload